From 9c9dba5f2cc990a0958fae854fe1287c6b84e4fb Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Mon, 13 Jun 2016 00:13:04 +0530 Subject: [PATCH 1/5] Adding users.feature scenarios using gherkin --- .gitignore | 1 - RoboFile.php | 11 +- tests/_support/AcceptanceTester.php | 149 +++++++++++++- .../Page/Acceptance/Administrator/Login.php | 39 +++- .../Step/Acceptance/Administrator/User.php | 187 +++++++++++++++++- tests/acceptance/administratorlogin.feature | 12 +- 6 files changed, 367 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index 19ab14c416..9faa430049 100644 --- a/.gitignore +++ b/.gitignore @@ -26,7 +26,6 @@ tests/codeception/_output/* tests/codeception/vendor/* tests/codeception/testingsite* tests/codeception/tests/acceptance.suite.yml -tests/codeception/tests/acceptance/*Tester.php tests/codeception/tests/functional/*Tester.php tests/codeception/tests/unit/*Tester.php diff --git a/RoboFile.php b/RoboFile.php index ba3cf01c0a..1d5022cece 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -274,6 +274,15 @@ public function runTests($opts = ['use-htaccess' => false, 'env' => 'desktop']) ->stopOnFail(); $this->taskCodecept($pathToCodeception) + ->arg('--steps') + ->arg('--debug') + ->arg('--fail-fast') + ->arg('--env ' . $opts['env']) + ->arg('tests/acceptance/users.feature') + ->run() + ->stopOnFail(); + + /* $this->taskCodecept($pathToCodeception) ->arg('--steps') ->arg('--debug') ->arg('--fail-fast') @@ -289,7 +298,7 @@ public function runTests($opts = ['use-htaccess' => false, 'env' => 'desktop']) ->arg('--env ' . $opts['env']) ->arg('tests/acceptance/frontend/') ->run() - ->stopOnFail(); + ->stopOnFail();*/ /* // Uncomment this lines if you need to debug selenium errors diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 4c7dcbb6d6..3b29d824ee 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -1,6 +1,4 @@ waitForText($title, $timeout, ['class' => 'page-title']); + } + + /** + * Function to check for PHP Notices or Warnings + * + * @param string $page Optional, if not given checks will be done in the current page + * + * @note: doAdminLogin() before + */ + public function checkForPhpNoticesOrWarnings($page = null) + { + $I = $this; + + if ($page) + { + $I->amOnPage($page); + } + + $I->dontSeeInPageSource('Notice:'); + $I->dontSeeInPageSource('Notice:'); + $I->dontSeeInPageSource('Warning:'); + $I->dontSeeInPageSource('Warning:'); + $I->dontSeeInPageSource('Strict standards:'); + $I->dontSeeInPageSource('Strict standards:'); + $I->dontSeeInPageSource('The requested page can\'t be found'); + } + + /** + * Function to select Toolbar buttons in Joomla! Admin Toolbar Panel + * + * @param string $button The full name of the button + */ + public function clickToolbarButton($button) + { + $I = $this; + $input = strtolower($button); + + // @todo Needs to find way to work with different window size. + /*$screenSize = explode("x", $this->config['window_size']); + if($screenSize[0] <= 480) + { + $I->click('Toolbar'); + }*/ + + switch($input) + { + case "new": + $I->click(['xpath' => "//div[@id='toolbar-new']//button"]); + break; + case "edit": + $I->click(['xpath' => "//div[@id='toolbar-edit']//button"]); + break; + case "publish": + $I->click(['xpath' => "//div[@id='toolbar-publish']//button"]); + break; + case "unpublish": + $I->click(['xpath' => "//div[@id='toolbar-unpublish']//button"]); + break; + case "archive": + $I->click(['xpath' => "//div[@id='toolbar-archive']//button"]); + break; + case "check-in": + $I->click(['xpath' => "//div[@id='toolbar-checkin']//button"]); + break; + case "batch": + $I->click(['xpath' => "//div[@id='toolbar-batch']//button"]); + break; + case "rebuild": + $I->click(['xpath' => "//div[@id='toolbar-refresh']//button"]); + break; + case "trash": + $I->click(['xpath' => "//div[@id='toolbar-trash']//button"]); + break; + case "save": + $I->click(['xpath' => "//div[@id='toolbar-apply']//button"]); + break; + case "save & close": + $I->click(['xpath' => "//div[@id='toolbar-save']//button"]); + break; + case "save & new": + $I->click(['xpath' => "//div[@id='toolbar-save-new']//button"]); + break; + case "cancel": + $I->click(['xpath' => "//div[@id='toolbar-cancel']//button"]); + break; + case "options": + $I->click(['xpath' => "//div[@id='toolbar-options']//button"]); + break; + case "empty trash": + $I->click(['xpath' => "//div[@id='toolbar-delete']//button"]); + break; + } + } + + /** + * Function to select all the item in the Search results in Administrator List + * + * Note: We recommend use of checkAllResults function only after searchForItem to be sure you are selecting only the desired result set + * + * @return void + */ + public function checkAllResults() + { + $I = $this; + //$this->debug("Selecting Checkall button"); + $I->click(['xpath' => "//thead//input[@name='checkall-toggle' or @name='toggle']"]); + } - /** - * Define custom actions here - */ + /** + * Selects an option in a Chosen Selector based on its id + * + * @param string $selectId The id of the