From 6146016c2297f8836bccaf0e9c3d71c842f8d82a Mon Sep 17 00:00:00 2001 From: m-tyrala Date: Mon, 5 Feb 2018 13:31:53 +0100 Subject: [PATCH 1/4] EZP-28172 Behat Covering of Content Types - squash changes to one commit --- .travis.yml | 2 +- behat_suites.yml | 15 +- .../Authentication.feature | 0 features/ContentTypeGroup.feature | 63 +++++++ .../BusinessContext/AdministrationContext.php | 168 ++++++++++++++++++ .../AuthenticationContext.php | 2 +- .../{ => BusinessContext}/BusinessContext.php | 3 +- .../ContentViewContext.php} | 32 +--- .../NavigationContext.php | 21 ++- .../BusinessContext/NotificationContext.php | 25 +++ .../BusinessContext/RightMenuContext.php | 24 +++ .../Behat/BusinessContext/UpdateContext.php | 23 +++ .../Behat/{ => Helper}/EnvironmentRestore.php | 2 +- src/lib/Behat/{ => Helper}/Hooks.php | 2 +- src/lib/Behat/{ => Helper}/StudioUtility.php | 2 +- src/lib/Behat/{ => Helper}/UtilityContext.php | 37 +++- src/lib/Behat/PageElement/AdminList.php | 96 ++++++++++ src/lib/Behat/PageElement/Breadcrumb.php | 25 +++ src/lib/Behat/PageElement/Dialog.php | 30 ++++ src/lib/Behat/PageElement/Element.php | 7 +- src/lib/Behat/PageElement/ElementFactory.php | 42 +++++ src/lib/Behat/PageElement/Notification.php | 30 ++++ src/lib/Behat/PageElement/RightMenu.php | 8 + src/lib/Behat/PageElement/UpdateForm.php | 33 ++++ src/lib/Behat/PageElement/UpperMenu.php | 8 + .../Behat/PageObject/ContentStructurePage.php | 7 +- .../Behat/PageObject/ContentTypeGroupPage.php | 41 +++++ .../PageObject/ContentTypeGroupsPage.php | 38 ++++ src/lib/Behat/PageObject/DashboardPage.php | 2 +- src/lib/Behat/PageObject/LoginPage.php | 2 +- src/lib/Behat/PageObject/Page.php | 11 +- .../Behat/PageObject/PageObjectFactory.php | 16 +- src/lib/Behat/PageObject/UpdateItemPage.php | 44 +++++ 33 files changed, 799 insertions(+), 62 deletions(-) rename {src/features => features}/Authentication.feature (100%) create mode 100644 features/ContentTypeGroup.feature create mode 100644 src/lib/Behat/BusinessContext/AdministrationContext.php rename src/lib/Behat/{ => BusinessContext}/AuthenticationContext.php (96%) rename src/lib/Behat/{ => BusinessContext}/BusinessContext.php (84%) rename src/lib/Behat/{ContentContext.php => BusinessContext/ContentViewContext.php} (51%) rename src/lib/Behat/{ => BusinessContext}/NavigationContext.php (62%) create mode 100644 src/lib/Behat/BusinessContext/NotificationContext.php create mode 100644 src/lib/Behat/BusinessContext/RightMenuContext.php create mode 100644 src/lib/Behat/BusinessContext/UpdateContext.php rename src/lib/Behat/{ => Helper}/EnvironmentRestore.php (98%) rename src/lib/Behat/{ => Helper}/Hooks.php (95%) rename src/lib/Behat/{ => Helper}/StudioUtility.php (99%) rename src/lib/Behat/{ => Helper}/UtilityContext.php (82%) create mode 100644 src/lib/Behat/PageElement/AdminList.php create mode 100644 src/lib/Behat/PageElement/Breadcrumb.php create mode 100644 src/lib/Behat/PageElement/Dialog.php create mode 100644 src/lib/Behat/PageElement/ElementFactory.php create mode 100644 src/lib/Behat/PageElement/Notification.php create mode 100644 src/lib/Behat/PageElement/UpdateForm.php create mode 100644 src/lib/Behat/PageObject/ContentTypeGroupPage.php create mode 100644 src/lib/Behat/PageObject/ContentTypeGroupsPage.php create mode 100644 src/lib/Behat/PageObject/UpdateItemPage.php diff --git a/.travis.yml b/.travis.yml index 54874b17fa..d6f1b00584 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ matrix: - php: 7.1 env: PHPUNIT_CONFIG='phpunit.xml' - php: 7.1 - env: BEHAT_OPTS="--profile=adminui --suite=adminui" SYMFONY_ENV=behat + env: BEHAT_OPTS="--profile=adminui --suite=adminui --no-interaction" SYMFONY_ENV=behat env: global: diff --git a/behat_suites.yml b/behat_suites.yml index 43dd92144e..59083b30e8 100644 --- a/behat_suites.yml +++ b/behat_suites.yml @@ -4,11 +4,16 @@ adminui: suites: adminui: paths: - - '%paths.base%/vendor/ezsystems/ezplatform-admin-ui/src/features' + - '%paths.base%/vendor/ezsystems/ezplatform-admin-ui/features' filters: tags: "@common" contexts: - - EzSystems\EzPlatformAdminUi\Behat\UtilityContext - - EzSystems\EzPlatformAdminUi\Behat\AuthenticationContext - - EzSystems\EzPlatformAdminUi\Behat\NavigationContext - - EzSystems\EzPlatformAdminUi\Behat\Hooks + - EzSystems\EzPlatformAdminUi\Behat\Helper\UtilityContext + - EzSystems\EzPlatformAdminUi\Behat\Helper\Hooks + - EzSystems\EzPlatformAdminUi\Behat\BusinessContext\AuthenticationContext + - EzSystems\EzPlatformAdminUi\Behat\BusinessContext\NavigationContext + - EzSystems\EzPlatformAdminUi\Behat\BusinessContext\AdministrationContext + - EzSystems\EzPlatformAdminUi\Behat\BusinessContext\ContentViewContext + - EzSystems\EzPlatformAdminUi\Behat\BusinessContext\UpdateContext + - EzSystems\EzPlatformAdminUi\Behat\BusinessContext\RightMenuContext + - EzSystems\EzPlatformAdminUi\Behat\BusinessContext\NotificationContext diff --git a/src/features/Authentication.feature b/features/Authentication.feature similarity index 100% rename from src/features/Authentication.feature rename to features/Authentication.feature diff --git a/features/ContentTypeGroup.feature b/features/ContentTypeGroup.feature new file mode 100644 index 0000000000..7533ef5950 --- /dev/null +++ b/features/ContentTypeGroup.feature @@ -0,0 +1,63 @@ +Feature: Content types management + As an administrator + In order to customize my eZ installation + I want to manage my Content types structure. + + Background: + Given I am logged as "admin" + And I go to "Content Types" in "Admin" tab + + @javascript @common + Scenario: Changes can be discarded while creating new Content Type Group + When I start creating new "Content Type Group" + And I set "Name" to "Test CTG" + And I click on the edit action bar button "Discard changes" + Then I should be on "Content Type Groups" page + And I should see "Content Type Groups" list + And there's no "Test CTG" on "Content Type Groups" list + + @javascript @common + Scenario: New Content Type Group can be added + When I start creating new "Content Type Group" + And I set "Name" to "Test CTG" + And I click on the edit action bar button "Create" + Then I should be on "Content Type Group" "Test CTG" page + + @javascript @common + Scenario: I can navigate to Admin / Content Types through breadcrumb + Given I go to "Test CTG" "Content Type Group" page + When I click on "Content Types" on breadcrumb + Then I should be on "Content Type Groups" page + And I should see "Content Type Groups" list + + @javascript @common + Scenario: Changes can be discarded while editing Content Type Group + Given there's "Test CTG" on "Content Type Groups" list + When I start editing "Content Type Group" "Test CTG" + And I set "Name" to "Test CTG edited" + And I click on the edit action bar button "Discard changes" + Then I should be on "Content Type Groups" page + And I should see "Content Type Groups" list + And there's "Test CTG" on "Content Type Groups" list + And there's no "Test CTG edited" on "Content Type Groups" list + + @javascript @common + Scenario: Content Type Group can be edited + Given there's "Test CTG" on "Content Type Groups" list + When I start editing "Content Type Group" "Test CTG" + And I set "Name" to "Test CTG edited" + And I click on the edit action bar button "Save" + Then I should be on "Content Type Group" "Test CTG edited" page + And notification that "Content type group" "Test CTG" is updated appears + + @javascript @common + Scenario: Content type group can be deleted + Given there's empty "Test CTG edited" on "Content Type Groups" list + When I delete "Content Type Group" "Test CTG edited" + Then there's no "Test CTG edited" on "Content Type Groups" list + And notification that "Content type group" "Test CTG edited" is deleted appears + + @javascript @common + Scenario: Non-empty Content type group cannot be deleted + Given there's non-empty "Content" on "Content Type Groups" list + Then "Content Type Group" "Content" cannot be selected diff --git a/src/lib/Behat/BusinessContext/AdministrationContext.php b/src/lib/Behat/BusinessContext/AdministrationContext.php new file mode 100644 index 0000000000..f5e0fa5812 --- /dev/null +++ b/src/lib/Behat/BusinessContext/AdministrationContext.php @@ -0,0 +1,168 @@ + ContentTypeGroupsPage::PAGE_NAME, + 'Content Type' => '', + 'Language' => '', + 'Role' => '', + 'Section' => '', + 'User' => '', ]; + private $emptyHeaderMapping = ['Content Type Groups' => 'Content Types count', + 'Sections' => 'Assigned Content items', ]; + + /** + * @Then I should see :pageName list + * @Then I should see :pageName :parameter list + * + * @param string $pageName + */ + public function iSeeList(string $pageName, string $parameter = null): void + { + $contentTypeGroupsPage = PageObjectFactory::createPage($this->utilityContext, $pageName, $parameter); + $contentTypeGroupsPage->verifyElements(); + } + + /** + * @When I start creating new :newItemType + * + * @param string $newItemType + */ + public function iStartCreatingNew(string $newItemType): void + { + if (!\array_key_exists($newItemType, $this->itemCreateMapping)) { + throw new \InvalidArgumentException(sprintf('Unrecognised item type name: %s', $newItemType)); + } + PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$newItemType]) + ->adminList->clickPlusButton(); + } + + /** + * @Then there's :listElementName on :page list + * @Then there's :listElementName on :parameter :page list + */ + public function isElementOnTheList($listElementName, $page): void + { + $actual = PageObjectFactory::createPage($this->utilityContext, $page) + ->adminList->isElementOnList($listElementName); + + if (!$actual) { + throw new ElementNotFoundException( + $this->utilityContext->getSession(), + sprintf('Element "%s" is not on the %s list.', $listElementName, $page)); + } + } + + /** + * @Then there's no :listElementName on :page list + * @Then there's no :listElementName on :parameter :page list + */ + public function isElementNotOnTheList($listElementName, $page, $parameter = null): void + { + $actual = PageObjectFactory::createPage($this->utilityContext, $page, $parameter) + ->adminList->isElementOnList($listElementName); + + if ($actual) { + throw new ElementNotFoundException( + $this->utilityContext->getSession(), + sprintf('Element "%s" is on the %s list.', $listElementName, $page)); + } + } + + /** + * Check if item is or is not empty, according to $empty param. + * + * @param $itemName + * @param $page + * @param $shouldBeEmpty + */ + private function verifyContentsStatus($itemName, $page, $shouldBeEmpty): void + { + $isEmpty = '0'; + + $contentsCount = PageObjectFactory::createPage($this->utilityContext, $page) + ->adminList->getListItemAttribute($itemName, $this->emptyHeaderMapping[$page]); + + $msg = ''; + if ($shouldBeEmpty) { + $msg = ' non'; + } + + if (($contentsCount !== $isEmpty) === $shouldBeEmpty) { + throw new ElementNotFoundException( + $this->utilityContext->getSession(), + sprintf('No%s empty %s on the %s list.', $msg, $itemName, $page)); + } + } + + /** + * @Given there's empty :itemName on :page list + */ + public function isEmptyElementOnTheList($itemName, $page): void + { + $this->verifyContentsStatus($itemName, $page, true); + } + + /** + * @Given there's non-empty :itemName on :page list + */ + public function isNonEmptyElementOnTheList($itemName, $page): void + { + $this->verifyContentsStatus($itemName, $page, false); + } + + /** + * @Then :itemType :itemName cannot be selected + */ + public function itemCannotBeSelected($itemType, $itemName): void + { + $checkboxState = PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType]) + ->adminList->isListElementSelectable($itemName); + + if ($checkboxState) { + throw new \Exception(sprintf('Element %s shoudn\'t be selectable.', $itemName)); + } + } + + /** + * @Given I go to :itemName :itemType page + */ + public function iGoToListItem($itemName, $itemType) + { + PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType]) + ->adminList->clickListElement($itemName); + } + + /** + * @When I start editing :itemType :itemName + */ + public function iStartEditingItem($itemType, $itemName) + { + PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType]) + ->adminList->clickEditButton($itemName); + } + + /** + * @When I delete :itemType :itemName + */ + public function iDeleteItem($itemType, $itemName) + { + $contentTypeGroups = PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType]); + $contentTypeGroups->adminList->selectListElement($itemName); + $contentTypeGroups->adminList->clickTrashButton(); + ElementFactory::createElement($this->utilityContext, Dialog::ELEMENT_NAME) + ->confirm(); + } +} diff --git a/src/lib/Behat/AuthenticationContext.php b/src/lib/Behat/BusinessContext/AuthenticationContext.php similarity index 96% rename from src/lib/Behat/AuthenticationContext.php rename to src/lib/Behat/BusinessContext/AuthenticationContext.php index f10123b31b..ee8736cae2 100644 --- a/src/lib/Behat/AuthenticationContext.php +++ b/src/lib/Behat/BusinessContext/AuthenticationContext.php @@ -4,7 +4,7 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformAdminUi\Behat; +namespace EzSystems\EzPlatformAdminUi\Behat\BusinessContext; use EzSystems\EzPlatformAdminUi\Behat\PageObject\LoginPage; use EzSystems\EzPlatformAdminUi\Behat\PageObject\PageObjectFactory; diff --git a/src/lib/Behat/BusinessContext.php b/src/lib/Behat/BusinessContext/BusinessContext.php similarity index 84% rename from src/lib/Behat/BusinessContext.php rename to src/lib/Behat/BusinessContext/BusinessContext.php index 8149562c83..f90356940d 100644 --- a/src/lib/Behat/BusinessContext.php +++ b/src/lib/Behat/BusinessContext/BusinessContext.php @@ -4,10 +4,11 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformAdminUi\Behat; +namespace EzSystems\EzPlatformAdminUi\Behat\BusinessContext; use Behat\Behat\Context\Context; use Behat\Behat\Hook\Scope\BeforeScenarioScope; +use EzSystems\EzPlatformAdminUi\Behat\Helper\UtilityContext; abstract class BusinessContext implements Context { diff --git a/src/lib/Behat/ContentContext.php b/src/lib/Behat/BusinessContext/ContentViewContext.php similarity index 51% rename from src/lib/Behat/ContentContext.php rename to src/lib/Behat/BusinessContext/ContentViewContext.php index 8be2000ba6..6bab0b39a2 100644 --- a/src/lib/Behat/ContentContext.php +++ b/src/lib/Behat/BusinessContext/ContentViewContext.php @@ -4,27 +4,14 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformAdminUi\Behat; +namespace EzSystems\EzPlatformAdminUi\Behat\BusinessContext; -use EzSystems\EzPlatformAdminUi\Behat\PageElement\RightMenu; use EzSystems\EzPlatformAdminUi\Behat\PageObject\ContentStructurePage; use EzSystems\EzPlatformAdminUi\Behat\PageObject\PageObjectFactory; use PHPUnit\Framework\Assert; -class ContentContext extends BusinessContext +class ContentViewContext extends BusinessContext { - /** - * @Given I click (on) the edit action bar button :button - * Click on a AdminUI edit action bar - * - * @param string $button Text of the element to click - */ - public function clickEditActionBar($button) - { - $rightMenu = new RightMenu($this->utilityContext); - $rightMenu->clickButton($button); - } - /** * @Given I start creating a new Landing Page :name */ @@ -42,19 +29,4 @@ public function iSeeTitle($title) $contentStructurePage = PageObjectFactory::createPage($this->utilityContext, ContentStructurePage::PAGE_NAME); Assert::assertEquals($title, $contentStructurePage->getPageHeaderTitle()); } - - /** - * @When I set :field to :value - * @When I set :field as empty - */ - public function fillFieldWithValue($field, $value = '') - { - $fieldNode = $this->utilityContext->waitUntil(10, - function () use ($field) { - return $this->utilityContext->getSession()->getPage()->findField($field); - }); - - $fieldNode->setValue(''); - $fieldNode->setValue($value); - } } diff --git a/src/lib/Behat/NavigationContext.php b/src/lib/Behat/BusinessContext/NavigationContext.php similarity index 62% rename from src/lib/Behat/NavigationContext.php rename to src/lib/Behat/BusinessContext/NavigationContext.php index 8929479c96..c90e05ae12 100644 --- a/src/lib/Behat/NavigationContext.php +++ b/src/lib/Behat/BusinessContext/NavigationContext.php @@ -4,8 +4,10 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformAdminUi\Behat; +namespace EzSystems\EzPlatformAdminUi\Behat\BusinessContext; +use EzSystems\EzPlatformAdminUi\Behat\PageElement\Breadcrumb; +use EzSystems\EzPlatformAdminUi\Behat\PageElement\ElementFactory; use EzSystems\EzPlatformAdminUi\Behat\PageElement\UpperMenu; use EzSystems\EzPlatformAdminUi\Behat\PageObject\PageObjectFactory; @@ -31,10 +33,11 @@ public function tryToOpenPage($pageName): void /** * @Then I should be on :pageName page + * @Then I should be on :pageName :itemName page */ - public function iAmOnPage($pageName): void + public function iAmOnPage($pageName, $itemName = null): void { - $page = PageObjectFactory::createPage($this->utilityContext, $pageName); + $page = PageObjectFactory::createPage($this->utilityContext, $pageName, $itemName); $page->verifyIsLoaded(); } @@ -44,11 +47,21 @@ public function iAmOnPage($pageName): void */ public function iGoToTab($tabName, $subTab = null): void { - $upperMenu = new UpperMenu($this->utilityContext); + $upperMenu = ElementFactory::createElement($this->utilityContext, UpperMenu::ELEMENT_NAME); $upperMenu->goToTab($tabName); if ($subTab !== null) { $upperMenu->goToSubTab($subTab); } } + + /** + * @When I click on :element on breadcrumb + */ + public function iClickOnBreadcrumbLink($element) + { + $breadcrumb = ElementFactory::createElement($this->utilityContext, Breadcrumb::ELEMENT_NAME); + $breadcrumb->verifyVisibility(); + $breadcrumb->clickBreadcrumbItem($element); + } } diff --git a/src/lib/Behat/BusinessContext/NotificationContext.php b/src/lib/Behat/BusinessContext/NotificationContext.php new file mode 100644 index 0000000000..afc9d0f6a5 --- /dev/null +++ b/src/lib/Behat/BusinessContext/NotificationContext.php @@ -0,0 +1,25 @@ +utilityContext, Notification::ELEMENT_NAME); + $notification->verifyVisibility(); + $notification->verifyAlertSuccess(); + Assert::assertEquals(sprintf('%s \'%s\' %s.', $itemType, $itemName, $action), $notification->getMessage()); + } +} diff --git a/src/lib/Behat/BusinessContext/RightMenuContext.php b/src/lib/Behat/BusinessContext/RightMenuContext.php new file mode 100644 index 0000000000..b6f5cd2d04 --- /dev/null +++ b/src/lib/Behat/BusinessContext/RightMenuContext.php @@ -0,0 +1,24 @@ +utilityContext); + $rightMenu->clickButton($button); + } +} diff --git a/src/lib/Behat/BusinessContext/UpdateContext.php b/src/lib/Behat/BusinessContext/UpdateContext.php new file mode 100644 index 0000000000..150d0713e0 --- /dev/null +++ b/src/lib/Behat/BusinessContext/UpdateContext.php @@ -0,0 +1,23 @@ +utilityContext, UpdateItemPage::PAGE_NAME) + ->updateForm->fillFIeldWithValue($field, $value); + } +} diff --git a/src/lib/Behat/EnvironmentRestore.php b/src/lib/Behat/Helper/EnvironmentRestore.php similarity index 98% rename from src/lib/Behat/EnvironmentRestore.php rename to src/lib/Behat/Helper/EnvironmentRestore.php index 0fe9815590..b41ba16f13 100644 --- a/src/lib/Behat/EnvironmentRestore.php +++ b/src/lib/Behat/Helper/EnvironmentRestore.php @@ -4,7 +4,7 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformAdminUi\Behat; +namespace EzSystems\EzPlatformAdminUi\Behat\Helper; use EzSystems\PlatformInstallerBundle\Installer\Installer; use Symfony\Component\Console\Output\NullOutput; diff --git a/src/lib/Behat/Hooks.php b/src/lib/Behat/Helper/Hooks.php similarity index 95% rename from src/lib/Behat/Hooks.php rename to src/lib/Behat/Helper/Hooks.php index 8e5cd50236..2d2ed02eb1 100644 --- a/src/lib/Behat/Hooks.php +++ b/src/lib/Behat/Helper/Hooks.php @@ -4,7 +4,7 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformAdminUi\Behat; +namespace EzSystems\EzPlatformAdminUi\Behat\Helper; use Behat\MinkExtension\Context\RawMinkContext; use Behat\Symfony2Extension\Context\KernelDictionary; diff --git a/src/lib/Behat/StudioUtility.php b/src/lib/Behat/Helper/StudioUtility.php similarity index 99% rename from src/lib/Behat/StudioUtility.php rename to src/lib/Behat/Helper/StudioUtility.php index 2fd02dbe46..1d7c27cea2 100644 --- a/src/lib/Behat/StudioUtility.php +++ b/src/lib/Behat/Helper/StudioUtility.php @@ -4,7 +4,7 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformAdminUi\Behat; +namespace EzSystems\EzPlatformAdminUi\Behat\Helper; use Behat\Mink\Element\NodeElement; use Exception; diff --git a/src/lib/Behat/UtilityContext.php b/src/lib/Behat/Helper/UtilityContext.php similarity index 82% rename from src/lib/Behat/UtilityContext.php rename to src/lib/Behat/Helper/UtilityContext.php index da2d54a3dc..6c15565420 100644 --- a/src/lib/Behat/UtilityContext.php +++ b/src/lib/Behat/Helper/UtilityContext.php @@ -4,7 +4,7 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformAdminUi\Behat; +namespace EzSystems\EzPlatformAdminUi\Behat\Helper; use Behat\Mink\Element\NodeElement; use Behat\Mink\Element\TraversableElement; @@ -99,6 +99,41 @@ public function getElementByText(string $text, string $selector, string $textSel return null; } + /** + * Finds an HTML element by class and the text value and returns it's position in order. Search can be narrowed to children of baseElement. + * + * @param string $text Text value of the element + * @param string $selector CSS selector of the element + * @param string $textSelector Extra CSS selector for text of the element + * @param TraversableElement|null $baseElement + * + * @return int + */ + public function getElementPositionByText(string $text, string $selector, string $textSelector = null, TraversableElement $baseElement = null): int + { + $baseElement = $baseElement ?? $this->getSession()->getPage(); + $counter = 0; + + $elements = $this->findAllWithWait($selector, $baseElement); + foreach ($elements as $element) { + ++$counter; + if ($textSelector !== null) { + try { + $elementText = $this->findElement($textSelector, 10, $element)->getText(); + } catch (\Exception $e) { + continue; + } + } else { + $elementText = $element->getText(); + } + if ($elementText === $text) { + return $counter; + } + } + + return 0; + } + /** * Waits no longer than specified timeout for the given condition to be true. * diff --git a/src/lib/Behat/PageElement/AdminList.php b/src/lib/Behat/PageElement/AdminList.php new file mode 100644 index 0000000000..5497dd91c1 --- /dev/null +++ b/src/lib/Behat/PageElement/AdminList.php @@ -0,0 +1,96 @@ + 'form', + 'plusButton' => '.ez-icon-create', + 'trashButton' => '.ez-icon-trash', + 'editButton' => 'tr:nth-child(%s) a[title=Edit]', + 'listHeader' => '.ez-table-header__headline', + 'tableHeader' => 'th', + 'listElementLink' => '.ez-checkbox-cell+ td a', + 'tableCell' => 'tr:nth-child(%s) td:nth-child(%s)', ]; + + /** @var string Name by which Element is recognised */ + public const ELEMENT_NAME = 'Admin List'; + protected $listHeader; + + public function __construct(UtilityContext $context, string $listHeader) + { + parent::__construct($context); + $this->listHeader = $listHeader; + } + + private function verifyProperList(): void + { + if ($this->listHeader !== $this->context->findElement($this->fields['listHeader'], $this->defaultTimeout)->getText()) { + throw new ElementNotFoundException($this->context->getSession(), 'table header', $this->fields['listHeader']); + } + } + + public function verifyVisibility(): void + { + $this->context->waitUntilElementIsVisible($this->fields['plusButton'], $this->defaultTimeout); + $this->context->waitUntilElementIsVisible($this->fields['trashButton'], $this->defaultTimeout); + $this->context->waitUntilElementIsVisible($this->fields['listHeader'], $this->defaultTimeout); + + $this->verifyProperList(); + } + + public function clickPlusButton(): void + { + $this->context->findElement($this->fields['plusButton'])->click(); + } + + public function clickTrashButton(): void + { + $this->context->findElement($this->fields['trashButton'])->click(); + } + + public function isListElementSelectable(string $name): bool + { + $position = $this->context->getElementPositionByText($name, $this->fields['listElementLink']); + $checkbox = $this->context->findElement(sprintf($this->fields['tableCell'], $position, 1) . ' .form-check-input')->getAttribute('disabled'); + + return $checkbox !== 'disabled'; + } + + public function selectListElement(string $name): void + { + $position = $this->context->getElementPositionByText($name, $this->fields['listElementLink']); + $this->context->findElement(sprintf($this->fields['tableCell'], $position, 1))->checkField(''); + } + + public function clickListElement(string $name): void + { + $this->context->getElementByText($name, $this->fields['listElementLink'])->click(); + } + + public function isElementOnList(string $name): bool + { + return $this->context->getElementByText($name, $this->fields['listElementLink']) !== null; + } + + public function getListItemAttribute(string $name, string $header): string + { + $columnPosition = $this->context->getElementPositionByText($header, $this->fields['tableHeader'], null, $this->context->findElement($this->fields['list'])); + $rowPosition = $this->context->getElementPositionByText($name, $this->fields['listElementLink'], null, $this->context->findElement($this->fields['list'])); + + return $this->context->findElement(sprintf($this->fields['tableCell'], $rowPosition, $columnPosition))->getText(); + } + + public function clickEditButton(string $listItemName): void + { + $position = $this->context->getElementPositionByText($listItemName, $this->fields['listElementLink']); + $this->context->findElement(sprintf($this->fields['editButton'], $position))->click(); + } +} diff --git a/src/lib/Behat/PageElement/Breadcrumb.php b/src/lib/Behat/PageElement/Breadcrumb.php new file mode 100644 index 0000000000..e2ff4a6dd2 --- /dev/null +++ b/src/lib/Behat/PageElement/Breadcrumb.php @@ -0,0 +1,25 @@ + '.breadcrumb-item', + 'breadcrumbItemLink' => '.breadcrumb-item a', ]; + /** @var string Name by which Element is recognised */ + public const ELEMENT_NAME = 'Breadcrumb'; + + public function verifyVisibility(): void + { + $this->context->waitUntilElementIsVisible($this->fields['breadcrumbItem']); + } + + public function clickBreadcrumbItem(string $itemName) + { + $this->context->getElementByText($itemName, $this->fields['breadcrumbItemLink'])->click(); + } +} diff --git a/src/lib/Behat/PageElement/Dialog.php b/src/lib/Behat/PageElement/Dialog.php new file mode 100644 index 0000000000..a390806be4 --- /dev/null +++ b/src/lib/Behat/PageElement/Dialog.php @@ -0,0 +1,30 @@ + '.btn--trigger', + 'decline' => '.btn--no', ]; + /** @var string Name by which Element is recognised */ + public const ELEMENT_NAME = 'Dialog'; + + public function confirm() + { + $this->context->findElement($this->fields['confirm'])->click(); + } + + public function decline() + { + $this->context->findElement($this->fields['decline'])->click(); + } + + public function verifyVisibility(): void + { + // TODO: Implement verifyVisibility() method. Not sure if it's needed + } +} diff --git a/src/lib/Behat/PageElement/Element.php b/src/lib/Behat/PageElement/Element.php index f8c8aafd73..47aace5b4f 100644 --- a/src/lib/Behat/PageElement/Element.php +++ b/src/lib/Behat/PageElement/Element.php @@ -6,7 +6,7 @@ */ namespace EzSystems\EzPlatformAdminUi\Behat\PageElement; -use EzSystems\EzPlatformAdminUi\Behat\UtilityContext; +use EzSystems\EzPlatformAdminUi\Behat\Helper\UtilityContext; abstract class Element { @@ -15,13 +15,12 @@ abstract class Element /* \EzSystems\EzPlatformAdminUi\Behat\UtilityContext */ protected $context; + protected $fields; public function __construct(UtilityContext $context) { $this->context = $context; } - public function verifyVisibility(): void - { - } + abstract public function verifyVisibility(): void; } diff --git a/src/lib/Behat/PageElement/ElementFactory.php b/src/lib/Behat/PageElement/ElementFactory.php new file mode 100644 index 0000000000..6cf15f6edd --- /dev/null +++ b/src/lib/Behat/PageElement/ElementFactory.php @@ -0,0 +1,42 @@ + '.alert', + 'successAlert' => '.alert-success', ]; + /** @var string Name by which Element is recognised */ + public const ELEMENT_NAME = 'Notification'; + + public function verifyVisibility(): void + { + $this->context->waitUntilElementIsVisible($this->fields['alert'], $this->defaultTimeout); + } + + public function verifyAlertSuccess() + { + $this->context->assertElementOnPage($this->fields['successAlert']); + } + + public function getMessage(): string + { + return $this->context->findElement($this->fields['alert'])->getText(); + } +} diff --git a/src/lib/Behat/PageElement/RightMenu.php b/src/lib/Behat/PageElement/RightMenu.php index e53a7851b7..b316f4de91 100644 --- a/src/lib/Behat/PageElement/RightMenu.php +++ b/src/lib/Behat/PageElement/RightMenu.php @@ -8,6 +8,9 @@ class RightMenu extends Element { + /** @var string Name by which Element is recognised */ + public const ELEMENT_NAME = 'Right Menu'; + /** * Clicks a button on the right menu (Create, Preview, Publish etc.). * @@ -17,4 +20,9 @@ public function clickButton($buttonName) { $this->context->getElementByText($buttonName, '.ez-context-menu .btn-block')->click(); } + + public function verifyVisibility(): void + { + // TODO: Implement verifyVisibility() method. + } } diff --git a/src/lib/Behat/PageElement/UpdateForm.php b/src/lib/Behat/PageElement/UpdateForm.php new file mode 100644 index 0000000000..8fe618f16d --- /dev/null +++ b/src/lib/Behat/PageElement/UpdateForm.php @@ -0,0 +1,33 @@ + '.form-group', + 'mainFormSection' => '.px-5:nth-child(1) .card-body', ]; + + /** @var string Name by which Element is recognised */ + public const ELEMENT_NAME = 'Admin Update Form'; + public const MAIN_FORM_SECTION = 'mainFormSection'; + + public function verifyVisibility(): void + { + // TODO: Implement verifyVisibility() method. + } + + public function fillFIeldWithValue(string $fieldName, string $value): void + { + $fieldNode = $this->context->waitUntil($this->defaultTimeout, + function () use ($fieldName) { + return $this->context->getSession()->getPage()->findField($fieldName); + }); + + $fieldNode->setValue(''); + $fieldNode->setValue($value); + } +} diff --git a/src/lib/Behat/PageElement/UpperMenu.php b/src/lib/Behat/PageElement/UpperMenu.php index f5ab4b7811..13bda59c24 100644 --- a/src/lib/Behat/PageElement/UpperMenu.php +++ b/src/lib/Behat/PageElement/UpperMenu.php @@ -8,6 +8,9 @@ class UpperMenu extends Element { + /** @var string Name by which Element is recognised */ + public const ELEMENT_NAME = 'Upper Menu'; + /** * Clicks on top menu, for example "Content" tab. * @@ -27,4 +30,9 @@ public function goToSubTab($tabName) { $this->context->getElementByText($tabName, '.navbar-expand-lg .nav-link')->click(); } + + public function verifyVisibility(): void + { + // TODO: Implement verifyVisibility() method. + } } diff --git a/src/lib/Behat/PageObject/ContentStructurePage.php b/src/lib/Behat/PageObject/ContentStructurePage.php index 792d1261b1..ee47d19f4d 100644 --- a/src/lib/Behat/PageObject/ContentStructurePage.php +++ b/src/lib/Behat/PageObject/ContentStructurePage.php @@ -7,7 +7,7 @@ namespace EzSystems\EzPlatformAdminUi\Behat\PageObject; use EzSystems\EzPlatformAdminUi\Behat\PageElement\RightMenu; -use EzSystems\EzPlatformAdminUi\Behat\UtilityContext; +use EzSystems\EzPlatformAdminUi\Behat\Helper\UtilityContext; class ContentStructurePage extends Page { @@ -43,4 +43,9 @@ public function startCreatingContent($contentType) $this->rightMenu->clickButton('Create'); $this->context->getElementByText($contentType, '.form-check-label')->click(); } + + public function verifyElements(): void + { + // TODO: Implement verifyElements() method. + } } diff --git a/src/lib/Behat/PageObject/ContentTypeGroupPage.php b/src/lib/Behat/PageObject/ContentTypeGroupPage.php new file mode 100644 index 0000000000..8b9485e72a --- /dev/null +++ b/src/lib/Behat/PageObject/ContentTypeGroupPage.php @@ -0,0 +1,41 @@ +groupName = $groupName; + parent::__construct($context); + $this->adminList = ElementFactory::createElement($this->context, AdminList::ELEMENT_NAME, sprintf('Content Types in %s', $this->groupName)); + } + + /** + * Verifies that all necessary elements are visible. + */ + public function verifyElements(): void + { + $this->adminList->verifyVisibility(); + } +} diff --git a/src/lib/Behat/PageObject/ContentTypeGroupsPage.php b/src/lib/Behat/PageObject/ContentTypeGroupsPage.php new file mode 100644 index 0000000000..6c2c12ce89 --- /dev/null +++ b/src/lib/Behat/PageObject/ContentTypeGroupsPage.php @@ -0,0 +1,38 @@ +adminList = ElementFactory::createElement($this->context, AdminList::ELEMENT_NAME, self::PAGE_NAME); + } + + /** + * Verifies that all necessary elements are visible. + */ + public function verifyElements(): void + { + $this->adminList->verifyVisibility(); + } +} diff --git a/src/lib/Behat/PageObject/DashboardPage.php b/src/lib/Behat/PageObject/DashboardPage.php index f6bd1b2388..6ee26653d7 100644 --- a/src/lib/Behat/PageObject/DashboardPage.php +++ b/src/lib/Behat/PageObject/DashboardPage.php @@ -14,7 +14,7 @@ class DashboardPage extends Page protected $route = '/admin/dashboard'; /** @var string Name by which Page is recognised */ - const PAGE_NAME = 'Dashboard'; + public const PAGE_NAME = 'Dashboard'; /** * Verifies that the Dashboard has the "Me" section. diff --git a/src/lib/Behat/PageObject/LoginPage.php b/src/lib/Behat/PageObject/LoginPage.php index 9c02468e04..70caf634b6 100644 --- a/src/lib/Behat/PageObject/LoginPage.php +++ b/src/lib/Behat/PageObject/LoginPage.php @@ -12,7 +12,7 @@ class LoginPage extends Page protected $route = '/admin/login'; /** @var string Name by which Page is recognised */ - const PAGE_NAME = 'Login'; + public const PAGE_NAME = 'Login'; protected $fields = ['username' => '#username', 'password' => '#password']; diff --git a/src/lib/Behat/PageObject/Page.php b/src/lib/Behat/PageObject/Page.php index ab6e24e24a..014cf5f05a 100644 --- a/src/lib/Behat/PageObject/Page.php +++ b/src/lib/Behat/PageObject/Page.php @@ -6,11 +6,11 @@ */ namespace EzSystems\EzPlatformAdminUi\Behat\PageObject; -use EzSystems\EzPlatformAdminUi\Behat\UtilityContext; +use EzSystems\EzPlatformAdminUi\Behat\Helper\UtilityContext; abstract class Page { - protected $defaultTimeout = 5; + protected $defaultTimeout = 50; /** @var string Route under which the Page is available */ protected $route; @@ -18,6 +18,9 @@ abstract class Page /** @var UtilityContext context for interactions with the page */ protected $context; + // @var UpperMenu + public $upperMenu; + public function __construct(UtilityContext $context) { $this->context = $context; @@ -59,9 +62,7 @@ public function verifyRoute(): void /** * Verifies that expected elements are present. */ - public function verifyElements(): void - { - } + abstract public function verifyElements(): void; /** * Gets the header text displayed in AdminUI. diff --git a/src/lib/Behat/PageObject/PageObjectFactory.php b/src/lib/Behat/PageObject/PageObjectFactory.php index 9de345c8bf..4874275945 100644 --- a/src/lib/Behat/PageObject/PageObjectFactory.php +++ b/src/lib/Behat/PageObject/PageObjectFactory.php @@ -6,8 +6,9 @@ */ namespace EzSystems\EzPlatformAdminUi\Behat\PageObject; -use EzSystems\EzPlatformAdminUi\Behat\UtilityContext; -use EzSystems\StudioUIBundle\Tests\Behat\PageObject\LandingPageEditorPage; +use EzSystems\EzPlatformAdminUi\Behat\Helper\UtilityContext; + +//use EzSystems\StudioUIBundle\Tests\Behat\PageObject\LandingPageEditorPage; class PageObjectFactory { @@ -16,10 +17,11 @@ class PageObjectFactory * * @param UtilityContext $context * @param string $pageName Name of the Page to creator + * @param string $parameter additional parameter for constructor, e.g. name of item * - * @return Page Page to interact with + * @return LoginPage|DashboardPage|ContentStructurePage|ContentTypeGroupsPage|UpdateItemPage to interact with */ - public static function createPage(UtilityContext $context, string $pageName): Page + public static function createPage(UtilityContext $context, string $pageName, ...$parameters): Page { switch ($pageName) { case LoginPage::PAGE_NAME: @@ -28,6 +30,12 @@ public static function createPage(UtilityContext $context, string $pageName): Pa return new DashboardPage($context); case ContentStructurePage::PAGE_NAME: return new ContentStructurePage($context); + case ContentTypeGroupsPage::PAGE_NAME: + return new ContentTypeGroupsPage($context); + case UpdateItemPage::PAGE_NAME: + return new UpdateItemPage($context); + case ContentTypeGroupPage::PAGE_NAME: + return new ContentTypeGroupPage($context, $parameters[0]); case LandingPageEditorPage::PAGE_NAME: return new LandingPageEditorPage($context); default: diff --git a/src/lib/Behat/PageObject/UpdateItemPage.php b/src/lib/Behat/PageObject/UpdateItemPage.php new file mode 100644 index 0000000000..e11b39dd24 --- /dev/null +++ b/src/lib/Behat/PageObject/UpdateItemPage.php @@ -0,0 +1,44 @@ +updateForm = ElementFactory::createElement($this->context, UpdateForm::ELEMENT_NAME); + $this->rightMenu = ElementFactory::createElement($this->context, RightMenu::ELEMENT_NAME); + } + + public function verifyElements(): void + { + $this->rightMenu->verifyVisibility(); + $this->updateForm->verifyVisibility(); + } +} From 79c5a923fc31e0248621559afdb8feff6fd1fea5 Mon Sep 17 00:00:00 2001 From: m-tyrala Date: Tue, 6 Feb 2018 15:02:03 +0100 Subject: [PATCH 2/4] EZP-28172 Behat Covering of Content Types - fixes after review --- .../BusinessContext/AdministrationContext.php | 54 ++++++++++--------- .../BusinessContext/AuthenticationContext.php | 2 +- .../BusinessContext/ContentViewContext.php | 4 +- .../BusinessContext/NavigationContext.php | 10 ++-- .../BusinessContext/RightMenuContext.php | 2 +- .../Behat/BusinessContext/UpdateContext.php | 2 +- src/lib/Behat/PageElement/AdminList.php | 22 ++++---- src/lib/Behat/PageElement/Breadcrumb.php | 8 +-- src/lib/Behat/PageElement/Dialog.php | 10 ++-- src/lib/Behat/PageElement/ElementFactory.php | 2 +- src/lib/Behat/PageElement/Notification.php | 8 +-- src/lib/Behat/PageElement/RightMenu.php | 2 +- src/lib/Behat/PageElement/UpdateForm.php | 6 ++- src/lib/Behat/PageElement/UpperMenu.php | 4 +- .../Behat/PageObject/ContentStructurePage.php | 4 +- src/lib/Behat/PageObject/LoginPage.php | 5 +- .../Behat/PageObject/PageObjectFactory.php | 5 +- 17 files changed, 84 insertions(+), 66 deletions(-) diff --git a/src/lib/Behat/BusinessContext/AdministrationContext.php b/src/lib/Behat/BusinessContext/AdministrationContext.php index f5e0fa5812..980db3b879 100644 --- a/src/lib/Behat/BusinessContext/AdministrationContext.php +++ b/src/lib/Behat/BusinessContext/AdministrationContext.php @@ -14,14 +14,18 @@ class AdministrationContext extends BusinessContext { - private $itemCreateMapping = ['Content Type Group' => ContentTypeGroupsPage::PAGE_NAME, - 'Content Type' => '', - 'Language' => '', - 'Role' => '', - 'Section' => '', - 'User' => '', ]; - private $emptyHeaderMapping = ['Content Type Groups' => 'Content Types count', - 'Sections' => 'Assigned Content items', ]; + private $itemCreateMapping = [ + 'Content Type Group' => ContentTypeGroupsPage::PAGE_NAME, + 'Content Type' => '', + 'Language' => '', + 'Role' => '', + 'Section' => '', + 'User' => '', + ]; + private $emptyHeaderMapping = [ + 'Content Type Groups' => 'Content Types count', + 'Sections' => 'Assigned Content items', + ]; /** * @Then I should see :pageName list @@ -53,12 +57,12 @@ public function iStartCreatingNew(string $newItemType): void * @Then there's :listElementName on :page list * @Then there's :listElementName on :parameter :page list */ - public function isElementOnTheList($listElementName, $page): void + public function isElementOnTheList(string $listElementName, string $page): void { - $actual = PageObjectFactory::createPage($this->utilityContext, $page) + $isElementOnTheList = PageObjectFactory::createPage($this->utilityContext, $page) ->adminList->isElementOnList($listElementName); - if (!$actual) { + if (!$isElementOnTheList) { throw new ElementNotFoundException( $this->utilityContext->getSession(), sprintf('Element "%s" is not on the %s list.', $listElementName, $page)); @@ -69,12 +73,12 @@ public function isElementOnTheList($listElementName, $page): void * @Then there's no :listElementName on :page list * @Then there's no :listElementName on :parameter :page list */ - public function isElementNotOnTheList($listElementName, $page, $parameter = null): void + public function isElementNotOnTheList(string $listElementName, string $page, string $parameter = null): void { - $actual = PageObjectFactory::createPage($this->utilityContext, $page, $parameter) + $isElementOnTheList = PageObjectFactory::createPage($this->utilityContext, $page, $parameter) ->adminList->isElementOnList($listElementName); - if ($actual) { + if ($isElementOnTheList) { throw new ElementNotFoundException( $this->utilityContext->getSession(), sprintf('Element "%s" is on the %s list.', $listElementName, $page)); @@ -88,9 +92,9 @@ public function isElementNotOnTheList($listElementName, $page, $parameter = null * @param $page * @param $shouldBeEmpty */ - private function verifyContentsStatus($itemName, $page, $shouldBeEmpty): void + private function verifyContentsStatus(string $itemName, string $page, string $shouldBeEmpty): void { - $isEmpty = '0'; + $emptyContainerCellValue = '0'; $contentsCount = PageObjectFactory::createPage($this->utilityContext, $page) ->adminList->getListItemAttribute($itemName, $this->emptyHeaderMapping[$page]); @@ -100,7 +104,7 @@ private function verifyContentsStatus($itemName, $page, $shouldBeEmpty): void $msg = ' non'; } - if (($contentsCount !== $isEmpty) === $shouldBeEmpty) { + if (($contentsCount !== $emptyContainerCellValue) === $shouldBeEmpty) { throw new ElementNotFoundException( $this->utilityContext->getSession(), sprintf('No%s empty %s on the %s list.', $msg, $itemName, $page)); @@ -110,7 +114,7 @@ private function verifyContentsStatus($itemName, $page, $shouldBeEmpty): void /** * @Given there's empty :itemName on :page list */ - public function isEmptyElementOnTheList($itemName, $page): void + public function isEmptyElementOnTheList(string $itemName, string $page): void { $this->verifyContentsStatus($itemName, $page, true); } @@ -118,7 +122,7 @@ public function isEmptyElementOnTheList($itemName, $page): void /** * @Given there's non-empty :itemName on :page list */ - public function isNonEmptyElementOnTheList($itemName, $page): void + public function isNonEmptyElementOnTheList(string $itemName, string $page): void { $this->verifyContentsStatus($itemName, $page, false); } @@ -126,12 +130,12 @@ public function isNonEmptyElementOnTheList($itemName, $page): void /** * @Then :itemType :itemName cannot be selected */ - public function itemCannotBeSelected($itemType, $itemName): void + public function itemCannotBeSelected(string $itemType, string $itemName): void { - $checkboxState = PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType]) + $isListElementSelectable = PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType]) ->adminList->isListElementSelectable($itemName); - if ($checkboxState) { + if ($isListElementSelectable) { throw new \Exception(sprintf('Element %s shoudn\'t be selectable.', $itemName)); } } @@ -139,7 +143,7 @@ public function itemCannotBeSelected($itemType, $itemName): void /** * @Given I go to :itemName :itemType page */ - public function iGoToListItem($itemName, $itemType) + public function iGoToListItem(string $itemName, string $itemType) { PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType]) ->adminList->clickListElement($itemName); @@ -148,7 +152,7 @@ public function iGoToListItem($itemName, $itemType) /** * @When I start editing :itemType :itemName */ - public function iStartEditingItem($itemType, $itemName) + public function iStartEditingItem(string $itemType, string $itemName) { PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType]) ->adminList->clickEditButton($itemName); @@ -157,7 +161,7 @@ public function iStartEditingItem($itemType, $itemName) /** * @When I delete :itemType :itemName */ - public function iDeleteItem($itemType, $itemName) + public function iDeleteItem(string $itemType, string $itemName) { $contentTypeGroups = PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType]); $contentTypeGroups->adminList->selectListElement($itemName); diff --git a/src/lib/Behat/BusinessContext/AuthenticationContext.php b/src/lib/Behat/BusinessContext/AuthenticationContext.php index ee8736cae2..7fbd514fa1 100644 --- a/src/lib/Behat/BusinessContext/AuthenticationContext.php +++ b/src/lib/Behat/BusinessContext/AuthenticationContext.php @@ -34,7 +34,7 @@ public function iLoginAs(string $username, string $password): void * * @throws \OutOfBoundsException when username is not recognised */ - public function iAmLoggedAs(string $username) + public function iAmLoggedAs(string $username): void { $loginPage = PageObjectFactory::createPage($this->utilityContext, LoginPage::PAGE_NAME); $loginPage->open(); diff --git a/src/lib/Behat/BusinessContext/ContentViewContext.php b/src/lib/Behat/BusinessContext/ContentViewContext.php index 6bab0b39a2..d347f6c237 100644 --- a/src/lib/Behat/BusinessContext/ContentViewContext.php +++ b/src/lib/Behat/BusinessContext/ContentViewContext.php @@ -15,7 +15,7 @@ class ContentViewContext extends BusinessContext /** * @Given I start creating a new Landing Page :name */ - public function startCreatingNewLandingPage($name) + public function startCreatingNewLandingPage(string $name): void { $contentStructurePage = PageObjectFactory::createPage($this->utilityContext, ContentStructurePage::PAGE_NAME); $contentStructurePage->createLandingPage($name, 'Test Desc'); @@ -24,7 +24,7 @@ public function startCreatingNewLandingPage($name) /** * @Then I (should) see :title title/topic */ - public function iSeeTitle($title) + public function iSeeTitle(string $title): void { $contentStructurePage = PageObjectFactory::createPage($this->utilityContext, ContentStructurePage::PAGE_NAME); Assert::assertEquals($title, $contentStructurePage->getPageHeaderTitle()); diff --git a/src/lib/Behat/BusinessContext/NavigationContext.php b/src/lib/Behat/BusinessContext/NavigationContext.php index c90e05ae12..c2eea85dd8 100644 --- a/src/lib/Behat/BusinessContext/NavigationContext.php +++ b/src/lib/Behat/BusinessContext/NavigationContext.php @@ -16,7 +16,7 @@ class NavigationContext extends BusinessContext /** * @Given I open :pageName page */ - public function openPage($pageName): void + public function openPage(string $pageName): void { $page = PageObjectFactory::createPage($this->utilityContext, $pageName); $page->open(); @@ -25,7 +25,7 @@ public function openPage($pageName): void /** * @Given I try to open :pageName page */ - public function tryToOpenPage($pageName): void + public function tryToOpenPage(string $pageName): void { $page = PageObjectFactory::createPage($this->utilityContext, $pageName); $page->open(false); @@ -35,7 +35,7 @@ public function tryToOpenPage($pageName): void * @Then I should be on :pageName page * @Then I should be on :pageName :itemName page */ - public function iAmOnPage($pageName, $itemName = null): void + public function iAmOnPage(string $pageName, string $itemName = null): void { $page = PageObjectFactory::createPage($this->utilityContext, $pageName, $itemName); $page->verifyIsLoaded(); @@ -45,7 +45,7 @@ public function iAmOnPage($pageName, $itemName = null): void * @Then I go to :tab tab * @Then I go to :subTab in :tab tab */ - public function iGoToTab($tabName, $subTab = null): void + public function iGoToTab(string $tabName, string $subTab = null): void { $upperMenu = ElementFactory::createElement($this->utilityContext, UpperMenu::ELEMENT_NAME); $upperMenu->goToTab($tabName); @@ -58,7 +58,7 @@ public function iGoToTab($tabName, $subTab = null): void /** * @When I click on :element on breadcrumb */ - public function iClickOnBreadcrumbLink($element) + public function iClickOnBreadcrumbLink(string $element): void { $breadcrumb = ElementFactory::createElement($this->utilityContext, Breadcrumb::ELEMENT_NAME); $breadcrumb->verifyVisibility(); diff --git a/src/lib/Behat/BusinessContext/RightMenuContext.php b/src/lib/Behat/BusinessContext/RightMenuContext.php index b6f5cd2d04..cf2cdd03a9 100644 --- a/src/lib/Behat/BusinessContext/RightMenuContext.php +++ b/src/lib/Behat/BusinessContext/RightMenuContext.php @@ -16,7 +16,7 @@ class RightMenuContext extends BusinessContext * * @param string $button Text of the element to click */ - public function clickEditActionBar($button) + public function clickEditActionBar(string $button): void { $rightMenu = new RightMenu($this->utilityContext); $rightMenu->clickButton($button); diff --git a/src/lib/Behat/BusinessContext/UpdateContext.php b/src/lib/Behat/BusinessContext/UpdateContext.php index 150d0713e0..47f54cadd7 100644 --- a/src/lib/Behat/BusinessContext/UpdateContext.php +++ b/src/lib/Behat/BusinessContext/UpdateContext.php @@ -15,7 +15,7 @@ class UpdateContext extends BusinessContext * @When I set :field to :value * @When I set :field as empty */ - public function fillFieldWithValue($field, $value = '') + public function fillFieldWithValue(string $field, string $value = ''): void { PageObjectFactory::createPage($this->utilityContext, UpdateItemPage::PAGE_NAME) ->updateForm->fillFIeldWithValue($field, $value); diff --git a/src/lib/Behat/PageElement/AdminList.php b/src/lib/Behat/PageElement/AdminList.php index 5497dd91c1..d88ea40ff7 100644 --- a/src/lib/Behat/PageElement/AdminList.php +++ b/src/lib/Behat/PageElement/AdminList.php @@ -11,14 +11,16 @@ class AdminList extends Element { - protected $fields = ['list' => 'form', - 'plusButton' => '.ez-icon-create', - 'trashButton' => '.ez-icon-trash', - 'editButton' => 'tr:nth-child(%s) a[title=Edit]', - 'listHeader' => '.ez-table-header__headline', - 'tableHeader' => 'th', - 'listElementLink' => '.ez-checkbox-cell+ td a', - 'tableCell' => 'tr:nth-child(%s) td:nth-child(%s)', ]; + protected $fields = [ + 'list' => 'form', + 'plusButton' => '.ez-icon-create', + 'trashButton' => '.ez-icon-trash', + 'editButton' => 'tr:nth-child(%s) a[title=Edit]', + 'listHeader' => '.ez-table-header__headline', + 'tableHeader' => 'th', + 'listElementLink' => '.ez-checkbox-cell+ td a', + 'tableCell' => 'tr:nth-child(%s) td:nth-child(%s)', + ]; /** @var string Name by which Element is recognised */ public const ELEMENT_NAME = 'Admin List'; @@ -32,7 +34,9 @@ public function __construct(UtilityContext $context, string $listHeader) private function verifyProperList(): void { - if ($this->listHeader !== $this->context->findElement($this->fields['listHeader'], $this->defaultTimeout)->getText()) { + $actualHeader = $this->context->findElement($this->fields['listHeader'], $this->defaultTimeout)->getText(); + + if ($this->listHeader !== $actualHeader) { throw new ElementNotFoundException($this->context->getSession(), 'table header', $this->fields['listHeader']); } } diff --git a/src/lib/Behat/PageElement/Breadcrumb.php b/src/lib/Behat/PageElement/Breadcrumb.php index e2ff4a6dd2..e85a64f866 100644 --- a/src/lib/Behat/PageElement/Breadcrumb.php +++ b/src/lib/Behat/PageElement/Breadcrumb.php @@ -8,8 +8,10 @@ class Breadcrumb extends Element { - protected $fields = ['breadcrumbItem' => '.breadcrumb-item', - 'breadcrumbItemLink' => '.breadcrumb-item a', ]; + protected $fields = [ + 'breadcrumbItem' => '.breadcrumb-item', + 'breadcrumbItemLink' => '.breadcrumb-item a', + ]; /** @var string Name by which Element is recognised */ public const ELEMENT_NAME = 'Breadcrumb'; @@ -18,7 +20,7 @@ public function verifyVisibility(): void $this->context->waitUntilElementIsVisible($this->fields['breadcrumbItem']); } - public function clickBreadcrumbItem(string $itemName) + public function clickBreadcrumbItem(string $itemName): void { $this->context->getElementByText($itemName, $this->fields['breadcrumbItemLink'])->click(); } diff --git a/src/lib/Behat/PageElement/Dialog.php b/src/lib/Behat/PageElement/Dialog.php index a390806be4..c0071e6841 100644 --- a/src/lib/Behat/PageElement/Dialog.php +++ b/src/lib/Behat/PageElement/Dialog.php @@ -8,17 +8,19 @@ class Dialog extends Element { - protected $fields = ['confirm' => '.btn--trigger', - 'decline' => '.btn--no', ]; + protected $fields = [ + 'confirm' => '.btn--trigger', + 'decline' => '.btn--no', + ]; /** @var string Name by which Element is recognised */ public const ELEMENT_NAME = 'Dialog'; - public function confirm() + public function confirm(): void { $this->context->findElement($this->fields['confirm'])->click(); } - public function decline() + public function decline(): void { $this->context->findElement($this->fields['decline'])->click(); } diff --git a/src/lib/Behat/PageElement/ElementFactory.php b/src/lib/Behat/PageElement/ElementFactory.php index 6cf15f6edd..e19b7ba1c1 100644 --- a/src/lib/Behat/PageElement/ElementFactory.php +++ b/src/lib/Behat/PageElement/ElementFactory.php @@ -18,7 +18,7 @@ class ElementFactory * * @return AdminList|Dialog|RightMenu|UpperMenu|UpdateForm|Breadcrumb|Notification Element to interact with */ - public static function createElement(UtilityContext $context, string $elementName, ...$parameters): Element + public static function createElement(UtilityContext $context, string $elementName, ?string ...$parameters): Element { switch ($elementName) { case AdminList::ELEMENT_NAME: diff --git a/src/lib/Behat/PageElement/Notification.php b/src/lib/Behat/PageElement/Notification.php index 9c5df7b195..ce0f325895 100644 --- a/src/lib/Behat/PageElement/Notification.php +++ b/src/lib/Behat/PageElement/Notification.php @@ -8,8 +8,10 @@ class Notification extends Element { - protected $fields = ['alert' => '.alert', - 'successAlert' => '.alert-success', ]; + protected $fields = [ + 'alert' => '.alert', + 'successAlert' => '.alert-success', + ]; /** @var string Name by which Element is recognised */ public const ELEMENT_NAME = 'Notification'; @@ -18,7 +20,7 @@ public function verifyVisibility(): void $this->context->waitUntilElementIsVisible($this->fields['alert'], $this->defaultTimeout); } - public function verifyAlertSuccess() + public function verifyAlertSuccess(): void { $this->context->assertElementOnPage($this->fields['successAlert']); } diff --git a/src/lib/Behat/PageElement/RightMenu.php b/src/lib/Behat/PageElement/RightMenu.php index b316f4de91..3b7d6fa3fe 100644 --- a/src/lib/Behat/PageElement/RightMenu.php +++ b/src/lib/Behat/PageElement/RightMenu.php @@ -16,7 +16,7 @@ class RightMenu extends Element * * @param $buttonName */ - public function clickButton($buttonName) + public function clickButton(string $buttonName): void { $this->context->getElementByText($buttonName, '.ez-context-menu .btn-block')->click(); } diff --git a/src/lib/Behat/PageElement/UpdateForm.php b/src/lib/Behat/PageElement/UpdateForm.php index 8fe618f16d..158aea5ea1 100644 --- a/src/lib/Behat/PageElement/UpdateForm.php +++ b/src/lib/Behat/PageElement/UpdateForm.php @@ -8,8 +8,10 @@ class UpdateForm extends Element { - protected $fields = ['formElement' => '.form-group', - 'mainFormSection' => '.px-5:nth-child(1) .card-body', ]; + protected $fields = [ + 'formElement' => '.form-group', + 'mainFormSection' => '.px-5:nth-child(1) .card-body', + ]; /** @var string Name by which Element is recognised */ public const ELEMENT_NAME = 'Admin Update Form'; diff --git a/src/lib/Behat/PageElement/UpperMenu.php b/src/lib/Behat/PageElement/UpperMenu.php index 13bda59c24..782bd6bc52 100644 --- a/src/lib/Behat/PageElement/UpperMenu.php +++ b/src/lib/Behat/PageElement/UpperMenu.php @@ -16,7 +16,7 @@ class UpperMenu extends Element * * @param $tabName */ - public function goToTab($tabName) + public function goToTab(string $tabName): void { $this->context->getElementByText($tabName, '.nav-link')->click(); } @@ -26,7 +26,7 @@ public function goToTab($tabName) * * @param $tabName */ - public function goToSubTab($tabName) + public function goToSubTab(string $tabName): void { $this->context->getElementByText($tabName, '.navbar-expand-lg .nav-link')->click(); } diff --git a/src/lib/Behat/PageObject/ContentStructurePage.php b/src/lib/Behat/PageObject/ContentStructurePage.php index ee47d19f4d..b367ea5fa1 100644 --- a/src/lib/Behat/PageObject/ContentStructurePage.php +++ b/src/lib/Behat/PageObject/ContentStructurePage.php @@ -26,7 +26,7 @@ public function __construct(UtilityContext $context) $this->rightMenu = new RightMenu($this->context); } - public function createLandingPage($name, $description) + public function createLandingPage(string $name, string $description): void { $this->startCreatingContent('Landing page'); $this->context->getSession()->getPage()->findField('Title')->setValue($name); @@ -38,7 +38,7 @@ public function createLandingPage($name, $description) * * @param $contentType */ - public function startCreatingContent($contentType) + public function startCreatingContent(string $contentType): void { $this->rightMenu->clickButton('Create'); $this->context->getElementByText($contentType, '.form-check-label')->click(); diff --git a/src/lib/Behat/PageObject/LoginPage.php b/src/lib/Behat/PageObject/LoginPage.php index 70caf634b6..a4b75daa1e 100644 --- a/src/lib/Behat/PageObject/LoginPage.php +++ b/src/lib/Behat/PageObject/LoginPage.php @@ -14,7 +14,10 @@ class LoginPage extends Page /** @var string Name by which Page is recognised */ public const PAGE_NAME = 'Login'; - protected $fields = ['username' => '#username', 'password' => '#password']; + protected $fields = [ + 'username' => '#username', + 'password' => '#password', + ]; /** * Performs login action. diff --git a/src/lib/Behat/PageObject/PageObjectFactory.php b/src/lib/Behat/PageObject/PageObjectFactory.php index 4874275945..f0a90f8e6e 100644 --- a/src/lib/Behat/PageObject/PageObjectFactory.php +++ b/src/lib/Behat/PageObject/PageObjectFactory.php @@ -7,8 +7,7 @@ namespace EzSystems\EzPlatformAdminUi\Behat\PageObject; use EzSystems\EzPlatformAdminUi\Behat\Helper\UtilityContext; - -//use EzSystems\StudioUIBundle\Tests\Behat\PageObject\LandingPageEditorPage; +use EzSystems\StudioUIBundle\Tests\Behat\PageObject\LandingPageEditorPage; class PageObjectFactory { @@ -21,7 +20,7 @@ class PageObjectFactory * * @return LoginPage|DashboardPage|ContentStructurePage|ContentTypeGroupsPage|UpdateItemPage to interact with */ - public static function createPage(UtilityContext $context, string $pageName, ...$parameters): Page + public static function createPage(UtilityContext $context, string $pageName, ?string ...$parameters): Page { switch ($pageName) { case LoginPage::PAGE_NAME: From e845397b13e301f969788907658da87f76f47a8e Mon Sep 17 00:00:00 2001 From: m-tyrala Date: Tue, 6 Feb 2018 15:10:10 +0100 Subject: [PATCH 3/4] EZP-28172 Behat Covering of Content Types - fixes after review --- src/lib/Behat/BusinessContext/AdministrationContext.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/Behat/BusinessContext/AdministrationContext.php b/src/lib/Behat/BusinessContext/AdministrationContext.php index 980db3b879..ac25b34278 100644 --- a/src/lib/Behat/BusinessContext/AdministrationContext.php +++ b/src/lib/Behat/BusinessContext/AdministrationContext.php @@ -143,7 +143,7 @@ public function itemCannotBeSelected(string $itemType, string $itemName): void /** * @Given I go to :itemName :itemType page */ - public function iGoToListItem(string $itemName, string $itemType) + public function iGoToListItem(string $itemName, string $itemType): void { PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType]) ->adminList->clickListElement($itemName); @@ -152,7 +152,7 @@ public function iGoToListItem(string $itemName, string $itemType) /** * @When I start editing :itemType :itemName */ - public function iStartEditingItem(string $itemType, string $itemName) + public function iStartEditingItem(string $itemType, string $itemName): void { PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType]) ->adminList->clickEditButton($itemName); @@ -161,7 +161,7 @@ public function iStartEditingItem(string $itemType, string $itemName) /** * @When I delete :itemType :itemName */ - public function iDeleteItem(string $itemType, string $itemName) + public function iDeleteItem(string $itemType, string $itemName): void { $contentTypeGroups = PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType]); $contentTypeGroups->adminList->selectListElement($itemName); From 96133780ad7cf923e565f068dc10f04aed37f2b0 Mon Sep 17 00:00:00 2001 From: m-tyrala Date: Tue, 6 Feb 2018 22:21:21 +0100 Subject: [PATCH 4/4] EZP-28172 Behat Covering of Content Types - fixes after review --- .../BusinessContext/AdministrationContext.php | 17 ++++++++++------- .../BusinessContext/AuthenticationContext.php | 1 + .../Behat/BusinessContext/NavigationContext.php | 1 + .../BusinessContext/NotificationContext.php | 1 + .../Behat/BusinessContext/RightMenuContext.php | 1 + src/lib/Behat/BusinessContext/UpdateContext.php | 1 + src/lib/Behat/PageElement/AdminList.php | 2 ++ src/lib/Behat/PageElement/Breadcrumb.php | 1 + src/lib/Behat/PageElement/Dialog.php | 1 + src/lib/Behat/PageElement/Element.php | 1 + src/lib/Behat/PageElement/ElementFactory.php | 2 +- src/lib/Behat/PageElement/Notification.php | 1 + src/lib/Behat/PageElement/RightMenu.php | 3 ++- src/lib/Behat/PageElement/UpdateForm.php | 1 + src/lib/Behat/PageElement/UpperMenu.php | 1 + 15 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/lib/Behat/BusinessContext/AdministrationContext.php b/src/lib/Behat/BusinessContext/AdministrationContext.php index ac25b34278..a554fedd35 100644 --- a/src/lib/Behat/BusinessContext/AdministrationContext.php +++ b/src/lib/Behat/BusinessContext/AdministrationContext.php @@ -12,6 +12,7 @@ use EzSystems\EzPlatformAdminUi\Behat\PageObject\ContentTypeGroupsPage; use EzSystems\EzPlatformAdminUi\Behat\PageObject\PageObjectFactory; +/** Context for common actions (creating, editing, deleting, etc) in Admin pages (Content Types, Languages, etc.) */ class AdministrationContext extends BusinessContext { private $itemCreateMapping = [ @@ -46,8 +47,8 @@ public function iSeeList(string $pageName, string $parameter = null): void */ public function iStartCreatingNew(string $newItemType): void { - if (!\array_key_exists($newItemType, $this->itemCreateMapping)) { - throw new \InvalidArgumentException(sprintf('Unrecognised item type name: %s', $newItemType)); + if (!array_key_exists($newItemType, $this->itemCreateMapping)) { + throw new \InvalidArgumentException(sprintf('Unrecognized item type name: %s', $newItemType)); } PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$newItemType]) ->adminList->clickPlusButton(); @@ -65,7 +66,8 @@ public function isElementOnTheList(string $listElementName, string $page): void if (!$isElementOnTheList) { throw new ElementNotFoundException( $this->utilityContext->getSession(), - sprintf('Element "%s" is not on the %s list.', $listElementName, $page)); + sprintf('Element "%s" is not on the %s list.', $listElementName, $page) + ); } } @@ -81,16 +83,17 @@ public function isElementNotOnTheList(string $listElementName, string $page, str if ($isElementOnTheList) { throw new ElementNotFoundException( $this->utilityContext->getSession(), - sprintf('Element "%s" is on the %s list.', $listElementName, $page)); + sprintf('Element "%s" is on the %s list.', $listElementName, $page) + ); } } /** * Check if item is or is not empty, according to $empty param. * - * @param $itemName - * @param $page - * @param $shouldBeEmpty + * @param string $itemName + * @param string $page + * @param string $shouldBeEmpty */ private function verifyContentsStatus(string $itemName, string $page, string $shouldBeEmpty): void { diff --git a/src/lib/Behat/BusinessContext/AuthenticationContext.php b/src/lib/Behat/BusinessContext/AuthenticationContext.php index 7fbd514fa1..385fc4b9dc 100644 --- a/src/lib/Behat/BusinessContext/AuthenticationContext.php +++ b/src/lib/Behat/BusinessContext/AuthenticationContext.php @@ -10,6 +10,7 @@ use EzSystems\EzPlatformAdminUi\Behat\PageObject\PageObjectFactory; use OutOfBoundsException; +/** Context for authentication actions */ class AuthenticationContext extends BusinessContext { /** @var array Dictionary of known user logins and their passwords */ diff --git a/src/lib/Behat/BusinessContext/NavigationContext.php b/src/lib/Behat/BusinessContext/NavigationContext.php index c2eea85dd8..dcbe5e3e4f 100644 --- a/src/lib/Behat/BusinessContext/NavigationContext.php +++ b/src/lib/Behat/BusinessContext/NavigationContext.php @@ -11,6 +11,7 @@ use EzSystems\EzPlatformAdminUi\Behat\PageElement\UpperMenu; use EzSystems\EzPlatformAdminUi\Behat\PageObject\PageObjectFactory; +/** Context for general navigation actions */ class NavigationContext extends BusinessContext { /** diff --git a/src/lib/Behat/BusinessContext/NotificationContext.php b/src/lib/Behat/BusinessContext/NotificationContext.php index afc9d0f6a5..b2adeb72ae 100644 --- a/src/lib/Behat/BusinessContext/NotificationContext.php +++ b/src/lib/Behat/BusinessContext/NotificationContext.php @@ -10,6 +10,7 @@ use EzSystems\EzPlatformAdminUi\Behat\PageElement\Notification; use PHPUnit\Framework\Assert; +/** Context for actions on notifications */ class NotificationContext extends BusinessContext { /** diff --git a/src/lib/Behat/BusinessContext/RightMenuContext.php b/src/lib/Behat/BusinessContext/RightMenuContext.php index cf2cdd03a9..e22f8b72bd 100644 --- a/src/lib/Behat/BusinessContext/RightMenuContext.php +++ b/src/lib/Behat/BusinessContext/RightMenuContext.php @@ -8,6 +8,7 @@ use EzSystems\EzPlatformAdminUi\Behat\PageElement\RightMenu; +/** Context for actions on right menu */ class RightMenuContext extends BusinessContext { /** diff --git a/src/lib/Behat/BusinessContext/UpdateContext.php b/src/lib/Behat/BusinessContext/UpdateContext.php index 47f54cadd7..86cf1e2777 100644 --- a/src/lib/Behat/BusinessContext/UpdateContext.php +++ b/src/lib/Behat/BusinessContext/UpdateContext.php @@ -9,6 +9,7 @@ use EzSystems\EzPlatformAdminUi\Behat\PageObject\PageObjectFactory; use EzSystems\EzPlatformAdminUi\Behat\PageObject\UpdateItemPage; +/** Context for common actions for creating and updating */ class UpdateContext extends BusinessContext { /** diff --git a/src/lib/Behat/PageElement/AdminList.php b/src/lib/Behat/PageElement/AdminList.php index d88ea40ff7..1fbbcf37df 100644 --- a/src/lib/Behat/PageElement/AdminList.php +++ b/src/lib/Behat/PageElement/AdminList.php @@ -9,6 +9,7 @@ use Behat\Mink\Exception\ElementNotFoundException; use EzSystems\EzPlatformAdminUi\Behat\Helper\UtilityContext; +/** Element that describes list-table structure that repeats in every Admin pages */ class AdminList extends Element { protected $fields = [ @@ -24,6 +25,7 @@ class AdminList extends Element /** @var string Name by which Element is recognised */ public const ELEMENT_NAME = 'Admin List'; + /** @var string list table title placed in the blue bar */ protected $listHeader; public function __construct(UtilityContext $context, string $listHeader) diff --git a/src/lib/Behat/PageElement/Breadcrumb.php b/src/lib/Behat/PageElement/Breadcrumb.php index e85a64f866..00281daf51 100644 --- a/src/lib/Behat/PageElement/Breadcrumb.php +++ b/src/lib/Behat/PageElement/Breadcrumb.php @@ -6,6 +6,7 @@ */ namespace EzSystems\EzPlatformAdminUi\Behat\PageElement; +/** Element that describes breadcrumb */ class Breadcrumb extends Element { protected $fields = [ diff --git a/src/lib/Behat/PageElement/Dialog.php b/src/lib/Behat/PageElement/Dialog.php index c0071e6841..bd167c88dd 100644 --- a/src/lib/Behat/PageElement/Dialog.php +++ b/src/lib/Behat/PageElement/Dialog.php @@ -6,6 +6,7 @@ */ namespace EzSystems\EzPlatformAdminUi\Behat\PageElement; +/** Element that describes dialog popup */ class Dialog extends Element { protected $fields = [ diff --git a/src/lib/Behat/PageElement/Element.php b/src/lib/Behat/PageElement/Element.php index 47aace5b4f..bab496dce7 100644 --- a/src/lib/Behat/PageElement/Element.php +++ b/src/lib/Behat/PageElement/Element.php @@ -8,6 +8,7 @@ use EzSystems\EzPlatformAdminUi\Behat\Helper\UtilityContext; +/** Abstract for pages elements */ abstract class Element { /** @var int */ diff --git a/src/lib/Behat/PageElement/ElementFactory.php b/src/lib/Behat/PageElement/ElementFactory.php index e19b7ba1c1..3f8de11141 100644 --- a/src/lib/Behat/PageElement/ElementFactory.php +++ b/src/lib/Behat/PageElement/ElementFactory.php @@ -36,7 +36,7 @@ public static function createElement(UtilityContext $context, string $elementNam case Notification::ELEMENT_NAME: return new Notification($context); default: - throw new \InvalidArgumentException(sprintf('Unrecognised element name: %s', $elementName)); + throw new \InvalidArgumentException(sprintf('Unrecognized element name: %s', $elementName)); } } } diff --git a/src/lib/Behat/PageElement/Notification.php b/src/lib/Behat/PageElement/Notification.php index ce0f325895..9da90ad167 100644 --- a/src/lib/Behat/PageElement/Notification.php +++ b/src/lib/Behat/PageElement/Notification.php @@ -6,6 +6,7 @@ */ namespace EzSystems\EzPlatformAdminUi\Behat\PageElement; +/** Element that describes user notification bar, that appears on the bottom of the screen */ class Notification extends Element { protected $fields = [ diff --git a/src/lib/Behat/PageElement/RightMenu.php b/src/lib/Behat/PageElement/RightMenu.php index 3b7d6fa3fe..018702687b 100644 --- a/src/lib/Behat/PageElement/RightMenu.php +++ b/src/lib/Behat/PageElement/RightMenu.php @@ -6,13 +6,14 @@ */ namespace EzSystems\EzPlatformAdminUi\Behat\PageElement; +/** Element that describes right action menu (Create, Preview, Publish etc.) */ class RightMenu extends Element { /** @var string Name by which Element is recognised */ public const ELEMENT_NAME = 'Right Menu'; /** - * Clicks a button on the right menu (Create, Preview, Publish etc.). + * Clicks a button on the right menu. * * @param $buttonName */ diff --git a/src/lib/Behat/PageElement/UpdateForm.php b/src/lib/Behat/PageElement/UpdateForm.php index 158aea5ea1..2dbd805eb6 100644 --- a/src/lib/Behat/PageElement/UpdateForm.php +++ b/src/lib/Behat/PageElement/UpdateForm.php @@ -6,6 +6,7 @@ */ namespace EzSystems\EzPlatformAdminUi\Behat\PageElement; +/** Element that describes structures in all update forms */ class UpdateForm extends Element { protected $fields = [ diff --git a/src/lib/Behat/PageElement/UpperMenu.php b/src/lib/Behat/PageElement/UpperMenu.php index 782bd6bc52..d3e3d3817a 100644 --- a/src/lib/Behat/PageElement/UpperMenu.php +++ b/src/lib/Behat/PageElement/UpperMenu.php @@ -6,6 +6,7 @@ */ namespace EzSystems\EzPlatformAdminUi\Behat\PageElement; +/** Element that describes upper menu (Content, Admin, Page and theirs children) */ class UpperMenu extends Element { /** @var string Name by which Element is recognised */