Skip to content

Commit ba2d29d

Browse files
authored
Merge pull request #1020 from ezsystems/EZP-30668-move-core-to-behatbundle
EZP-30668: move core tests classes from AdminUI to BehatBundle
2 parents 1dc7f1d + 108bb9a commit ba2d29d

File tree

116 files changed

+423
-1580
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+423
-1580
lines changed

behat_suites.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ adminui:
1313
filters:
1414
tags: "@common"
1515
contexts:
16-
- EzSystems\EzPlatformAdminUi\Behat\Helper\UtilityContext
17-
- EzSystems\EzPlatformAdminUi\Behat\Helper\Hooks
16+
- EzSystems\Behat\Browser\Context\BrowserContext
17+
- EzSystems\Behat\Browser\Context\Hooks
1818
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\AuthenticationContext
1919
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\NavigationContext
2020
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\AdministrationContext
@@ -42,8 +42,8 @@ adminui:
4242
filters:
4343
tags: "@common"
4444
contexts:
45-
- EzSystems\EzPlatformAdminUi\Behat\Helper\UtilityContext
46-
- EzSystems\EzPlatformAdminUi\Behat\Helper\Hooks
45+
- EzSystems\Behat\Browser\Context\BrowserContext
46+
- EzSystems\Behat\Browser\Context\Hooks
4747
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\AuthenticationContext
4848
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\NavigationContext
4949
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\ContentViewContext
@@ -61,8 +61,8 @@ adminui:
6161
filters:
6262
tags: "@common"
6363
contexts:
64-
- EzSystems\EzPlatformAdminUi\Behat\Helper\UtilityContext
65-
- EzSystems\EzPlatformAdminUi\Behat\Helper\Hooks
64+
- EzSystems\Behat\Browser\Context\BrowserContext
65+
- EzSystems\Behat\Browser\Context\Hooks
6666
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\AuthenticationContext
6767
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\NavigationContext
6868
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\ContentViewContext

src/lib/Behat/BusinessContext/AdminUpdateContext.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
namespace EzSystems\EzPlatformAdminUi\Behat\BusinessContext;
88

99
use Behat\Gherkin\Node\TableNode;
10-
use EzSystems\EzPlatformAdminUi\Behat\PageElement\ElementFactory;
10+
use EzSystems\Behat\Browser\Factory\ElementFactory;
1111
use EzSystems\EzPlatformAdminUi\Behat\PageElement\Notification;
12-
use EzSystems\EzPlatformAdminUi\Behat\PageObject\PageObjectFactory;
12+
use EzSystems\Behat\Browser\Factory\PageObjectFactory;
1313
use EzSystems\EzPlatformAdminUi\Behat\PageObject\AdminUpdateItemPage;
1414

