Skip to content

Commit

Permalink
Merge pull request #1020 from ezsystems/EZP-30668-move-core-to-behatb…
Browse files Browse the repository at this point in the history
…undle

EZP-30668: move core tests classes from AdminUI to BehatBundle
  • Loading branch information
lserwatka authored Jul 5, 2019
2 parents 1dc7f1d + 108bb9a commit ba2d29d
Show file tree
Hide file tree
Showing 116 changed files with 423 additions and 1,580 deletions.
12 changes: 6 additions & 6 deletions behat_suites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ adminui:
filters:
tags: "@common"
contexts:
- EzSystems\EzPlatformAdminUi\Behat\Helper\UtilityContext
- EzSystems\EzPlatformAdminUi\Behat\Helper\Hooks
- EzSystems\Behat\Browser\Context\BrowserContext
- EzSystems\Behat\Browser\Context\Hooks
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\AuthenticationContext
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\NavigationContext
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\AdministrationContext
Expand Down Expand Up @@ -42,8 +42,8 @@ adminui:
filters:
tags: "@common"
contexts:
- EzSystems\EzPlatformAdminUi\Behat\Helper\UtilityContext
- EzSystems\EzPlatformAdminUi\Behat\Helper\Hooks
- EzSystems\Behat\Browser\Context\BrowserContext
- EzSystems\Behat\Browser\Context\Hooks
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\AuthenticationContext
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\NavigationContext
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\ContentViewContext
Expand All @@ -61,8 +61,8 @@ adminui:
filters:
tags: "@common"
contexts:
- EzSystems\EzPlatformAdminUi\Behat\Helper\UtilityContext
- EzSystems\EzPlatformAdminUi\Behat\Helper\Hooks
- EzSystems\Behat\Browser\Context\BrowserContext
- EzSystems\Behat\Browser\Context\Hooks
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\AuthenticationContext
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\NavigationContext
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\ContentViewContext
Expand Down
18 changes: 9 additions & 9 deletions src/lib/Behat/BusinessContext/AdminUpdateContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
namespace EzSystems\EzPlatformAdminUi\Behat\BusinessContext;

use Behat\Gherkin\Node\TableNode;
use EzSystems\EzPlatformAdminUi\Behat\PageElement\ElementFactory;
use EzSystems\Behat\Browser\Factory\ElementFactory;
use EzSystems\EzPlatformAdminUi\Behat\PageElement\Notification;
use EzSystems\EzPlatformAdminUi\Behat\PageObject\PageObjectFactory;
use EzSystems\Behat\Browser\Factory\PageObjectFactory;
use EzSystems\EzPlatformAdminUi\Behat\PageObject\AdminUpdateItemPage;

