From 64404e3a506cf1c12ee7b19196e743dea5fdb2f3 Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Sat, 7 May 2016 11:42:10 +0530 Subject: [PATCH 01/18] added content feature scenario using gherkin --- tests/acceptance/content.feature | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/acceptance/content.feature diff --git a/tests/acceptance/content.feature b/tests/acceptance/content.feature new file mode 100644 index 0000000000..c04081a06b --- /dev/null +++ b/tests/acceptance/content.feature @@ -0,0 +1,37 @@ +Feature: Content + In order to manage content articles in the web + As an owner + I need to be able to create and modify content articles + + Background: + Given I am logged in at Joomla administrator as "admin" with password "admin" + And I open administrator dashboard page + + Scenario: create featured content + Given there is a content article with title "My first Joomla Content" + When I feature the content with title "My first Joomla Content" + Then I should see the published article "My first Joomla Content" in the joomla home page + + Scenario: Add New Article + Given there is a content article with title "My first Joomla Article" + When I feature the content with title "My first Joomla Article" + Then I should see the published article "My first Joomla Article" in the joomla home page + + Scenario: Edit Article + Given there is a list of content article with title + And I select the content article for edit with title "My first Joomla Article" + When I feature the content with title "My first Joomla Article" + Then I should see the published article "My first Joomla Article" in the joomla home page + + Scenario: Unpublish Article + Given there is a list of content article with title + And I select the content article for unpublish with title "My first Joomla Article" + When I unpublished the content with title "My first Joomla Article" + Then I should not see the unpublished article "My first Joomla Article" in the joomla home page + + Scenario: publish Article + Given there is a list of content article with title + And I select the content article which is unpublish with title "My first Joomla Article" + When I published the content with title "My first Joomla Article" + Then I should see the published article "My first Joomla Article" in the joomla home page + From fb1d48fbda0c6bc2350bf5a791ff52247a6623fb Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Thu, 12 May 2016 08:23:10 +0530 Subject: [PATCH 02/18] Update content feature file --- tests/acceptance/content.feature | 52 ++++++++++++++++---------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/tests/acceptance/content.feature b/tests/acceptance/content.feature index c04081a06b..5705586984 100644 --- a/tests/acceptance/content.feature +++ b/tests/acceptance/content.feature @@ -1,37 +1,37 @@ -Feature: Content - In order to manage content articles in the web +Feature: content + In order to manage content article in the web As an owner - I need to be able to create and modify content articles + I need to create modify delete and un public content article Background: - Given I am logged in at Joomla administrator as "admin" with password "admin" - And I open administrator dashboard page + Given There is an administrator link + When Login into Joomla administrator with username "admin" and password "admin" + Then I see administrator dashboard - Scenario: create featured content - Given there is a content article with title "My first Joomla Content" - When I feature the content with title "My first Joomla Content" - Then I should see the published article "My first Joomla Content" in the joomla home page - - Scenario: Add New Article + Scenario: Feature an Article Given there is a content article with title "My first Joomla Article" When I feature the content with title "My first Joomla Article" Then I should see the published article "My first Joomla Article" in the joomla home page - Scenario: Edit Article - Given there is a list of content article with title - And I select the content article for edit with title "My first Joomla Article" - When I feature the content with title "My first Joomla Article" - Then I should see the published article "My first Joomla Article" in the joomla home page + Scenario: Modify an article + Given I select the content article with title "My first Joomla Article" + And change the title "My Joomla Article" + When I try to post "My Joomla Article" + Then I should see the "Article successfully saved" + And published article "My Joomla Article" in the joomla home page - Scenario: Unpublish Article - Given there is a list of content article with title - And I select the content article for unpublish with title "My first Joomla Article" - When I unpublished the content with title "My first Joomla Article" - Then I should not see the unpublished article "My first Joomla Article" in the joomla home page + Scenario: Unpublish an article + Given I have article with name "My Joomla Article" + When I un publish "My Joomla Article" + Then I can not see the article"My Joomla Article" in the joomla home page - Scenario: publish Article - Given there is a list of content article with title - And I select the content article which is unpublish with title "My first Joomla Article" - When I published the content with title "My first Joomla Article" - Then I should see the published article "My first Joomla Article" in the joomla home page + Scenario: Remove an article + Given I have one content article which needs to be removed + When I delete the article with name "My Joomla Article" + Then I should not see in joomla site frontend + Scenario: Registered user can not see or access article from site + Given I have article with title "My Joomla Article" + And set access to registered + When I do login with registered user "prital" and password "patel" + Then I should see the registered article in the joomla home page From f0412226f1a3de3c7167b93151fac518906833fb Mon Sep 17 00:00:00 2001 From: javier gomez Date: Thu, 12 May 2016 11:40:34 +0200 Subject: [PATCH 03/18] Not ignore acceptance tester --- .gitignore | 1 - 1 file changed, 1 deletion(-) 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 From 7a73da251a61b13f400d32b26ffd382a3daf7860 Mon Sep 17 00:00:00 2001 From: javier gomez Date: Thu, 12 May 2016 11:42:25 +0200 Subject: [PATCH 04/18] Add acceptance tester --- tests/_support/AcceptanceTester.php | 30 ++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 4c7dcbb6d6..82d0684477 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -20,7 +20,31 @@ class AcceptanceTester extends \Codeception\Actor { use _generated\AcceptanceTesterActions; - /** - * Define custom actions here - */ + /** + * @Given Joomla CMS is installed + */ + public function joomlaCMSIsInstalled() + { + // throw new \Codeception\Exception\Incomplete("Step `Joomla CMS is installed` is not defined"); + } + + /** + * @When Login into Joomla administrator with username :arg1 and password :arg1 + */ + public function loginIntoJoomlaAdministratorWithUsernameAndPassword($username, $password) + { + $I = $this; + $I->amOnPage('administrator/'); + $I->fillField('Username', $username); + $I->fillField(['id' => 'mod-login-password'], $password); + $I->click('Log in'); + } + + /** + * @Then I see administrator dashboard + */ + public function iSeeAdministratorDashboard() + { + // throw new \Codeception\Exception\Incomplete("Step `I see administrator dashboard` is not defined"); + } } From 529559e2a3b6bea4096d18d84f9fd4bfc6d9559c Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Sun, 15 May 2016 21:43:15 +0530 Subject: [PATCH 05/18] Adding acceptance suits for content feature. --- RoboFile.php | 20 +++ tests/_support/AcceptanceTester.php | 206 ++++++++++++++++++++++++- tests/acceptance/administrator.feature | 9 ++ tests/acceptance/content.feature | 47 +++--- 4 files changed, 260 insertions(+), 22 deletions(-) create mode 100644 tests/acceptance/administrator.feature diff --git a/RoboFile.php b/RoboFile.php index ba3cf01c0a..8a610da4ee 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -273,6 +273,25 @@ public function runTests($opts = ['use-htaccess' => false, 'env' => 'desktop']) ->run() ->stopOnFail(); + $this->taskCodecept($pathToCodeception) + ->arg('--steps') + ->arg('--debug') + ->arg('--fail-fast') + ->arg('--env ' . $opts['env']) + ->arg('tests/acceptance/administrator.feature') + ->run() + ->stopOnFail(); + + $this->taskCodecept($pathToCodeception) + ->arg('--steps') + ->arg('--debug') + ->arg('--fail-fast') + ->arg('--env ' . $opts['env']) + ->arg('tests/acceptance/content.feature') + ->run() + ->stopOnFail(); + + /* $this->taskCodecept($pathToCodeception) ->arg('--steps') ->arg('--debug') @@ -291,6 +310,7 @@ public function runTests($opts = ['use-htaccess' => false, 'env' => 'desktop']) ->run() ->stopOnFail(); + */ /* // Uncomment this lines if you need to debug selenium errors $seleniumErrors = file_get_contents('selenium.log'); diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 82d0684477..e66f1741f6 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -36,7 +36,7 @@ public function loginIntoJoomlaAdministratorWithUsernameAndPassword($username, $ $I = $this; $I->amOnPage('administrator/'); $I->fillField('Username', $username); - $I->fillField(['id' => 'mod-login-password'], $password); + $I->fillField('passwd', $password); $I->click('Log in'); } @@ -45,6 +45,208 @@ public function loginIntoJoomlaAdministratorWithUsernameAndPassword($username, $ */ public function iSeeAdministratorDashboard() { - // throw new \Codeception\Exception\Incomplete("Step `I see administrator dashboard` is not defined"); + $I = $this; + $I->see('Control Panel', 'h1'); } + + /** + * @Given There is a Add Content link + */ + public function thereIsAAddContentLink() + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_content&view=articles'); + $I->clickToolbarButton('New'); + } + + /** + * @When I add the content with title :arg1 + */ + public function iAddTheContentWithTitle($title) + { + $I = $this; + $I->fillField('#jform_title', $title); + } + + /** + * @When I add content body :arg1 + */ + public function iAddContentBody($body) + { + $I = $this; + $I->fillField('#jform_articletext', $body); + } + + /** + * @When I save an article + */ + public function iSaveAnArticle() + { + $I = $this; + $I->clickToolbarButton('Save'); + } + + /** + * @Then I should see the article :arg1 in the joomla frontend + */ + public function iShouldSeeTheArticleInTheJoomlaFrontend($arg1) + { + $I = $this; + $I->amOnPage('/'); + // @todo + } + + + /** + * @Given there is a content article with title :arg1 + */ + public function thereIsAContentArticleWithTitle($My_Article) + { + $I = $this; + $I->wantTo('create article'); + $I->click('nav nav-hover'); + $I->click(''); + $I->click('Featured Articles'); + $I->fillField('Title', $My_Article); + $I->click('save'); + + + } + + /** + * @When I feature the content with title :arg1 + */ + public function iFeatureTheContentWithTitle($arg1) + { + throw new \Codeception\Exception\Incomplete("Step `I feature the content with title :arg1` is not defined"); + } + + /** + * @Then I should see the published article :arg1 in the joomla home page + */ + public function iShouldSeeThePublishedArticleInTheJoomlaHomePage($arg1) + { + throw new \Codeception\Exception\Incomplete("Step `I should see the published article :arg1 in the joomla home page` is not defined"); + } + + /** + * @Given I select the content article with title :arg1 + */ + public function iSelectTheContentArticleWithTitle($arg1) + { + throw new \Codeception\Exception\Incomplete("Step `I select the content article with title :arg1` is not defined"); + } + + /** + * @Given change the title :arg1 + */ + public function changeTheTitle($arg1) + { + throw new \Codeception\Exception\Incomplete("Step `change the title :arg1` is not defined"); + } + + /** + * @When I try to post :arg1 + */ + public function iTryToPost($arg1) + { + throw new \Codeception\Exception\Incomplete("Step `I try to post :arg1` is not defined"); + } + + /** + * @Then I should see the :arg1 + */ + public function iShouldSeeThe($arg1) + { + throw new \Codeception\Exception\Incomplete("Step `I should see the :arg1` is not defined"); + } + + /** + * @Then published article :arg1 in the joomla home page + */ + public function publishedArticleInTheJoomlaHomePage($arg1) + { + throw new \Codeception\Exception\Incomplete("Step `published article :arg1 in the joomla home page` is not defined"); + } + + /** + * @Given I have article with name :arg1 + */ + public function iHaveArticleWithName($arg1) + { + throw new \Codeception\Exception\Incomplete("Step `I have article with name :arg1` is not defined"); + } + + /** + * @When I un publish :arg1 + */ + public function iUnPublish($arg1) + { + throw new \Codeception\Exception\Incomplete("Step `I un publish :arg1` is not defined"); + } + + /** + * @Then I can not see the article :arg1 in the joomla home page + */ + public function iCanNotSeeTheArticleInTheJoomlaHomePage($arg1) + { + throw new \Codeception\Exception\Incomplete("Step `I can not see the article :arg1 in the joomla home page` is not defined"); + } + + /** + * @Given I have one content article which needs to be removed + */ + public function iHaveOneContentArticleWhichNeedsToBeRemoved() + { + throw new \Codeception\Exception\Incomplete("Step `I have one content article which needs to be removed` is not defined"); + } + + /** + * @When I delete the article with name :arg1 + */ + public function iDeleteTheArticleWithName($arg1) + { + throw new \Codeception\Exception\Incomplete("Step `I delete the article with name :arg1` is not defined"); + } + + /** + * @Then I should not see in joomla site frontend + */ + public function iShouldNotSeeInJoomlaSiteFrontend() + { + throw new \Codeception\Exception\Incomplete("Step `I should not see in joomla site frontend` is not defined"); + } + + /** + * @Given I have article with title :arg1 + */ + public function iHaveArticleWithTitle($arg1) + { + throw new \Codeception\Exception\Incomplete("Step `I have article with title :arg1` is not defined"); + } + + /** + * @Given set access to registered + */ + public function setAccessToRegistered() + { + throw new \Codeception\Exception\Incomplete("Step `set access to registered` is not defined"); + } + + /** + * @When I do login with registered user :arg1 and password :arg2 + */ + public function iDoLoginWithRegisteredUserAndPassword($arg1, $arg2) + { + throw new \Codeception\Exception\Incomplete("Step `I do login with registered user :arg1 and password :arg2` is not defined"); + } + + /** + * @Then I should see the registered article in the joomla home page + */ + public function iShouldSeeTheRegisteredArticleInTheJoomlaHomePage() + { + throw new \Codeception\Exception\Incomplete("Step `I should see the registered article in the joomla home page` is not defined"); + } + } diff --git a/tests/acceptance/administrator.feature b/tests/acceptance/administrator.feature new file mode 100644 index 0000000000..ef19bc51c0 --- /dev/null +++ b/tests/acceptance/administrator.feature @@ -0,0 +1,9 @@ +Feature: administrator + In order to manage my web application + As an administrator + I need to have a control panel + + Scenario: Login in Administrator + Given Joomla CMS is installed + When Login into Joomla administrator with username "admin" and password "admin" + Then I see administrator dashboard diff --git a/tests/acceptance/content.feature b/tests/acceptance/content.feature index 5705586984..8530da8eda 100644 --- a/tests/acceptance/content.feature +++ b/tests/acceptance/content.feature @@ -1,37 +1,44 @@ Feature: content In order to manage content article in the web As an owner - I need to create modify delete and un public content article + I need to create modify delete and Unpublish content article Background: Given There is an administrator link When Login into Joomla administrator with username "admin" and password "admin" Then I see administrator dashboard + Scenario: Create an Article + Given There is a Add Content link + When I add the content with title "My_Article" + And I add content body "This is my first article" + And I save an article + Then I should see the article "My_Article" in the joomla frontend + Scenario: Feature an Article - Given there is a content article with title "My first Joomla Article" - When I feature the content with title "My first Joomla Article" - Then I should see the published article "My first Joomla Article" in the joomla home page + Given there is a content article with title "My_Article" + When I feature the content with title "My_Article" + Then I should see the published article "My_Article" in the joomla home page - Scenario: Modify an article - Given I select the content article with title "My first Joomla Article" - And change the title "My Joomla Article" - When I try to post "My Joomla Article" - Then I should see the "Article successfully saved" - And published article "My Joomla Article" in the joomla home page + Scenario: Modify an article + Given I select the content article with title "My first Joomla Article" + And change the title "My Joomla Article" + When I try to post "My Joomla Article" + Then I should see the "Article successfully saved" + And published article "My Joomla Article" in the joomla home page Scenario: Unpublish an article - Given I have article with name "My Joomla Article" - When I un publish "My Joomla Article" - Then I can not see the article"My Joomla Article" in the joomla home page + Given I have article with name "My Joomla Article" + When I un publish "My Joomla Article" + Then I can not see the article "My Joomla Article" in the joomla home page Scenario: Remove an article - Given I have one content article which needs to be removed - When I delete the article with name "My Joomla Article" - Then I should not see in joomla site frontend + Given I have one content article which needs to be removed + When I delete the article with name "My Joomla Article" + Then I should not see in joomla site frontend Scenario: Registered user can not see or access article from site - Given I have article with title "My Joomla Article" - And set access to registered - When I do login with registered user "prital" and password "patel" - Then I should see the registered article in the joomla home page + Given I have article with title "My Joomla Article" + And set access to registered + When I do login with registered user "prital" and password "patel" + Then I should see the registered article in the joomla home page From 4644e29d4a9535f4256501aa4dd16d51d63918ee Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Tue, 17 May 2016 09:31:42 +0530 Subject: [PATCH 06/18] Update in content.feature to set correct Background --- tests/acceptance/content.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/acceptance/content.feature b/tests/acceptance/content.feature index 8530da8eda..ac6e382c17 100644 --- a/tests/acceptance/content.feature +++ b/tests/acceptance/content.feature @@ -4,7 +4,7 @@ Feature: content I need to create modify delete and Unpublish content article Background: - Given There is an administrator link + Given Joomla CMS is installed When Login into Joomla administrator with username "admin" and password "admin" Then I see administrator dashboard From 0bc9f11661ec0cae4a739c34a34ee3add747b500 Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Sat, 28 May 2016 16:33:27 +0530 Subject: [PATCH 07/18] Added acceptance suits for article backend --- tests/_support/AcceptanceTester.php | 361 +++++++++++++--------------- tests/acceptance/content.feature | 36 ++- 2 files changed, 183 insertions(+), 214 deletions(-) diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index e66f1741f6..f474857c97 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -12,42 +12,44 @@ * @method void am($role) * @method void lookForwardTo($achieveValue) * @method void comment($description) - * @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL) + * @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null) * * @SuppressWarnings(PHPMD) -*/ + */ class AcceptanceTester extends \Codeception\Actor { - use _generated\AcceptanceTesterActions; - - /** - * @Given Joomla CMS is installed - */ - public function joomlaCMSIsInstalled() - { - // throw new \Codeception\Exception\Incomplete("Step `Joomla CMS is installed` is not defined"); - } - - /** - * @When Login into Joomla administrator with username :arg1 and password :arg1 - */ - public function loginIntoJoomlaAdministratorWithUsernameAndPassword($username, $password) - { - $I = $this; - $I->amOnPage('administrator/'); - $I->fillField('Username', $username); - $I->fillField('passwd', $password); - $I->click('Log in'); - } - - /** - * @Then I see administrator dashboard - */ - public function iSeeAdministratorDashboard() - { - $I = $this; - $I->see('Control Panel', 'h1'); - } + use _generated\AcceptanceTesterActions; + + /** + * Install joomla CMS + * + * @Given Joomla CMS is installed + */ + public function joomlaCMSIsInstalled() + { + // throw new \Codeception\Exception\Incomplete("Step `Joomla CMS is installed` is not defined"); + } + + /** + * @When Login into Joomla administrator with username :arg1 and password :arg1 + */ + public function loginIntoJoomlaAdministratorWithUsernameAndPassword($username, $password) + { + $I = $this; + $I->amOnPage('administrator/'); + $I->fillField('Username', $username); + $I->fillField('passwd', $password); + $I->click('Log in'); + } + + /** + * @Then I see administrator dashboard + */ + public function iSeeAdministratorDashboard() + { + $I = $this; + $I->see('Control Panel', 'h1'); + } /** * @Given There is a Add Content link @@ -74,6 +76,7 @@ public function iAddTheContentWithTitle($title) public function iAddContentBody($body) { $I = $this; + $I->click('Toggle editor'); $I->fillField('#jform_articletext', $body); } @@ -87,166 +90,138 @@ public function iSaveAnArticle() } /** - * @Then I should see the article :arg1 in the joomla frontend - */ - public function iShouldSeeTheArticleInTheJoomlaFrontend($arg1) - { - $I = $this; - $I->amOnPage('/'); - // @todo - } - - - /** - * @Given there is a content article with title :arg1 - */ - public function thereIsAContentArticleWithTitle($My_Article) - { - $I = $this; - $I->wantTo('create article'); - $I->click('nav nav-hover'); - $I->click(''); - $I->click('Featured Articles'); - $I->fillField('Title', $My_Article); - $I->click('save'); - - - } - - /** - * @When I feature the content with title :arg1 - */ - public function iFeatureTheContentWithTitle($arg1) - { - throw new \Codeception\Exception\Incomplete("Step `I feature the content with title :arg1` is not defined"); - } - - /** - * @Then I should see the published article :arg1 in the joomla home page - */ - public function iShouldSeeThePublishedArticleInTheJoomlaHomePage($arg1) - { - throw new \Codeception\Exception\Incomplete("Step `I should see the published article :arg1 in the joomla home page` is not defined"); - } - - /** - * @Given I select the content article with title :arg1 - */ - public function iSelectTheContentArticleWithTitle($arg1) - { - throw new \Codeception\Exception\Incomplete("Step `I select the content article with title :arg1` is not defined"); - } - - /** - * @Given change the title :arg1 - */ - public function changeTheTitle($arg1) - { - throw new \Codeception\Exception\Incomplete("Step `change the title :arg1` is not defined"); - } - - /** - * @When I try to post :arg1 - */ - public function iTryToPost($arg1) - { - throw new \Codeception\Exception\Incomplete("Step `I try to post :arg1` is not defined"); - } - - /** - * @Then I should see the :arg1 - */ - public function iShouldSeeThe($arg1) - { - throw new \Codeception\Exception\Incomplete("Step `I should see the :arg1` is not defined"); - } - - /** - * @Then published article :arg1 in the joomla home page - */ - public function publishedArticleInTheJoomlaHomePage($arg1) - { - throw new \Codeception\Exception\Incomplete("Step `published article :arg1 in the joomla home page` is not defined"); - } - - /** - * @Given I have article with name :arg1 - */ - public function iHaveArticleWithName($arg1) - { - throw new \Codeception\Exception\Incomplete("Step `I have article with name :arg1` is not defined"); - } - - /** - * @When I un publish :arg1 - */ - public function iUnPublish($arg1) - { - throw new \Codeception\Exception\Incomplete("Step `I un publish :arg1` is not defined"); - } - - /** - * @Then I can not see the article :arg1 in the joomla home page - */ - public function iCanNotSeeTheArticleInTheJoomlaHomePage($arg1) - { - throw new \Codeception\Exception\Incomplete("Step `I can not see the article :arg1 in the joomla home page` is not defined"); - } - - /** - * @Given I have one content article which needs to be removed - */ - public function iHaveOneContentArticleWhichNeedsToBeRemoved() - { - throw new \Codeception\Exception\Incomplete("Step `I have one content article which needs to be removed` is not defined"); - } - - /** - * @When I delete the article with name :arg1 - */ - public function iDeleteTheArticleWithName($arg1) - { - throw new \Codeception\Exception\Incomplete("Step `I delete the article with name :arg1` is not defined"); - } - - /** - * @Then I should not see in joomla site frontend - */ - public function iShouldNotSeeInJoomlaSiteFrontend() - { - throw new \Codeception\Exception\Incomplete("Step `I should not see in joomla site frontend` is not defined"); - } - - /** - * @Given I have article with title :arg1 - */ - public function iHaveArticleWithTitle($arg1) - { - throw new \Codeception\Exception\Incomplete("Step `I have article with title :arg1` is not defined"); - } - - /** - * @Given set access to registered - */ - public function setAccessToRegistered() - { - throw new \Codeception\Exception\Incomplete("Step `set access to registered` is not defined"); - } - - /** - * @When I do login with registered user :arg1 and password :arg2 - */ - public function iDoLoginWithRegisteredUserAndPassword($arg1, $arg2) - { - throw new \Codeception\Exception\Incomplete("Step `I do login with registered user :arg1 and password :arg2` is not defined"); - } - - /** - * @Then I should see the registered article in the joomla home page - */ - public function iShouldSeeTheRegisteredArticleInTheJoomlaHomePage() - { - throw new \Codeception\Exception\Incomplete("Step `I should see the registered article in the joomla home page` is not defined"); - } + * @Then I should see the :arg1 message + */ + public function iShouldSeeTheMessage($arg1) + { + $I = $this; + $I->waitForText('Articles', 60, ['css' => '.page-title']); + $I->see('Article successfully saved.', ['id' => 'system-message-container']); + } + + /** + * @Given I search and select content article with title :arg1 + */ + public function iSearchAndSelectContentArticleWithTitle($title) + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_content&view=articles'); + $I->fillField('#filter_search', $title); + $I->click('.icon-search'); + $I->checkAllResults(); + } + + /** + * @When I feature the content with title :arg1 + */ + public function iFeatureTheContentWithTitle($title) + { + $I = $this; + $I->click(['xpath' => "//div[@id='toolbar-featured']/button"]); + } + + /** + * @Then I save and see the :arg1 message + */ + public function iSaveAndSeeTheMessage($arg1) + { + $I = $this; + $I->waitForText('Articles', 60, ['css' => '.page-title']); + $I->see('1 article featured.', ['id' => 'system-message-container']); + } + + /** + * @Given I select the content article with title :arg1 + */ + public function iSelectTheContentArticleWithTitle($title) + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_content&view=articles'); + $I->fillField('#filter_search', $title); + $I->click('.icon-search'); + $I->checkAllResults(); + $I->click(['xpath' => "//div[@id='toolbar-edit']/button"]); + } + + /** + * @Given I set access level as a register + */ + public function iSetAccessLevelAsARegister() + { + $I = $this; + $I->selectOptionInChosenById('jform_access', 'Registered'); + + } + + /** + * @When I save the article :arg1 + */ + public function iSaveTheArticle($arg1) + { + $I = $this; + $I->clickToolbarButton('Save & Close'); + } + + /** + * @Given I have article with name :arg1 + */ + public function iHaveArticleWithName($title) + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_content&view=articles'); + $I->fillField('#filter_search', $title); + $I->click('.icon-search'); + $I->checkAllResults(); + } + + /** + * @When I unpublish :arg1 + */ + public function iUnpublish($title) + { + $I = $this; + $I->click(['xpath' => "//div[@id='toolbar-unpublish']/button"]); + + } + /** + * @Then I see article unpublish message :arg1 + */ + public function iSeeArticleUnpublishMessage($arg1) + { + $I = $this; + $I->waitForText('Articles', 60, ['css' => '.page-title']); + $I->see('1 article unpublished.', ['id' => 'system-message-container']); + } + + + /** + * @Given I have :arg1 content article which needs to be Trash + */ + public function iHaveContentArticleWhichNeedsToBeTrash($title) + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_content&view=articles'); + $I->fillField('#filter_search', $title); + $I->click('.icon-search'); + $I->checkAllResults(); + } + + /** + * @When I Trash the article with name :arg1 + */ + public function iTrashTheArticleWithName($title) + { + $I = $this; + $I->click(['xpath' => "//div[@id='toolbar-trash']/button"]); + } + /** + * @Then I see article trash message :arg1 + */ + public function iSeeArticleTrashMessage($arg1) + { + $I = $this; + $I->waitForText('Articles', 60, ['css' => '.page-title']); + $I->see('1 article trashed.', ['id' => 'system-message-container']); + } } diff --git a/tests/acceptance/content.feature b/tests/acceptance/content.feature index ac6e382c17..3424b3d22f 100644 --- a/tests/acceptance/content.feature +++ b/tests/acceptance/content.feature @@ -1,7 +1,7 @@ Feature: content In order to manage content article in the web As an owner - I need to create modify delete and Unpublish content article + I need to create modify trash publish and Unpublish content article Background: Given Joomla CMS is installed @@ -13,32 +13,26 @@ Feature: content When I add the content with title "My_Article" And I add content body "This is my first article" And I save an article - Then I should see the article "My_Article" in the joomla frontend + Then I should see the "Article successfully saved." message Scenario: Feature an Article - Given there is a content article with title "My_Article" + Given I search and select content article with title "My_Article" When I feature the content with title "My_Article" - Then I should see the published article "My_Article" in the joomla home page + Then I save and see the "1 article featured." message Scenario: Modify an article - Given I select the content article with title "My first Joomla Article" - And change the title "My Joomla Article" - When I try to post "My Joomla Article" - Then I should see the "Article successfully saved" - And published article "My Joomla Article" in the joomla home page + Given I select the content article with title "My_Article" + And I set access level as a register + When I save the article "My_Article" + Then I should see the "Article successfully saved" message Scenario: Unpublish an article - Given I have article with name "My Joomla Article" - When I un publish "My Joomla Article" - Then I can not see the article "My Joomla Article" in the joomla home page + Given I have article with name "My_Article" + When I unpublish "My_Article" + Then I see article unpublish message "1 article unpublished." - Scenario: Remove an article - Given I have one content article which needs to be removed - When I delete the article with name "My Joomla Article" - Then I should not see in joomla site frontend + Scenario: Trash an article + Given I have "My_Article" content article which needs to be Trash + When I Trash the article with name "My_Article" + Then I see article trash message "1 article trashed." - Scenario: Registered user can not see or access article from site - Given I have article with title "My Joomla Article" - And set access to registered - When I do login with registered user "prital" and password "patel" - Then I should see the registered article in the joomla home page From ca40bee744ac6ef27c2c469da4776e3bff94b49a Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Mon, 30 May 2016 22:39:53 +0530 Subject: [PATCH 08/18] Adding users.feature scenarios and suits --- RoboFile.php | 9 ++ tests/_support/AcceptanceTester.php | 217 ++++++++++++++++++++++++++-- tests/acceptance/users.feature | 47 ++++++ 3 files changed, 260 insertions(+), 13 deletions(-) create mode 100644 tests/acceptance/users.feature diff --git a/RoboFile.php b/RoboFile.php index 8a610da4ee..5f227fc1f5 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -291,6 +291,15 @@ public function runTests($opts = ['use-htaccess' => false, 'env' => 'desktop']) ->run() ->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') diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index f474857c97..5e2ea29aab 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -33,13 +33,10 @@ public function joomlaCMSIsInstalled() /** * @When Login into Joomla administrator with username :arg1 and password :arg1 */ - public function loginIntoJoomlaAdministratorWithUsernameAndPassword($username, $password) + public function loginIntoJoomlaAdministrator($username, $password) { $I = $this; - $I->amOnPage('administrator/'); - $I->fillField('Username', $username); - $I->fillField('passwd', $password); - $I->click('Log in'); + $I->doAdministratorLogin($username, $password); } /** @@ -48,7 +45,7 @@ public function loginIntoJoomlaAdministratorWithUsernameAndPassword($username, $ public function iSeeAdministratorDashboard() { $I = $this; - $I->see('Control Panel', 'h1'); + $I->waitForPageTitle('Control Panel', 4); } /** @@ -95,7 +92,7 @@ public function iSaveAnArticle() public function iShouldSeeTheMessage($arg1) { $I = $this; - $I->waitForText('Articles', 60, ['css' => '.page-title']); + $I->waitForPageTitle('Articles'); $I->see('Article successfully saved.', ['id' => 'system-message-container']); } @@ -117,7 +114,7 @@ public function iSearchAndSelectContentArticleWithTitle($title) public function iFeatureTheContentWithTitle($title) { $I = $this; - $I->click(['xpath' => "//div[@id='toolbar-featured']/button"]); + $I->clickToolbarButton('featured'); } /** @@ -126,7 +123,7 @@ public function iFeatureTheContentWithTitle($title) public function iSaveAndSeeTheMessage($arg1) { $I = $this; - $I->waitForText('Articles', 60, ['css' => '.page-title']); + $I->waitForPageTitle('Articles'); $I->see('1 article featured.', ['id' => 'system-message-container']); } @@ -180,7 +177,7 @@ public function iHaveArticleWithName($title) public function iUnpublish($title) { $I = $this; - $I->click(['xpath' => "//div[@id='toolbar-unpublish']/button"]); + $I->clickToolbarButton('unpublish'); } /** @@ -189,7 +186,7 @@ public function iUnpublish($title) public function iSeeArticleUnpublishMessage($arg1) { $I = $this; - $I->waitForText('Articles', 60, ['css' => '.page-title']); + $I->waitForPageTitle('Articles'); $I->see('1 article unpublished.', ['id' => 'system-message-container']); } @@ -212,7 +209,7 @@ public function iHaveContentArticleWhichNeedsToBeTrash($title) public function iTrashTheArticleWithName($title) { $I = $this; - $I->click(['xpath' => "//div[@id='toolbar-trash']/button"]); + $I->clickToolbarButton('trash'); } /** * @Then I see article trash message :arg1 @@ -220,8 +217,202 @@ public function iTrashTheArticleWithName($title) public function iSeeArticleTrashMessage($arg1) { $I = $this; - $I->waitForText('Articles', 60, ['css' => '.page-title']); + $I->waitForPageTitle('Articles'); $I->see('1 article trashed.', ['id' => 'system-message-container']); } + /** + * @Given There is a add user link + */ + public function thereIsAAddUserLink() + { + $I =$this; + $I->amOnPage('administrator/index.php?option=com_users&view=users'); + $I->clickToolbarButton('New'); + } + + /** + * @When I enter the Name :arg1 + */ + public function iEnterTheName($name) + { + $I =$this; + $I->fillField('#jform_name', $name); + } + + /** + * @When I enter the Login Name :arg1 + */ + public function iEnterTheLoginName($username) + { + $I = $this; + $I->fillField('#jform_username', $username); + } + + /** + * @When I enter the Password :arg1 + */ + public function iEnterThePassword($password) + { + $I = $this; + $I->fillField('#jform_password', $password); + } + + /** + * @When I enter the Confirm Password :arg1 + */ + public function iEnterTheConfirmPassword($Confirm_Password) + { + $I = $this; + $I->fillField('#jform_password2', $Confirm_Password); + } + + /** + * @When I enter the Email :arg1 + */ + public function iEnterTheEmail($email) + { + $I = $this; + $I->fillField('#jform_email', $email); + } + + /** + * @Then I Save the user + */ + public function iSaveTheUser() + { + $I = $this; + $I->clickToolbarButton('Save & Close'); + } + + /** + * @Then I see the :arg1 message + */ + public function iSeeTheMessage($arg1) + { + $I = $this; + $I->waitForPageTitle('Users'); + $I->see('User successfully saved.', ['id' => 'system-message-container']); + } + + /** + * @Given I search and select the user with user name :arg1 + */ + public function iSearchAndSelectTheUserWithUserName($username) + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_users&view=users'); + $I->fillField('#filter_search', $username); + $I->click('.icon-search'); + $I->checkAllResults(); + $I->clickToolbarButton('edit'); + } + + /** + * @When I set name as an :arg1 and User Group as :arg1 + */ + public function iAssignedNameAndUserGroup($name, $username) + { + $I = $this; + $I->fillField('#jform_name',$name); + $I->click('Assigned User Groups'); + $I->checkOption('#1group_4'); + } + /** + * @Then I should display the :arg1 message + */ + public function iShouldDisplayTheMessage($arg1) + { + $I = $this; + $I->clickToolbarButton('Save & Close'); + $I->waitForPageTitle('Users'); + $I->see('User successfully saved.', ['id' => 'system-message-container']); + } + + /** + * @Given I have a user with user name :arg1 + */ + public function iHaveAUserWithUserName($username) + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_users&view=users'); + $I->fillField('#filter_search', $username); + $I->click('.icon-search'); + $I->checkAllResults(); + } + + /** + * @When I block user name :arg1 + */ + public function iBlockUserName($arg1) + { + $I = $this; + $I->clickToolbarButton('unpublish'); + } + + /** + * @Then I should see the user block message :arg1 + */ + public function iShouldSeeTheUserBlockMessage($arg1) + { + $I = $this; + $I->waitForPageTitle('Users'); + $I->see('User blocked.', ['id' => 'system-message-container']); + } + + /** + * @Given I have a blocked user with user name :arg1 + */ + public function iHaveABlockedUserWithUserName($username) + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_users&view=users'); + $I->fillField('#filter_search', $username); + $I->click('.icon-search'); + $I->checkAllResults(); + } + + /** + * @When I unblock the user :arg1 + */ + public function iUnblockTheUser($arg1) + { + $I = $this; + $I->waitForPageTitle('Users'); + $I->clickToolbarButton('unblock'); + } + + /** + * @Then I should see the user unblock message :arg1 + */ + public function iShouldSeeTheUserUnblockMessage($arg1) + { + $I = $this; + $I->waitForPageTitle('Users'); + $I->see('User enabled.', ['css' => '.alert-message']); + } + /** + * @When I Delete the user :arg1 + */ + public function iDeleteTheUser($username) + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_users&view=users'); + $I->fillField('#filter_search', $username); + $I->click('.icon-search'); + $I->checkAllResults(); + $I->clickToolbarButton('empty trash'); + $I->acceptPopup(); + } + + /** + * @Then I conform the user :arg1 delete sucessfully + */ + public function iConformTheUserDeleteSucessfully($arg1) + { + $I = $this; + $I->checkForPhpNoticesOrWarnings(); + $I->expectTo('see a success message and the user is deleted'); + $I->see('User successfully deleted', ['id' => 'system-message-container']); + } } diff --git a/tests/acceptance/users.feature b/tests/acceptance/users.feature new file mode 100644 index 0000000000..409902a5ce --- /dev/null +++ b/tests/acceptance/users.feature @@ -0,0 +1,47 @@ +Feature: users + In order to manage users in the web + As an owner + I need to create edit block unblock and delete user + + Background: + Given Joomla CMS is installed + When Login into Joomla administrator with username "admin" and password "admin" + Then I see administrator dashboard + + Scenario: create a user + Given There is a add user link + When I enter the Name "register" + And I enter the Login Name "register" + And I enter the Password "register" + And I enter the Confirm Password "register" + And I enter the Email "bladhapiyu@gmail.com" + Then I Save the user + And I see the "User successfully saved" message + + Scenario: Edit user + Given I search and select the user with user name "register" + When I set name as an "Editor" and User Group as "Editor" + Then I Save the user + And I see the "User successfully saved" message + + Scenario: Block a User + Given I have a user with user name "register" + When I block user name "register" + Then I should see the user block message "User blocked" + + Scenario: Unblock user + Given I have a blocked user with user name "register" + When I unblock the user "register" + Then I should see the user unblock message "User enable" + + Scenario: Delete user + Given I have a user with user name "Editor" + When I Delete the user "Editor" + Then I conform the user "Editor" delete sucessfully + + + + + + + From d9a2dbb88cf7851a79a740bf11e3e2a7b0a511a0 Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Tue, 31 May 2016 17:20:42 +0530 Subject: [PATCH 09/18] switch all to strict locators --- tests/_support/AcceptanceTester.php | 48 ++++++++++++++--------------- tests/acceptance/content.feature | 2 +- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 5e2ea29aab..64030e2fcd 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -64,7 +64,7 @@ public function thereIsAAddContentLink() public function iAddTheContentWithTitle($title) { $I = $this; - $I->fillField('#jform_title', $title); + $I->fillField(['id' => 'jform_title'], $title); } /** @@ -74,7 +74,7 @@ public function iAddContentBody($body) { $I = $this; $I->click('Toggle editor'); - $I->fillField('#jform_articletext', $body); + $I->fillField(['id' => 'jform_articletext'], $body); } /** @@ -103,7 +103,7 @@ public function iSearchAndSelectContentArticleWithTitle($title) { $I = $this; $I->amOnPage('administrator/index.php?option=com_content&view=articles'); - $I->fillField('#filter_search', $title); + $I->fillField(['id' => 'filter_search'], $title); $I->click('.icon-search'); $I->checkAllResults(); } @@ -134,20 +134,19 @@ public function iSelectTheContentArticleWithTitle($title) { $I = $this; $I->amOnPage('administrator/index.php?option=com_content&view=articles'); - $I->fillField('#filter_search', $title); + $I->fillField(['id' => 'filter_search'], $title); $I->click('.icon-search'); $I->checkAllResults(); $I->click(['xpath' => "//div[@id='toolbar-edit']/button"]); } /** - * @Given I set access level as a register + * @Given I set access level as a :arg1 */ - public function iSetAccessLevelAsARegister() + public function iSetAccessLevelAsA($accessLevel) { $I = $this; - $I->selectOptionInChosenById('jform_access', 'Registered'); - + $I->selectOptionInChosenById(['id' => 'jform_access'], $accessLevel); } /** @@ -166,7 +165,7 @@ public function iHaveArticleWithName($title) { $I = $this; $I->amOnPage('administrator/index.php?option=com_content&view=articles'); - $I->fillField('#filter_search', $title); + $I->fillField(['id' => 'filter_search'], $title); $I->click('.icon-search'); $I->checkAllResults(); } @@ -178,7 +177,6 @@ public function iUnpublish($title) { $I = $this; $I->clickToolbarButton('unpublish'); - } /** * @Then I see article unpublish message :arg1 @@ -198,7 +196,7 @@ public function iHaveContentArticleWhichNeedsToBeTrash($title) { $I = $this; $I->amOnPage('administrator/index.php?option=com_content&view=articles'); - $I->fillField('#filter_search', $title); + $I->fillField(['id' => 'filter_search'], $title); $I->click('.icon-search'); $I->checkAllResults(); } @@ -211,6 +209,7 @@ public function iTrashTheArticleWithName($title) $I = $this; $I->clickToolbarButton('trash'); } + /** * @Then I see article trash message :arg1 */ @@ -220,12 +219,13 @@ public function iSeeArticleTrashMessage($arg1) $I->waitForPageTitle('Articles'); $I->see('1 article trashed.', ['id' => 'system-message-container']); } + /** * @Given There is a add user link */ public function thereIsAAddUserLink() { - $I =$this; + $I = $this; $I->amOnPage('administrator/index.php?option=com_users&view=users'); $I->clickToolbarButton('New'); } @@ -236,7 +236,7 @@ public function thereIsAAddUserLink() public function iEnterTheName($name) { $I =$this; - $I->fillField('#jform_name', $name); + $I->fillField(['id' => 'jform_name'], $name); } /** @@ -245,7 +245,7 @@ public function iEnterTheName($name) public function iEnterTheLoginName($username) { $I = $this; - $I->fillField('#jform_username', $username); + $I->fillField(['id' => 'jform_username'], $username); } /** @@ -254,7 +254,7 @@ public function iEnterTheLoginName($username) public function iEnterThePassword($password) { $I = $this; - $I->fillField('#jform_password', $password); + $I->fillField(['id' => 'jform_password'], $password); } /** @@ -263,7 +263,7 @@ public function iEnterThePassword($password) public function iEnterTheConfirmPassword($Confirm_Password) { $I = $this; - $I->fillField('#jform_password2', $Confirm_Password); + $I->fillField(['id' => 'jform_password2'], $Confirm_Password); } /** @@ -272,7 +272,7 @@ public function iEnterTheConfirmPassword($Confirm_Password) public function iEnterTheEmail($email) { $I = $this; - $I->fillField('#jform_email', $email); + $I->fillField(['id' => 'jform_email'], $email); } /** @@ -301,7 +301,7 @@ public function iSearchAndSelectTheUserWithUserName($username) { $I = $this; $I->amOnPage('administrator/index.php?option=com_users&view=users'); - $I->fillField('#filter_search', $username); + $I->fillField(['id' => 'filter_search'], $username); $I->click('.icon-search'); $I->checkAllResults(); $I->clickToolbarButton('edit'); @@ -313,9 +313,9 @@ public function iSearchAndSelectTheUserWithUserName($username) public function iAssignedNameAndUserGroup($name, $username) { $I = $this; - $I->fillField('#jform_name',$name); + $I->fillField(['id' => 'jform_name'], $name); $I->click('Assigned User Groups'); - $I->checkOption('#1group_4'); + $I->checkOption('1group_4'); } /** * @Then I should display the :arg1 message @@ -335,7 +335,7 @@ public function iHaveAUserWithUserName($username) { $I = $this; $I->amOnPage('administrator/index.php?option=com_users&view=users'); - $I->fillField('#filter_search', $username); + $I->fillField(['id' => 'filter_search'], $username); $I->click('.icon-search'); $I->checkAllResults(); } @@ -366,7 +366,7 @@ public function iHaveABlockedUserWithUserName($username) { $I = $this; $I->amOnPage('administrator/index.php?option=com_users&view=users'); - $I->fillField('#filter_search', $username); + $I->fillField(['id' => 'filter_search'], $username); $I->click('.icon-search'); $I->checkAllResults(); } @@ -388,7 +388,7 @@ public function iShouldSeeTheUserUnblockMessage($arg1) { $I = $this; $I->waitForPageTitle('Users'); - $I->see('User enabled.', ['css' => '.alert-message']); + $I->see('User enabled.', ['class' => '.alert-message']); } /** @@ -398,7 +398,7 @@ public function iDeleteTheUser($username) { $I = $this; $I->amOnPage('administrator/index.php?option=com_users&view=users'); - $I->fillField('#filter_search', $username); + $I->fillField(['id' => 'filter_search'], $username); $I->click('.icon-search'); $I->checkAllResults(); $I->clickToolbarButton('empty trash'); diff --git a/tests/acceptance/content.feature b/tests/acceptance/content.feature index 3424b3d22f..92765cf2a9 100644 --- a/tests/acceptance/content.feature +++ b/tests/acceptance/content.feature @@ -22,7 +22,7 @@ Feature: content Scenario: Modify an article Given I select the content article with title "My_Article" - And I set access level as a register + And I set access level as a "register" When I save the article "My_Article" Then I should see the "Article successfully saved" message From 219adc49a2d1993cebf9c30cc42ada5dbe42e612 Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Tue, 7 Jun 2016 23:04:30 +0530 Subject: [PATCH 10/18] Improve coding style --- tests/_support/AcceptanceTester.php | 16 ++++++++-------- tests/acceptance/content.feature | 2 +- tests/acceptance/users.feature | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 64030e2fcd..77b6c40d93 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -146,7 +146,7 @@ public function iSelectTheContentArticleWithTitle($title) public function iSetAccessLevelAsA($accessLevel) { $I = $this; - $I->selectOptionInChosenById(['id' => 'jform_access'], $accessLevel); + $I->selectOptionInChosenById('jform_access', $accessLevel); } /** @@ -315,7 +315,7 @@ public function iAssignedNameAndUserGroup($name, $username) $I = $this; $I->fillField(['id' => 'jform_name'], $name); $I->click('Assigned User Groups'); - $I->checkOption('1group_4'); + $I->checkOption('#1group_4'); } /** * @Then I should display the :arg1 message @@ -378,17 +378,17 @@ public function iUnblockTheUser($arg1) { $I = $this; $I->waitForPageTitle('Users'); - $I->clickToolbarButton('unblock'); + $I->clickToolbarButton('Unblock'); } /** * @Then I should see the user unblock message :arg1 */ - public function iShouldSeeTheUserUnblockMessage($arg1) + public function iShouldSeeTheUserUnblockMessage($message) { $I = $this; $I->waitForPageTitle('Users'); - $I->see('User enabled.', ['class' => '.alert-message']); + $I->see($message, ['id' => 'system-message-container']); } /** @@ -406,13 +406,13 @@ public function iDeleteTheUser($username) } /** - * @Then I conform the user :arg1 delete sucessfully + * @Then I conform the user delete sucessfully by getting message :arg1 */ - public function iConformTheUserDeleteSucessfully($arg1) + public function iConformTheUserDeleteSucessfully($message) { $I = $this; $I->checkForPhpNoticesOrWarnings(); $I->expectTo('see a success message and the user is deleted'); - $I->see('User successfully deleted', ['id' => 'system-message-container']); + $I->see($message, ['class' => 'alert-message']); } } diff --git a/tests/acceptance/content.feature b/tests/acceptance/content.feature index 92765cf2a9..e31ac2c6fe 100644 --- a/tests/acceptance/content.feature +++ b/tests/acceptance/content.feature @@ -22,7 +22,7 @@ Feature: content Scenario: Modify an article Given I select the content article with title "My_Article" - And I set access level as a "register" + And I set access level as a "Registered" When I save the article "My_Article" Then I should see the "Article successfully saved" message diff --git a/tests/acceptance/users.feature b/tests/acceptance/users.feature index 409902a5ce..12f0e0a49f 100644 --- a/tests/acceptance/users.feature +++ b/tests/acceptance/users.feature @@ -32,12 +32,12 @@ Feature: users Scenario: Unblock user Given I have a blocked user with user name "register" When I unblock the user "register" - Then I should see the user unblock message "User enable" + Then I should see the user unblock message "User enabled." Scenario: Delete user Given I have a user with user name "Editor" When I Delete the user "Editor" - Then I conform the user "Editor" delete sucessfully + Then I conform the user delete sucessfully by getting message "1 user successfully deleted." From 285802de4d50df8165ecb271d3213a0425d5fc2a Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Tue, 7 Jun 2016 23:23:32 +0530 Subject: [PATCH 11/18] Move new joomla browser functions here --- tests/_support/AcceptanceTester.php | 26 ++++++++++++++++++++------ tests/acceptance/content.feature | 2 +- tests/acceptance/users.feature | 2 +- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 77b6c40d93..02c1b15442 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -109,12 +109,12 @@ public function iSearchAndSelectContentArticleWithTitle($title) } /** - * @When I feature the content with title :arg1 + * @When I featured the article */ - public function iFeatureTheContentWithTitle($title) + public function iFeatureTheContentWithTitle() { $I = $this; - $I->clickToolbarButton('featured'); + $I->click(['xpath' => "//div[@id='toolbar-featured']//button"]); } /** @@ -372,13 +372,13 @@ public function iHaveABlockedUserWithUserName($username) } /** - * @When I unblock the user :arg1 + * @When I unblock the user */ - public function iUnblockTheUser($arg1) + public function iUnblockTheUser() { $I = $this; $I->waitForPageTitle('Users'); - $I->clickToolbarButton('Unblock'); + $I->click(['xpath' => "//div[@id='toolbar-unblock']//button"]); } /** @@ -415,4 +415,18 @@ public function iConformTheUserDeleteSucessfully($message) $I->expectTo('see a success message and the user is deleted'); $I->see($message, ['class' => 'alert-message']); } + + /** + * Method is to set Wait for page title + * + * @param string $title Page Title text + * @param integer $waiting Waiting time + * + * @return void + */ + public function waitForPageTitle($title, $timeout = 60) + { + $I = $this; + $I->waitForText($title, $timeout, ['class' => 'page-title']); + } } diff --git a/tests/acceptance/content.feature b/tests/acceptance/content.feature index e31ac2c6fe..49eaaf3724 100644 --- a/tests/acceptance/content.feature +++ b/tests/acceptance/content.feature @@ -17,7 +17,7 @@ Feature: content Scenario: Feature an Article Given I search and select content article with title "My_Article" - When I feature the content with title "My_Article" + When I featured the article Then I save and see the "1 article featured." message Scenario: Modify an article diff --git a/tests/acceptance/users.feature b/tests/acceptance/users.feature index 12f0e0a49f..77ea4a9c38 100644 --- a/tests/acceptance/users.feature +++ b/tests/acceptance/users.feature @@ -31,7 +31,7 @@ Feature: users Scenario: Unblock user Given I have a blocked user with user name "register" - When I unblock the user "register" + When I unblock the user Then I should see the user unblock message "User enabled." Scenario: Delete user From 8696495b6b160ac8d4f276b9308dc5b1d67db081 Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Wed, 8 Jun 2016 00:00:08 +0530 Subject: [PATCH 12/18] Fixed Unused parameters --- tests/_support/AcceptanceTester.php | 48 +++++++++++++++-------------- tests/acceptance/content.feature | 6 ++-- tests/acceptance/users.feature | 8 ++--- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 02c1b15442..198284ec73 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -89,11 +89,11 @@ public function iSaveAnArticle() /** * @Then I should see the :arg1 message */ - public function iShouldSeeTheMessage($arg1) + public function iShouldSeeTheMessage($mesage) { $I = $this; $I->waitForPageTitle('Articles'); - $I->see('Article successfully saved.', ['id' => 'system-message-container']); + $I->see($mesage, ['id' => 'system-message-container']); } /** @@ -120,11 +120,11 @@ public function iFeatureTheContentWithTitle() /** * @Then I save and see the :arg1 message */ - public function iSaveAndSeeTheMessage($arg1) + public function iSaveAndSeeTheMessage($message) { $I = $this; $I->waitForPageTitle('Articles'); - $I->see('1 article featured.', ['id' => 'system-message-container']); + $I->see($message, ['id' => 'system-message-container']); } /** @@ -150,9 +150,9 @@ public function iSetAccessLevelAsA($accessLevel) } /** - * @When I save the article :arg1 + * @When I save the article */ - public function iSaveTheArticle($arg1) + public function iSaveTheArticle() { $I = $this; $I->clickToolbarButton('Save & Close'); @@ -171,9 +171,9 @@ public function iHaveArticleWithName($title) } /** - * @When I unpublish :arg1 + * @When I unpublish the article */ - public function iUnpublish($title) + public function iUnpublish() { $I = $this; $I->clickToolbarButton('unpublish'); @@ -181,11 +181,11 @@ public function iUnpublish($title) /** * @Then I see article unpublish message :arg1 */ - public function iSeeArticleUnpublishMessage($arg1) + public function iSeeArticleUnpublishMessage($message) { $I = $this; $I->waitForPageTitle('Articles'); - $I->see('1 article unpublished.', ['id' => 'system-message-container']); + $I->see($message, ['id' => 'system-message-container']); } @@ -202,9 +202,9 @@ public function iHaveContentArticleWhichNeedsToBeTrash($title) } /** - * @When I Trash the article with name :arg1 + * @When I Trash the article */ - public function iTrashTheArticleWithName($title) + public function iTrashTheArticleWithName() { $I = $this; $I->clickToolbarButton('trash'); @@ -213,11 +213,11 @@ public function iTrashTheArticleWithName($title) /** * @Then I see article trash message :arg1 */ - public function iSeeArticleTrashMessage($arg1) + public function iSeeArticleTrashMessage($message) { $I = $this; $I->waitForPageTitle('Articles'); - $I->see('1 article trashed.', ['id' => 'system-message-container']); + $I->see($message, ['id' => 'system-message-container']); } /** @@ -287,11 +287,11 @@ public function iSaveTheUser() /** * @Then I see the :arg1 message */ - public function iSeeTheMessage($arg1) + public function iSeeTheMessage($message) { $I = $this; $I->waitForPageTitle('Users'); - $I->see('User successfully saved.', ['id' => 'system-message-container']); + $I->see($message, ['id' => 'system-message-container']); } /** @@ -310,22 +310,24 @@ public function iSearchAndSelectTheUserWithUserName($username) /** * @When I set name as an :arg1 and User Group as :arg1 */ - public function iAssignedNameAndUserGroup($name, $username) + public function iAssignedNameAndUserGroup($name, $userGroup) { $I = $this; $I->fillField(['id' => 'jform_name'], $name); $I->click('Assigned User Groups'); + + // @todo use $userGroup variable to select user group dynamically $I->checkOption('#1group_4'); } /** * @Then I should display the :arg1 message */ - public function iShouldDisplayTheMessage($arg1) + public function iShouldDisplayTheMessage($message) { $I = $this; $I->clickToolbarButton('Save & Close'); $I->waitForPageTitle('Users'); - $I->see('User successfully saved.', ['id' => 'system-message-container']); + $I->see($message, ['id' => 'system-message-container']); } /** @@ -341,9 +343,9 @@ public function iHaveAUserWithUserName($username) } /** - * @When I block user name :arg1 + * @When I block the user */ - public function iBlockUserName($arg1) + public function iBlockTheUser() { $I = $this; $I->clickToolbarButton('unpublish'); @@ -352,11 +354,11 @@ public function iBlockUserName($arg1) /** * @Then I should see the user block message :arg1 */ - public function iShouldSeeTheUserBlockMessage($arg1) + public function iShouldSeeTheUserBlockMessage($message) { $I = $this; $I->waitForPageTitle('Users'); - $I->see('User blocked.', ['id' => 'system-message-container']); + $I->see($message, ['id' => 'system-message-container']); } /** diff --git a/tests/acceptance/content.feature b/tests/acceptance/content.feature index 49eaaf3724..249eea739d 100644 --- a/tests/acceptance/content.feature +++ b/tests/acceptance/content.feature @@ -23,16 +23,16 @@ Feature: content Scenario: Modify an article Given I select the content article with title "My_Article" And I set access level as a "Registered" - When I save the article "My_Article" + When I save the article Then I should see the "Article successfully saved" message Scenario: Unpublish an article Given I have article with name "My_Article" - When I unpublish "My_Article" + When I unpublish the article Then I see article unpublish message "1 article unpublished." Scenario: Trash an article Given I have "My_Article" content article which needs to be Trash - When I Trash the article with name "My_Article" + When I Trash the article Then I see article trash message "1 article trashed." diff --git a/tests/acceptance/users.feature b/tests/acceptance/users.feature index 77ea4a9c38..f98082bf1f 100644 --- a/tests/acceptance/users.feature +++ b/tests/acceptance/users.feature @@ -16,18 +16,18 @@ Feature: users And I enter the Confirm Password "register" And I enter the Email "bladhapiyu@gmail.com" Then I Save the user - And I see the "User successfully saved" message + And I see the "User successfully saved." message Scenario: Edit user Given I search and select the user with user name "register" When I set name as an "Editor" and User Group as "Editor" Then I Save the user - And I see the "User successfully saved" message + And I see the "User successfully saved." message Scenario: Block a User Given I have a user with user name "register" - When I block user name "register" - Then I should see the user block message "User blocked" + When I block the user + Then I should see the user block message "User blocked." Scenario: Unblock user Given I have a blocked user with user name "register" From 4adc554971b5be8d2d074cdd3a7ddf608acd2d1c Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Wed, 8 Jun 2016 12:20:34 +0530 Subject: [PATCH 13/18] correct the varible name --- tests/_support/AcceptanceTester.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 198284ec73..1d903a57c8 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -89,11 +89,11 @@ public function iSaveAnArticle() /** * @Then I should see the :arg1 message */ - public function iShouldSeeTheMessage($mesage) + public function iShouldSeeTheMessage($message) { $I = $this; $I->waitForPageTitle('Articles'); - $I->see($mesage, ['id' => 'system-message-container']); + $I->see($message, ['id' => 'system-message-container']); } /** @@ -422,7 +422,7 @@ public function iConformTheUserDeleteSucessfully($message) * Method is to set Wait for page title * * @param string $title Page Title text - * @param integer $waiting Waiting time + * @param integer $timeout timeout time * * @return void */ From de373a205f44cb951c683bcc8265e48eafa40508 Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Wed, 8 Jun 2016 13:56:13 +0530 Subject: [PATCH 14/18] Typo checking --- tests/acceptance/users.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/acceptance/users.feature b/tests/acceptance/users.feature index f98082bf1f..74271be6b4 100644 --- a/tests/acceptance/users.feature +++ b/tests/acceptance/users.feature @@ -37,7 +37,7 @@ Feature: users Scenario: Delete user Given I have a user with user name "Editor" When I Delete the user "Editor" - Then I conform the user delete sucessfully by getting message "1 user successfully deleted." + Then I confirm the user should have been deleted by getting the message "1 user successfully deleted." From 51059f65d6473fd4741a9ffb2bae6e4414379bad Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Thu, 9 Jun 2016 08:27:08 +0530 Subject: [PATCH 15/18] corrected spelling and grammer mistake --- tests/_support/AcceptanceTester.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 1d903a57c8..3ddebcc416 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -408,9 +408,9 @@ public function iDeleteTheUser($username) } /** - * @Then I conform the user delete sucessfully by getting message :arg1 + * @Then I confirm the user should have been deleted by getting the message :arg1 */ - public function iConformTheUserDeleteSucessfully($message) + public function iConfirmTheUserDeleteSucessfully($message) { $I = $this; $I->checkForPhpNoticesOrWarnings(); From 368e052c1ee6f0d5cdb9a0fa599ae123d38925aa Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Thu, 9 Jun 2016 23:09:18 +0530 Subject: [PATCH 16/18] Moving acceptance tester into steps and pages --- tests/_support/AcceptanceTester.php | 398 ------------------ .../Page/Acceptance/Administrator/Login.php | 39 +- .../Step/Acceptance/Administrator/Content.php | 177 ++++++++ .../Step/Acceptance/Administrator/User.php | 192 ++++++++- 4 files changed, 392 insertions(+), 414 deletions(-) create mode 100644 tests/_support/Step/Acceptance/Administrator/Content.php diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 3ddebcc416..07e95519d7 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -20,404 +20,6 @@ class AcceptanceTester extends \Codeception\Actor { use _generated\AcceptanceTesterActions; - /** - * Install joomla CMS - * - * @Given Joomla CMS is installed - */ - public function joomlaCMSIsInstalled() - { - // throw new \Codeception\Exception\Incomplete("Step `Joomla CMS is installed` is not defined"); - } - - /** - * @When Login into Joomla administrator with username :arg1 and password :arg1 - */ - public function loginIntoJoomlaAdministrator($username, $password) - { - $I = $this; - $I->doAdministratorLogin($username, $password); - } - - /** - * @Then I see administrator dashboard - */ - public function iSeeAdministratorDashboard() - { - $I = $this; - $I->waitForPageTitle('Control Panel', 4); - } - - /** - * @Given There is a Add Content link - */ - public function thereIsAAddContentLink() - { - $I = $this; - $I->amOnPage('administrator/index.php?option=com_content&view=articles'); - $I->clickToolbarButton('New'); - } - - /** - * @When I add the content with title :arg1 - */ - public function iAddTheContentWithTitle($title) - { - $I = $this; - $I->fillField(['id' => 'jform_title'], $title); - } - - /** - * @When I add content body :arg1 - */ - public function iAddContentBody($body) - { - $I = $this; - $I->click('Toggle editor'); - $I->fillField(['id' => 'jform_articletext'], $body); - } - - /** - * @When I save an article - */ - public function iSaveAnArticle() - { - $I = $this; - $I->clickToolbarButton('Save'); - } - - /** - * @Then I should see the :arg1 message - */ - public function iShouldSeeTheMessage($message) - { - $I = $this; - $I->waitForPageTitle('Articles'); - $I->see($message, ['id' => 'system-message-container']); - } - - /** - * @Given I search and select content article with title :arg1 - */ - public function iSearchAndSelectContentArticleWithTitle($title) - { - $I = $this; - $I->amOnPage('administrator/index.php?option=com_content&view=articles'); - $I->fillField(['id' => 'filter_search'], $title); - $I->click('.icon-search'); - $I->checkAllResults(); - } - - /** - * @When I featured the article - */ - public function iFeatureTheContentWithTitle() - { - $I = $this; - $I->click(['xpath' => "//div[@id='toolbar-featured']//button"]); - } - - /** - * @Then I save and see the :arg1 message - */ - public function iSaveAndSeeTheMessage($message) - { - $I = $this; - $I->waitForPageTitle('Articles'); - $I->see($message, ['id' => 'system-message-container']); - } - - /** - * @Given I select the content article with title :arg1 - */ - public function iSelectTheContentArticleWithTitle($title) - { - $I = $this; - $I->amOnPage('administrator/index.php?option=com_content&view=articles'); - $I->fillField(['id' => 'filter_search'], $title); - $I->click('.icon-search'); - $I->checkAllResults(); - $I->click(['xpath' => "//div[@id='toolbar-edit']/button"]); - } - - /** - * @Given I set access level as a :arg1 - */ - public function iSetAccessLevelAsA($accessLevel) - { - $I = $this; - $I->selectOptionInChosenById('jform_access', $accessLevel); - } - - /** - * @When I save the article - */ - public function iSaveTheArticle() - { - $I = $this; - $I->clickToolbarButton('Save & Close'); - } - - /** - * @Given I have article with name :arg1 - */ - public function iHaveArticleWithName($title) - { - $I = $this; - $I->amOnPage('administrator/index.php?option=com_content&view=articles'); - $I->fillField(['id' => 'filter_search'], $title); - $I->click('.icon-search'); - $I->checkAllResults(); - } - - /** - * @When I unpublish the article - */ - public function iUnpublish() - { - $I = $this; - $I->clickToolbarButton('unpublish'); - } - /** - * @Then I see article unpublish message :arg1 - */ - public function iSeeArticleUnpublishMessage($message) - { - $I = $this; - $I->waitForPageTitle('Articles'); - $I->see($message, ['id' => 'system-message-container']); - } - - - /** - * @Given I have :arg1 content article which needs to be Trash - */ - public function iHaveContentArticleWhichNeedsToBeTrash($title) - { - $I = $this; - $I->amOnPage('administrator/index.php?option=com_content&view=articles'); - $I->fillField(['id' => 'filter_search'], $title); - $I->click('.icon-search'); - $I->checkAllResults(); - } - - /** - * @When I Trash the article - */ - public function iTrashTheArticleWithName() - { - $I = $this; - $I->clickToolbarButton('trash'); - } - - /** - * @Then I see article trash message :arg1 - */ - public function iSeeArticleTrashMessage($message) - { - $I = $this; - $I->waitForPageTitle('Articles'); - $I->see($message, ['id' => 'system-message-container']); - } - - /** - * @Given There is a add user link - */ - public function thereIsAAddUserLink() - { - $I = $this; - $I->amOnPage('administrator/index.php?option=com_users&view=users'); - $I->clickToolbarButton('New'); - } - - /** - * @When I enter the Name :arg1 - */ - public function iEnterTheName($name) - { - $I =$this; - $I->fillField(['id' => 'jform_name'], $name); - } - - /** - * @When I enter the Login Name :arg1 - */ - public function iEnterTheLoginName($username) - { - $I = $this; - $I->fillField(['id' => 'jform_username'], $username); - } - - /** - * @When I enter the Password :arg1 - */ - public function iEnterThePassword($password) - { - $I = $this; - $I->fillField(['id' => 'jform_password'], $password); - } - - /** - * @When I enter the Confirm Password :arg1 - */ - public function iEnterTheConfirmPassword($Confirm_Password) - { - $I = $this; - $I->fillField(['id' => 'jform_password2'], $Confirm_Password); - } - - /** - * @When I enter the Email :arg1 - */ - public function iEnterTheEmail($email) - { - $I = $this; - $I->fillField(['id' => 'jform_email'], $email); - } - - /** - * @Then I Save the user - */ - public function iSaveTheUser() - { - $I = $this; - $I->clickToolbarButton('Save & Close'); - } - - /** - * @Then I see the :arg1 message - */ - public function iSeeTheMessage($message) - { - $I = $this; - $I->waitForPageTitle('Users'); - $I->see($message, ['id' => 'system-message-container']); - } - - /** - * @Given I search and select the user with user name :arg1 - */ - public function iSearchAndSelectTheUserWithUserName($username) - { - $I = $this; - $I->amOnPage('administrator/index.php?option=com_users&view=users'); - $I->fillField(['id' => 'filter_search'], $username); - $I->click('.icon-search'); - $I->checkAllResults(); - $I->clickToolbarButton('edit'); - } - - /** - * @When I set name as an :arg1 and User Group as :arg1 - */ - public function iAssignedNameAndUserGroup($name, $userGroup) - { - $I = $this; - $I->fillField(['id' => 'jform_name'], $name); - $I->click('Assigned User Groups'); - - // @todo use $userGroup variable to select user group dynamically - $I->checkOption('#1group_4'); - } - /** - * @Then I should display the :arg1 message - */ - public function iShouldDisplayTheMessage($message) - { - $I = $this; - $I->clickToolbarButton('Save & Close'); - $I->waitForPageTitle('Users'); - $I->see($message, ['id' => 'system-message-container']); - } - - /** - * @Given I have a user with user name :arg1 - */ - public function iHaveAUserWithUserName($username) - { - $I = $this; - $I->amOnPage('administrator/index.php?option=com_users&view=users'); - $I->fillField(['id' => 'filter_search'], $username); - $I->click('.icon-search'); - $I->checkAllResults(); - } - - /** - * @When I block the user - */ - public function iBlockTheUser() - { - $I = $this; - $I->clickToolbarButton('unpublish'); - } - - /** - * @Then I should see the user block message :arg1 - */ - public function iShouldSeeTheUserBlockMessage($message) - { - $I = $this; - $I->waitForPageTitle('Users'); - $I->see($message, ['id' => 'system-message-container']); - } - - /** - * @Given I have a blocked user with user name :arg1 - */ - public function iHaveABlockedUserWithUserName($username) - { - $I = $this; - $I->amOnPage('administrator/index.php?option=com_users&view=users'); - $I->fillField(['id' => 'filter_search'], $username); - $I->click('.icon-search'); - $I->checkAllResults(); - } - - /** - * @When I unblock the user - */ - public function iUnblockTheUser() - { - $I = $this; - $I->waitForPageTitle('Users'); - $I->click(['xpath' => "//div[@id='toolbar-unblock']//button"]); - } - - /** - * @Then I should see the user unblock message :arg1 - */ - public function iShouldSeeTheUserUnblockMessage($message) - { - $I = $this; - $I->waitForPageTitle('Users'); - $I->see($message, ['id' => 'system-message-container']); - } - - /** - * @When I Delete the user :arg1 - */ - public function iDeleteTheUser($username) - { - $I = $this; - $I->amOnPage('administrator/index.php?option=com_users&view=users'); - $I->fillField(['id' => 'filter_search'], $username); - $I->click('.icon-search'); - $I->checkAllResults(); - $I->clickToolbarButton('empty trash'); - $I->acceptPopup(); - } - - /** - * @Then I confirm the user should have been deleted by getting the message :arg1 - */ - public function iConfirmTheUserDeleteSucessfully($message) - { - $I = $this; - $I->checkForPhpNoticesOrWarnings(); - $I->expectTo('see a success message and the user is deleted'); - $I->see($message, ['class' => 'alert-message']); - } - /** * Method is to set Wait for page title * diff --git a/tests/_support/Page/Acceptance/Administrator/Login.php b/tests/_support/Page/Acceptance/Administrator/Login.php index 8e84d8379f..cfa824648b 100644 --- a/tests/_support/Page/Acceptance/Administrator/Login.php +++ b/tests/_support/Page/Acceptance/Administrator/Login.php @@ -4,14 +4,33 @@ class Login extends \AcceptanceTester { /** - * @When I login into Joomla Administrator with username :arg1 and password :arg1 - */ - public function login($username, $password) - { - $I = $this; - $I->amOnPage('administrator/'); - $I->fillField(['css' => 'input[data-tests="username"]'], $username); - $I->fillField(['css' => 'input[data-tests="password"]'], $password); - $I->click(['css' => 'button[data-tests="log in"]']); - } + * Install joomla CMS + * + * @Given Joomla CMS is installed + */ + public function joomlaCMSIsInstalled() + { + // throw new \Codeception\Exception\Incomplete("Step `Joomla CMS is installed` is not defined"); + } + + /** + * @When Login into Joomla administrator with username :arg1 and password :arg1 + */ + public function loginIntoJoomlaAdministrator($username, $password) + { + $I = $this; + $I->amOnPage('administrator/'); + $I->fillField(['css' => 'input[data-tests="username"]'], $username); + $I->fillField(['css' => 'input[data-tests="password"]'], $password); + $I->click(['css' => 'button[data-tests="log in"]']); + } + + /** + * @Then I see administrator dashboard + */ + public function iSeeAdministratorDashboard() + { + $I = $this; + $I->waitForPageTitle('Control Panel', 4); + } } diff --git a/tests/_support/Step/Acceptance/Administrator/Content.php b/tests/_support/Step/Acceptance/Administrator/Content.php new file mode 100644 index 0000000000..7c367fdf8f --- /dev/null +++ b/tests/_support/Step/Acceptance/Administrator/Content.php @@ -0,0 +1,177 @@ +amOnPage('administrator/index.php?option=com_content&view=articles'); + $I->clickToolbarButton('New'); + } + + /** + * @When I add the content with title :arg1 + */ + public function iAddTheContentWithTitle($title) + { + $I = $this; + $I->fillField(['id' => 'jform_title'], $title); + } + + /** + * @When I add content body :arg1 + */ + public function iAddContentBody($body) + { + $I = $this; + $I->click('Toggle editor'); + $I->fillField(['id' => 'jform_articletext'], $body); + } + + /** + * @When I save an article + */ + public function iSaveAnArticle() + { + $I = $this; + $I->clickToolbarButton('Save'); + } + + /** + * @Then I should see the :arg1 message + */ + public function iShouldSeeTheMessage($message) + { + $I = $this; + $I->waitForPageTitle('Articles'); + $I->see($message, ['id' => 'system-message-container']); + } + + /** + * @Given I search and select content article with title :arg1 + */ + public function iSearchAndSelectContentArticleWithTitle($title) + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_content&view=articles'); + $I->fillField(['id' => 'filter_search'], $title); + $I->click('.icon-search'); + $I->checkAllResults(); + } + + /** + * @When I featured the article + */ + public function iFeatureTheContentWithTitle() + { + $I = $this; + $I->click(['xpath' => "//div[@id='toolbar-featured']//button"]); + } + + /** + * @Then I save and see the :arg1 message + */ + public function iSaveAndSeeTheMessage($message) + { + $I = $this; + $I->waitForPageTitle('Articles'); + $I->see($message, ['id' => 'system-message-container']); + } + + /** + * @Given I select the content article with title :arg1 + */ + public function iSelectTheContentArticleWithTitle($title) + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_content&view=articles'); + $I->fillField(['id' => 'filter_search'], $title); + $I->click('.icon-search'); + $I->checkAllResults(); + $I->click(['xpath' => "//div[@id='toolbar-edit']/button"]); + } + + /** + * @Given I set access level as a :arg1 + */ + public function iSetAccessLevelAsA($accessLevel) + { + $I = $this; + $I->selectOptionInChosenById('jform_access', $accessLevel); + } + + /** + * @When I save the article + */ + public function iSaveTheArticle() + { + $I = $this; + $I->clickToolbarButton('Save & Close'); + } + + /** + * @Given I have article with name :arg1 + */ + public function iHaveArticleWithName($title) + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_content&view=articles'); + $I->fillField(['id' => 'filter_search'], $title); + $I->click('.icon-search'); + $I->checkAllResults(); + } + + /** + * @When I unpublish the article + */ + public function iUnpublish() + { + $I = $this; + $I->clickToolbarButton('unpublish'); + } + /** + * @Then I see article unpublish message :arg1 + */ + public function iSeeArticleUnpublishMessage($message) + { + $I = $this; + $I->waitForPageTitle('Articles'); + $I->see($message, ['id' => 'system-message-container']); + } + + + /** + * @Given I have :arg1 content article which needs to be Trash + */ + public function iHaveContentArticleWhichNeedsToBeTrash($title) + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_content&view=articles'); + $I->fillField(['id' => 'filter_search'], $title); + $I->click('.icon-search'); + $I->checkAllResults(); + } + + /** + * @When I Trash the article + */ + public function iTrashTheArticleWithName() + { + $I = $this; + $I->clickToolbarButton('trash'); + } + + /** + * @Then I see article trash message :arg1 + */ + public function iSeeArticleTrashMessage($message) + { + $I = $this; + $I->waitForPageTitle('Articles'); + $I->see($message, ['id' => 'system-message-container']); + } +} \ No newline at end of file diff --git a/tests/_support/Step/Acceptance/Administrator/User.php b/tests/_support/Step/Acceptance/Administrator/User.php index aec47635b4..4989c7e424 100644 --- a/tests/_support/Step/Acceptance/Administrator/User.php +++ b/tests/_support/Step/Acceptance/Administrator/User.php @@ -4,20 +4,200 @@ class User extends \AcceptanceTester { /** - * @Given I am registered administrator named :arg1 + * @Given There is a add user link */ - public function iAmRegisteredAdministratorNamed($arg1) + public function thereIsAAddUserLink() { $I = $this; - $I->comment('@todo'); + $I->amOnPage('administrator/index.php?option=com_users&view=users'); + $I->clickToolbarButton('New'); } /** - * @Then I should see administrator dashboard + * @When I enter the Name :arg1 */ - public function iShouldSeeAdministratorDashboard() + public function iEnterTheName($name) + { + $I =$this; + $I->fillField(['id' => 'jform_name'], $name); + } + + /** + * @When I enter the Login Name :arg1 + */ + public function iEnterTheLoginName($username) + { + $I = $this; + $I->fillField(['id' => 'jform_username'], $username); + } + + /** + * @When I enter the Password :arg1 + */ + public function iEnterThePassword($password) + { + $I = $this; + $I->fillField(['id' => 'jform_password'], $password); + } + + /** + * @When I enter the Confirm Password :arg1 + */ + public function iEnterTheConfirmPassword($Confirm_Password) + { + $I = $this; + $I->fillField(['id' => 'jform_password2'], $Confirm_Password); + } + + /** + * @When I enter the Email :arg1 + */ + public function iEnterTheEmail($email) + { + $I = $this; + $I->fillField(['id' => 'jform_email'], $email); + } + + /** + * @Then I Save the user + */ + public function iSaveTheUser() + { + $I = $this; + $I->clickToolbarButton('Save & Close'); + } + + /** + * @Then I see the :arg1 message + */ + public function iSeeTheMessage($message) + { + $I = $this; + $I->waitForPageTitle('Users'); + $I->see($message, ['id' => 'system-message-container']); + } + + /** + * @Given I search and select the user with user name :arg1 + */ + public function iSearchAndSelectTheUserWithUserName($username) + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_users&view=users'); + $I->fillField(['id' => 'filter_search'], $username); + $I->click('.icon-search'); + $I->checkAllResults(); + $I->clickToolbarButton('edit'); + } + + /** + * @When I set name as an :arg1 and User Group as :arg1 + */ + public function iAssignedNameAndUserGroup($name, $userGroup) + { + $I = $this; + $I->fillField(['id' => 'jform_name'], $name); + $I->click('Assigned User Groups'); + + // @todo use $userGroup variable to select user group dynamically + $I->checkOption('#1group_4'); + } + /** + * @Then I should display the :arg1 message + */ + public function iShouldDisplayTheMessage($message) + { + $I = $this; + $I->clickToolbarButton('Save & Close'); + $I->waitForPageTitle('Users'); + $I->see($message, ['id' => 'system-message-container']); + } + + /** + * @Given I have a user with user name :arg1 + */ + public function iHaveAUserWithUserName($username) + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_users&view=users'); + $I->fillField(['id' => 'filter_search'], $username); + $I->click('.icon-search'); + $I->checkAllResults(); + } + + /** + * @When I block the user + */ + public function iBlockTheUser() + { + $I = $this; + $I->clickToolbarButton('unpublish'); + } + + /** + * @Then I should see the user block message :arg1 + */ + public function iShouldSeeTheUserBlockMessage($message) + { + $I = $this; + $I->waitForPageTitle('Users'); + $I->see($message, ['id' => 'system-message-container']); + } + + /** + * @Given I have a blocked user with user name :arg1 + */ + public function iHaveABlockedUserWithUserName($username) + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_users&view=users'); + $I->fillField(['id' => 'filter_search'], $username); + $I->click('.icon-search'); + $I->checkAllResults(); + } + + /** + * @When I unblock the user + */ + public function iUnblockTheUser() + { + $I = $this; + $I->waitForPageTitle('Users'); + $I->click(['xpath' => "//div[@id='toolbar-unblock']//button"]); + } + + /** + * @Then I should see the user unblock message :arg1 + */ + public function iShouldSeeTheUserUnblockMessage($message) + { + $I = $this; + $I->waitForPageTitle('Users'); + $I->see($message, ['id' => 'system-message-container']); + } + + /** + * @When I Delete the user :arg1 + */ + public function iDeleteTheUser($username) + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_users&view=users'); + $I->fillField(['id' => 'filter_search'], $username); + $I->click('.icon-search'); + $I->checkAllResults(); + $I->clickToolbarButton('empty trash'); + $I->acceptPopup(); + } + + /** + * @Then I confirm the user should have been deleted by getting the message :arg1 + */ + public function iConfirmTheUserDeleteSucessfully($message) { $I = $this; - $I->comment('@todo'); + $I->checkForPhpNoticesOrWarnings(); + $I->expectTo('see a success message and the user is deleted'); + $I->see($message, ['class' => 'alert-message']); } } \ No newline at end of file From 2af295472b660ae85698727a7f45dbaaa00c7bed Mon Sep 17 00:00:00 2001 From: Prital Patel Date: Sun, 12 Jun 2016 08:42:46 +0530 Subject: [PATCH 17/18] Moving joomla browser methods into AcceptanceTester.php --- RoboFile.php | 9 -- tests/_support/AcceptanceTester.php | 125 ++++++++++++++++++ .../Step/Acceptance/Administrator/Content.php | 41 +++--- .../Step/Acceptance/Administrator/User.php | 79 ++++++----- tests/acceptance/administratorlogin.feature | 12 +- tests/acceptance/content.feature | 6 +- tests/acceptance/users.feature | 21 ++- 7 files changed, 205 insertions(+), 88 deletions(-) diff --git a/RoboFile.php b/RoboFile.php index 5f227fc1f5..08d9f3d3fe 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -273,15 +273,6 @@ public function runTests($opts = ['use-htaccess' => false, 'env' => 'desktop']) ->run() ->stopOnFail(); - $this->taskCodecept($pathToCodeception) - ->arg('--steps') - ->arg('--debug') - ->arg('--fail-fast') - ->arg('--env ' . $opts['env']) - ->arg('tests/acceptance/administrator.feature') - ->run() - ->stopOnFail(); - $this->taskCodecept($pathToCodeception) ->arg('--steps') ->arg('--debug') diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 07e95519d7..ac6c55b8dc 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -33,4 +33,129 @@ public function waitForPageTitle($title, $timeout = 60) $I = $this; $I->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']"]); + } + + /** + * Selects an option in a Chosen Selector based on its id + * + * @param string $selectId The id of the