1515
/** Context for common actions for creating and updating */
@@ -20,7 +20,7 @@ class AdminUpdateContext extends BusinessContext
2020
*/
2121
public function iSetFields(TableNode $table): void
2222
{
23-
$updateItemPage = PageObjectFactory::createPage($this->utilityContext, AdminUpdateItemPage::PAGE_NAME);
23+
$updateItemPage = PageObjectFactory::createPage($this->browserContext, AdminUpdateItemPage::PAGE_NAME);
2424
$hash = $table->getHash();
2525
foreach ($hash as $row) {
2626
$updateItemPage->adminUpdateForm->fillFieldWithValue($row['label'], $row['value']);
@@ -32,7 +32,7 @@ public function iSetFields(TableNode $table): void
3232
*/
3333
public function verifyFieldsAreSet(TableNode $table): void
3434
{
35-
$updateItemPage = PageObjectFactory::createPage($this->utilityContext, AdminUpdateItemPage::PAGE_NAME);
35+
$updateItemPage = PageObjectFactory::createPage($this->browserContext, AdminUpdateItemPage::PAGE_NAME);
3636
$hash = $table->getHash();
3737
foreach ($hash as $row) {
3838
$updateItemPage->adminUpdateForm->verifyFieldHasValue($row['label'], $row['value']);
@@ -44,11 +44,11 @@ public function verifyFieldsAreSet(TableNode $table): void
4444
*/
4545
public function iAddField(string $fieldName): void
4646
{
47-
$updateItemPage = PageObjectFactory::createPage($this->utilityContext, AdminUpdateItemPage::PAGE_NAME);
47+
$updateItemPage = PageObjectFactory::createPage($this->browserContext, AdminUpdateItemPage::PAGE_NAME);
4848
$updateItemPage->adminUpdateForm->selectFieldDefinition($fieldName);
4949
$updateItemPage->adminUpdateForm->clickAddFieldDefinition();
5050
$updateItemPage->adminUpdateForm->verifyNewFieldDefinitionFormExists($fieldName);
51-
$notification = ElementFactory::createElement($this->utilityContext, Notification::ELEMENT_NAME);
51+
$notification = ElementFactory::createElement($this->browserContext, Notification::ELEMENT_NAME);
5252
$notification->verifyVisibility();
5353
$notification->verifyAlertSuccess();
5454
$notification->closeAlert();
@@ -59,7 +59,7 @@ public function iAddField(string $fieldName): void
5959
*/
6060
public function iSetFieldInContainer(string $field, string $containerName, string $value): void
6161
{
62-
$updateItemPage = PageObjectFactory::createPage($this->utilityContext, AdminUpdateItemPage::PAGE_NAME);
62+
$updateItemPage = PageObjectFactory::createPage($this->browserContext, AdminUpdateItemPage::PAGE_NAME);
6363
$updateItemPage->adminUpdateForm->expandFieldDefinition($containerName);
6464
$updateItemPage->adminUpdateForm->fillFieldWithValue($field, $value, $containerName);
6565
}
@@ -70,9 +70,9 @@ public function iSetFieldInContainer(string $field, string $containerName, strin
7070
public function iSelectOptionsFrom(string $selectName, TableNode $options): void
7171
{
7272
$optionsHash = $options->getHash();
73-
$this->utilityContext->selectOption($selectName, $optionsHash[0]['option']);
73+
$this->browserContext->selectOption($selectName, $optionsHash[0]['option']);
7474
for ($i = 1; $i < count($optionsHash); ++$i) {
75-
$this->utilityContext->additionallySelectOption($selectName, $optionsHash[$i]['option']);
75+
$this->browserContext->additionallySelectOption($selectName, $optionsHash[$i]['option']);
7676
}
7777
}
7878
}

src/lib/Behat/BusinessContext/AdministrationContext.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
namespace EzSystems\EzPlatformAdminUi\Behat\BusinessContext;
88

99
use Behat\Gherkin\Node\TableNode;
10+
use EzSystems\Behat\Browser\Page\Page;
11+
use EzSystems\Behat\Browser\Factory\ElementFactory;
12+
use EzSystems\Behat\Browser\Factory\PageObjectFactory;
1013
use EzSystems\EzPlatformAdminUi\Behat\PageElement\Dialog;
11-
use EzSystems\EzPlatformAdminUi\Behat\PageElement\ElementFactory;
1214
use EzSystems\EzPlatformAdminUi\Behat\PageObject\ObjectStateGroupPage;
1315
use EzSystems\EzPlatformAdminUi\Behat\PageObject\ObjectStateGroupsPage;
14-
use EzSystems\EzPlatformAdminUi\Behat\PageObject\Page;
1516
use EzSystems\EzPlatformAdminUi\Behat\PageObject\RolePage;
1617
use EzSystems\EzPlatformAdminUi\Behat\PageObject\RolesPage;
1718
use EzSystems\EzPlatformAdminUi\Behat\PageObject\ContentTypeGroupPage;
1819
use EzSystems\EzPlatformAdminUi\Behat\PageObject\ContentTypeGroupsPage;
1920
use EzSystems\EzPlatformAdminUi\Behat\PageObject\LanguagesPage;
20-
use EzSystems\EzPlatformAdminUi\Behat\PageObject\PageObjectFactory;
2121
use EzSystems\EzPlatformAdminUi\Behat\PageObject\SectionPage;
2222
use EzSystems\EzPlatformAdminUi\Behat\PageObject\SectionsPage;
2323
use PHPUnit\Framework\Assert;
@@ -50,7 +50,7 @@ class AdministrationContext extends BusinessContext
5050
*/
5151
public function iSeeList(string $pageName, string $parameter = null): void
5252
{
53-
$contentTypeGroupsPage = PageObjectFactory::createPage($this->utilityContext, $pageName, $parameter);
53+
$contentTypeGroupsPage = PageObjectFactory::createPage($this->browserContext, $pageName, $parameter);
5454
$contentTypeGroupsPage->verifyElements();
5555
}
5656

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

@@ -74,7 +74,7 @@ public function iStartCreatingNew(string $newItemType, ?string $containerItem =
7474
*/
7575
public function iStartAssigningTo(string $itemName, string $pageType): void
7676
{
77-
$pageObject = PageObjectFactory::createPage($this->utilityContext, $pageType, $itemName);
77+
$pageObject = PageObjectFactory::createPage($this->browserContext, $pageType, $itemName);
7878
$pageObject->startAssigningToItem($itemName);
7979
}
8080

@@ -84,7 +84,7 @@ public function iStartAssigningTo(string $itemName, string $pageType): void
8484
*/
8585
public function verifyElementOnTheList(string $listElementName, string $page, ?string $parameter = null): void
8686
{
87-
$pageElement = PageObjectFactory::createPage($this->utilityContext, $page, $parameter);
87+
$pageElement = PageObjectFactory::createPage($this->browserContext, $page, $parameter);
8888
if (!$pageElement->adminList->isElementOnTheList($listElementName)) {
8989
Assert::fail(sprintf('Element "%s" is on the %s list.', $listElementName, $page));
9090
}
@@ -96,7 +96,7 @@ public function verifyElementOnTheList(string $listElementName, string $page, ?s
9696
*/
9797
public function verifyElementNotOnTheList(string $listElementName, string $page, string $parameter = null): void
9898
{
99-
$pageElement = PageObjectFactory::createPage($this->utilityContext, $page, $parameter);
99+
$pageElement = PageObjectFactory::createPage($this->browserContext, $page, $parameter);
100100
if ($pageElement->adminList->isElementOnTheList($listElementName)) {
101101
Assert::fail(sprintf('Element "%s" is on the %s list.', $listElementName, $page));
102102
}
@@ -113,7 +113,7 @@ private function verifyContentsStatus(string $itemName, string $page, bool $shou
113113
{
114114
$emptyContainerCellValue = '0';
115115

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

119119
$msg = '';
@@ -147,7 +147,7 @@ public function isNonEmptyElementOnTheList(string $itemName, string $page): void
147147
*/
148148
public function itemCannotBeSelected(string $itemType, string $itemName): void
149149
{
150-
$isListElementSelectable = PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType])
150+
$isListElementSelectable = PageObjectFactory::createPage($this->browserContext, $this->itemCreateMapping[$itemType])
151151
->adminList->table->isElementSelectable($itemName);
152152

153153
if ($isListElementSelectable) {
@@ -161,7 +161,7 @@ public function itemCannotBeSelected(string $itemType, string $itemName): void
161161
*/
162162
public function iGoToListItem(string $itemName, string $itemType, string $itemContainer = null): void
163163
{
164-
$pageElement = PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType], $itemContainer);
164+
$pageElement = PageObjectFactory::createPage($this->browserContext, $this->itemCreateMapping[$itemType], $itemContainer);
165165
if ($pageElement->adminList->isElementOnTheList($itemName)) {
166166
$pageElement->adminList->table->clickListElement($itemName);
167167
} else {
@@ -175,7 +175,7 @@ public function iGoToListItem(string $itemName, string $itemType, string $itemCo
175175
*/
176176
public function iStartEditingItem(string $itemType, string $itemName, ?string $containerName = null): void
177177
{
178-
PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType], $containerName)
178+
PageObjectFactory::createPage($this->browserContext, $this->itemCreateMapping[$itemType], $containerName)
179179
->startEditingItem($itemName);
180180
}
181181

@@ -184,7 +184,7 @@ public function iStartEditingItem(string $itemType, string $itemName, ?string $c
184184
*/
185185
public function iStartEditingItemFromDetails(string $itemType, string $itemName): void
186186
{
187-
PageObjectFactory::createPage($this->utilityContext, $itemType, $itemName)
187+
PageObjectFactory::createPage($this->browserContext, $itemType, $itemName)
188188
->startEditingSelf($itemName);
189189
}
190190

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

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

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

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

@@ -235,7 +235,7 @@ public function iDeleteItemsFromDetails(string $itemType, TableNode $settings):
235235
private function performDeletion(Page $page)
236236
{
237237
$page->adminList->clickTrashButton();
238-
$dialog = ElementFactory::createElement($this->utilityContext, Dialog::ELEMENT_NAME);
238+
$dialog = ElementFactory::createElement($this->browserContext, Dialog::ELEMENT_NAME);
239239
$dialog->verifyVisibility();
240240
$dialog->confirm();
241241
}
@@ -245,7 +245,7 @@ private function performDeletion(Page $page)
245245
*/
246246
public function itemHasProperAttribute(string $itemType, string $itemName, string $attributeName, string $value)
247247
{
248-
$pageObject = PageObjectFactory::createPage($this->utilityContext, $itemType, $itemName);
248+
$pageObject = PageObjectFactory::createPage($this->browserContext, $itemType, $itemName);
249249

250250
$pageObject->verifyItemAttribute($attributeName, $value);
251251
}
@@ -255,7 +255,7 @@ public function itemHasProperAttribute(string $itemType, string $itemName, strin
255255
*/
256256
public function linkItemHasProperAttribute(string $itemName, string $pageName, string $attributeName, string $value)
257257
{
258-
$pageObject = PageObjectFactory::createPage($this->utilityContext, $pageName);
258+
$pageObject = PageObjectFactory::createPage($this->browserContext, $pageName);
259259
$pageObject->verifyItemAttribute($attributeName, $value, $itemName);
260260
}
261261

@@ -275,7 +275,7 @@ public function itemHasProperAttributes(string $itemType, string $itemName, Tabl
275275
*/
276276
public function listIsEmpty(string $listName, string $itemType, string $itemName): void
277277
{
278-
$pageObject = PageObjectFactory::createPage($this->utilityContext, $itemType, $itemName);
278+
$pageObject = PageObjectFactory::createPage($this->browserContext, $itemType, $itemName);
279279
$pageObject->verifyListIsEmpty($listName);
280280
}
281281
}

src/lib/Behat/BusinessContext/AuthenticationContext.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace EzSystems\EzPlatformAdminUi\Behat\BusinessContext;
88

99
use EzSystems\EzPlatformAdminUi\Behat\PageObject\LoginPage;
10-
use EzSystems\EzPlatformAdminUi\Behat\PageObject\PageObjectFactory;
10+
use EzSystems\Behat\Browser\Factory\PageObjectFactory;
1111
use OutOfBoundsException;
1212

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

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

4141
if (!\array_key_exists($username, $this->userCredentials)) {

src/lib/Behat/BusinessContext/BusinessContext.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88

99
use Behat\Behat\Context\Context;
1010
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
11-
use EzSystems\EzPlatformAdminUi\Behat\Helper\UtilityContext;
11+
use EzSystems\Behat\Browser\Context\BrowserContext;
1212

1313
abstract class BusinessContext implements Context
1414
{
15-
/** @var UtilityContext */
16-
protected $utilityContext;
15+
/** @var BrowserContext */
16+
protected $browserContext;
1717

1818
/** @BeforeScenario
1919
* @param BeforeScenarioScope $scope Behat scope
2020
*/
2121
public function getUtilityContext(BeforeScenarioScope $scope): void
2222
{
2323
$environment = $scope->getEnvironment();
24-
$this->utilityContext = $environment->getContext(UtilityContext::class);
24+
$this->browserContext = $environment->getContext(BrowserContext::class);
2525
}
2626
}

src/lib/Behat/BusinessContext/ContentPreviewContext.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace EzSystems\EzPlatformAdminUi\Behat\BusinessContext;
88

99
use EzSystems\EzPlatformAdminUi\Behat\PageObject\ContentPreviewPage;
10-
use EzSystems\EzPlatformAdminUi\Behat\PageObject\PageObjectFactory;
10+
use EzSystems\Behat\Browser\Factory\PageObjectFactory;
1111

1212
class ContentPreviewContext extends BusinessContext
1313
{
@@ -16,7 +16,7 @@ class ContentPreviewContext extends BusinessContext
1616
*/
1717
public function iGoToPreview(string $viewName, string $contentName): void
1818
{
19-
$previewPage = PageObjectFactory::createPage($this->utilityContext, ContentPreviewPage::PAGE_NAME, $contentName);
19+
$previewPage = PageObjectFactory::createPage($this->browserContext, ContentPreviewPage::PAGE_NAME, $contentName);
2020
$previewPage->verifyIsLoaded();
2121
$previewPage->previewNav->goToView($viewName);
2222
}
@@ -26,7 +26,7 @@ public function iGoToPreview(string $viewName, string $contentName): void
2626
*/
2727
public function iGoToBackFromPreview(string $contentName): void
2828
{
29-
$previewPage = PageObjectFactory::createPage($this->utilityContext, ContentPreviewPage::PAGE_NAME, $contentName);
29+
$previewPage = PageObjectFactory::createPage($this->browserContext, ContentPreviewPage::PAGE_NAME, $contentName);
3030
$previewPage->verifyIsLoaded();
3131
$previewPage->previewNav->goBackToEditView();
3232
}

0 commit comments

Comments
 (0)