/** Context for common actions for creating and updating */
Expand All @@ -20,7 +20,7 @@ class AdminUpdateContext extends BusinessContext
*/
public function iSetFields(TableNode $table): void
{
$updateItemPage = PageObjectFactory::createPage($this->utilityContext, AdminUpdateItemPage::PAGE_NAME);
$updateItemPage = PageObjectFactory::createPage($this->browserContext, AdminUpdateItemPage::PAGE_NAME);
$hash = $table->getHash();
foreach ($hash as $row) {
$updateItemPage->adminUpdateForm->fillFieldWithValue($row['label'], $row['value']);
Expand All @@ -32,7 +32,7 @@ public function iSetFields(TableNode $table): void
*/
public function verifyFieldsAreSet(TableNode $table): void
{
$updateItemPage = PageObjectFactory::createPage($this->utilityContext, AdminUpdateItemPage::PAGE_NAME);
$updateItemPage = PageObjectFactory::createPage($this->browserContext, AdminUpdateItemPage::PAGE_NAME);
$hash = $table->getHash();
foreach ($hash as $row) {
$updateItemPage->adminUpdateForm->verifyFieldHasValue($row['label'], $row['value']);
Expand All @@ -44,11 +44,11 @@ public function verifyFieldsAreSet(TableNode $table): void
*/
public function iAddField(string $fieldName): void
{
$updateItemPage = PageObjectFactory::createPage($this->utilityContext, AdminUpdateItemPage::PAGE_NAME);
$updateItemPage = PageObjectFactory::createPage($this->browserContext, AdminUpdateItemPage::PAGE_NAME);
$updateItemPage->adminUpdateForm->selectFieldDefinition($fieldName);
$updateItemPage->adminUpdateForm->clickAddFieldDefinition();
$updateItemPage->adminUpdateForm->verifyNewFieldDefinitionFormExists($fieldName);
$notification = ElementFactory::createElement($this->utilityContext, Notification::ELEMENT_NAME);
$notification = ElementFactory::createElement($this->browserContext, Notification::ELEMENT_NAME);
$notification->verifyVisibility();
$notification->verifyAlertSuccess();
$notification->closeAlert();
Expand All @@ -59,7 +59,7 @@ public function iAddField(string $fieldName): void
*/
public function iSetFieldInContainer(string $field, string $containerName, string $value): void
{
$updateItemPage = PageObjectFactory::createPage($this->utilityContext, AdminUpdateItemPage::PAGE_NAME);
$updateItemPage = PageObjectFactory::createPage($this->browserContext, AdminUpdateItemPage::PAGE_NAME);
$updateItemPage->adminUpdateForm->expandFieldDefinition($containerName);
$updateItemPage->adminUpdateForm->fillFieldWithValue($field, $value, $containerName);
}
Expand All @@ -70,9 +70,9 @@ public function iSetFieldInContainer(string $field, string $containerName, strin
public function iSelectOptionsFrom(string $selectName, TableNode $options): void
{
$optionsHash = $options->getHash();
$this->utilityContext->selectOption($selectName, $optionsHash[0]['option']);
$this->browserContext->selectOption($selectName, $optionsHash[0]['option']);
for ($i = 1; $i < count($optionsHash); ++$i) {
$this->utilityContext->additionallySelectOption($selectName, $optionsHash[$i]['option']);
$this->browserContext->additionallySelectOption($selectName, $optionsHash[$i]['option']);
}
}
}
40 changes: 20 additions & 20 deletions src/lib/Behat/BusinessContext/AdministrationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
namespace EzSystems\EzPlatformAdminUi\Behat\BusinessContext;

use Behat\Gherkin\Node\TableNode;
use EzSystems\Behat\Browser\Page\Page;
use EzSystems\Behat\Browser\Factory\ElementFactory;
use EzSystems\Behat\Browser\Factory\PageObjectFactory;
use EzSystems\EzPlatformAdminUi\Behat\PageElement\Dialog;
use EzSystems\EzPlatformAdminUi\Behat\PageElement\ElementFactory;
use EzSystems\EzPlatformAdminUi\Behat\PageObject\ObjectStateGroupPage;
use EzSystems\EzPlatformAdminUi\Behat\PageObject\ObjectStateGroupsPage;
use EzSystems\EzPlatformAdminUi\Behat\PageObject\Page;
use EzSystems\EzPlatformAdminUi\Behat\PageObject\RolePage;
use EzSystems\EzPlatformAdminUi\Behat\PageObject\RolesPage;
use EzSystems\EzPlatformAdminUi\Behat\PageObject\ContentTypeGroupPage;
use EzSystems\EzPlatformAdminUi\Behat\PageObject\ContentTypeGroupsPage;
use EzSystems\EzPlatformAdminUi\Behat\PageObject\LanguagesPage;
use EzSystems\EzPlatformAdminUi\Behat\PageObject\PageObjectFactory;
use EzSystems\EzPlatformAdminUi\Behat\PageObject\SectionPage;
use EzSystems\EzPlatformAdminUi\Behat\PageObject\SectionsPage;
use PHPUnit\Framework\Assert;
Expand Down Expand Up @@ -50,7 +50,7 @@ class AdministrationContext extends BusinessContext
*/
public function iSeeList(string $pageName, string $parameter = null): void
{
$contentTypeGroupsPage = PageObjectFactory::createPage($this->utilityContext, $pageName, $parameter);
$contentTypeGroupsPage = PageObjectFactory::createPage($this->browserContext, $pageName, $parameter);
$contentTypeGroupsPage->verifyElements();
}

Expand All @@ -65,7 +65,7 @@ public function iStartCreatingNew(string $newItemType, ?string $containerItem =
if (!array_key_exists($newItemType, $this->itemCreateMapping)) {
throw new \InvalidArgumentException(sprintf('Unrecognized item type name: %s', $newItemType));
}
PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$newItemType], $containerItem)
PageObjectFactory::createPage($this->browserContext, $this->itemCreateMapping[$newItemType], $containerItem)
->startCreatingItem();
}

Expand All @@ -74,7 +74,7 @@ public function iStartCreatingNew(string $newItemType, ?string $containerItem =
*/
public function iStartAssigningTo(string $itemName, string $pageType): void
{
$pageObject = PageObjectFactory::createPage($this->utilityContext, $pageType, $itemName);
$pageObject = PageObjectFactory::createPage($this->browserContext, $pageType, $itemName);
$pageObject->startAssigningToItem($itemName);
}

Expand All @@ -84,7 +84,7 @@ public function iStartAssigningTo(string $itemName, string $pageType): void
*/
public function verifyElementOnTheList(string $listElementName, string $page, ?string $parameter = null): void
{
$pageElement = PageObjectFactory::createPage($this->utilityContext, $page, $parameter);
$pageElement = PageObjectFactory::createPage($this->browserContext, $page, $parameter);
if (!$pageElement->adminList->isElementOnTheList($listElementName)) {
Assert::fail(sprintf('Element "%s" is on the %s list.', $listElementName, $page));
}
Expand All @@ -96,7 +96,7 @@ public function verifyElementOnTheList(string $listElementName, string $page, ?s
*/
public function verifyElementNotOnTheList(string $listElementName, string $page, string $parameter = null): void
{
$pageElement = PageObjectFactory::createPage($this->utilityContext, $page, $parameter);
$pageElement = PageObjectFactory::createPage($this->browserContext, $page, $parameter);
if ($pageElement->adminList->isElementOnTheList($listElementName)) {
Assert::fail(sprintf('Element "%s" is on the %s list.', $listElementName, $page));
}
Expand All @@ -113,7 +113,7 @@ private function verifyContentsStatus(string $itemName, string $page, bool $shou
{
$emptyContainerCellValue = '0';

$contentsCount = PageObjectFactory::createPage($this->utilityContext, $page)
$contentsCount = PageObjectFactory::createPage($this->browserContext, $page)
->adminList->table->getTableCellValue($itemName, $this->emptyHeaderMapping[$page]);

$msg = '';
Expand Down Expand Up @@ -147,7 +147,7 @@ public function isNonEmptyElementOnTheList(string $itemName, string $page): void
*/
public function itemCannotBeSelected(string $itemType, string $itemName): void
{
$isListElementSelectable = PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType])
$isListElementSelectable = PageObjectFactory::createPage($this->browserContext, $this->itemCreateMapping[$itemType])
->adminList->table->isElementSelectable($itemName);

if ($isListElementSelectable) {
Expand All @@ -161,7 +161,7 @@ public function itemCannotBeSelected(string $itemType, string $itemName): void
*/
public function iGoToListItem(string $itemName, string $itemType, string $itemContainer = null): void
{
$pageElement = PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType], $itemContainer);
$pageElement = PageObjectFactory::createPage($this->browserContext, $this->itemCreateMapping[$itemType], $itemContainer);
if ($pageElement->adminList->isElementOnTheList($itemName)) {
$pageElement->adminList->table->clickListElement($itemName);
} else {
Expand All @@ -175,7 +175,7 @@ public function iGoToListItem(string $itemName, string $itemType, string $itemCo
*/
public function iStartEditingItem(string $itemType, string $itemName, ?string $containerName = null): void
{
PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType], $containerName)
PageObjectFactory::createPage($this->browserContext, $this->itemCreateMapping[$itemType], $containerName)
->startEditingItem($itemName);
}

Expand All @@ -184,7 +184,7 @@ public function iStartEditingItem(string $itemType, string $itemName, ?string $c
*/
public function iStartEditingItemFromDetails(string $itemType, string $itemName): void
{
PageObjectFactory::createPage($this->utilityContext, $itemType, $itemName)
PageObjectFactory::createPage($this->browserContext, $itemType, $itemName)
->startEditingSelf($itemName);
}

Expand All @@ -195,7 +195,7 @@ public function iDeleteItems(string $itemType, TableNode $settings): void
{
$hash = $settings->getHash();

$page = PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType]);
$page = PageObjectFactory::createPage($this->browserContext, $this->itemCreateMapping[$itemType]);
foreach ($hash as $setting) {
$page->adminList->table->selectListElement($setting['item']);
}
Expand All @@ -210,7 +210,7 @@ public function iDeleteItemsFromContainer(string $itemType, ?string $containerNa
{
$hash = $settings->getHash();

$page = PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType], $containerName);
$page = PageObjectFactory::createPage($this->browserContext, $this->itemCreateMapping[$itemType], $containerName);
foreach ($hash as $setting) {
$page->adminList->table->selectListElement($setting['item']);
}
Expand All @@ -225,7 +225,7 @@ public function iDeleteItemsFromDetails(string $itemType, TableNode $settings):
{
$hash = $settings->getHash();

$page = PageObjectFactory::createPage($this->utilityContext, $itemType, $hash[0]['item']);
$page = PageObjectFactory::createPage($this->browserContext, $itemType, $hash[0]['item']);
$this->performDeletion($page);
}

Expand All @@ -235,7 +235,7 @@ public function iDeleteItemsFromDetails(string $itemType, TableNode $settings):
private function performDeletion(Page $page)
{
$page->adminList->clickTrashButton();
$dialog = ElementFactory::createElement($this->utilityContext, Dialog::ELEMENT_NAME);
$dialog = ElementFactory::createElement($this->browserContext, Dialog::ELEMENT_NAME);
$dialog->verifyVisibility();
$dialog->confirm();
}
Expand All @@ -245,7 +245,7 @@ private function performDeletion(Page $page)
*/
public function itemHasProperAttribute(string $itemType, string $itemName, string $attributeName, string $value)
{
$pageObject = PageObjectFactory::createPage($this->utilityContext, $itemType, $itemName);
$pageObject = PageObjectFactory::createPage($this->browserContext, $itemType, $itemName);

$pageObject->verifyItemAttribute($attributeName, $value);
}
Expand All @@ -255,7 +255,7 @@ public function itemHasProperAttribute(string $itemType, string $itemName, strin
*/
public function linkItemHasProperAttribute(string $itemName, string $pageName, string $attributeName, string $value)
{
$pageObject = PageObjectFactory::createPage($this->utilityContext, $pageName);
$pageObject = PageObjectFactory::createPage($this->browserContext, $pageName);
$pageObject->verifyItemAttribute($attributeName, $value, $itemName);
}

Expand All @@ -275,7 +275,7 @@ public function itemHasProperAttributes(string $itemType, string $itemName, Tabl
*/
public function listIsEmpty(string $listName, string $itemType, string $itemName): void
{
$pageObject = PageObjectFactory::createPage($this->utilityContext, $itemType, $itemName);
$pageObject = PageObjectFactory::createPage($this->browserContext, $itemType, $itemName);
$pageObject->verifyListIsEmpty($listName);
}
}
6 changes: 3 additions & 3 deletions src/lib/Behat/BusinessContext/AuthenticationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace EzSystems\EzPlatformAdminUi\Behat\BusinessContext;

use EzSystems\EzPlatformAdminUi\Behat\PageObject\LoginPage;
use EzSystems\EzPlatformAdminUi\Behat\PageObject\PageObjectFactory;
use EzSystems\Behat\Browser\Factory\PageObjectFactory;
use OutOfBoundsException;

/** Context for authentication actions */
Expand All @@ -26,7 +26,7 @@ class AuthenticationContext extends BusinessContext
*/
public function iLoginAs(string $username, string $password): void
{
$loginPage = PageObjectFactory::createPage($this->utilityContext, LoginPage::PAGE_NAME);
$loginPage = PageObjectFactory::createPage($this->browserContext, LoginPage::PAGE_NAME);
$loginPage->login($username, $password);
}

Expand All @@ -35,7 +35,7 @@ public function iLoginAs(string $username, string $password): void
*/
public function iAmLoggedAs(string $username): void
{
$loginPage = PageObjectFactory::createPage($this->utilityContext, LoginPage::PAGE_NAME);
$loginPage = PageObjectFactory::createPage($this->browserContext, LoginPage::PAGE_NAME);
$loginPage->open();

if (!\array_key_exists($username, $this->userCredentials)) {
Expand Down
8 changes: 4 additions & 4 deletions src/lib/Behat/BusinessContext/BusinessContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@

use Behat\Behat\Context\Context;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use EzSystems\EzPlatformAdminUi\Behat\Helper\UtilityContext;
use EzSystems\Behat\Browser\Context\BrowserContext;

abstract class BusinessContext implements Context
{
/** @var UtilityContext */
protected $utilityContext;
/** @var BrowserContext */
protected $browserContext;

/** @BeforeScenario
* @param BeforeScenarioScope $scope Behat scope
*/
public function getUtilityContext(BeforeScenarioScope $scope): void
{
$environment = $scope->getEnvironment();
$this->utilityContext = $environment->getContext(UtilityContext::class);
$this->browserContext = $environment->getContext(BrowserContext::class);
}
}
6 changes: 3 additions & 3 deletions src/lib/Behat/BusinessContext/ContentPreviewContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace EzSystems\EzPlatformAdminUi\Behat\BusinessContext;

use EzSystems\EzPlatformAdminUi\Behat\PageObject\ContentPreviewPage;
use EzSystems\EzPlatformAdminUi\Behat\PageObject\PageObjectFactory;
use EzSystems\Behat\Browser\Factory\PageObjectFactory;

class ContentPreviewContext extends BusinessContext
{
Expand All @@ -16,7 +16,7 @@ class ContentPreviewContext extends BusinessContext
*/
public function iGoToPreview(string $viewName, string $contentName): void
{
$previewPage = PageObjectFactory::createPage($this->utilityContext, ContentPreviewPage::PAGE_NAME, $contentName);
$previewPage = PageObjectFactory::createPage($this->browserContext, ContentPreviewPage::PAGE_NAME, $contentName);
$previewPage->verifyIsLoaded();
$previewPage->previewNav->goToView($viewName);
}
Expand All @@ -26,7 +26,7 @@ public function iGoToPreview(string $viewName, string $contentName): void
*/
public function iGoToBackFromPreview(string $contentName): void
{
$previewPage = PageObjectFactory::createPage($this->utilityContext, ContentPreviewPage::PAGE_NAME, $contentName);
$previewPage = PageObjectFactory::createPage($this->browserContext, ContentPreviewPage::PAGE_NAME, $contentName);
$previewPage->verifyIsLoaded();
$previewPage->previewNav->goBackToEditView();
}
Expand Down
Loading

0 comments on commit ba2d29d

Please sign in to comment.