From a9a4570c4880f14e37f37831910ddebf69a6de58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Nowak?= Date: Tue, 19 May 2026 13:06:50 +0200 Subject: [PATCH 1/4] IBX-11766 composer require --dev webmozart/assert:^2.3 --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8c9f14b13e..0b9d713da7 100644 --- a/composer.json +++ b/composer.json @@ -73,7 +73,8 @@ "phpstan/phpstan": "^2.0", "phpstan/phpstan-phpunit": "^2.0", "phpstan/phpstan-symfony": "^2.0", - "phpunit/phpunit": "^9.5" + "phpunit/phpunit": "^9.5", + "webmozart/assert": "^2.3" }, "config": { "allow-plugins": { From 3e760d2a995a4f663e4335c14bc55f486e3f9e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Nowak?= Date: Tue, 19 May 2026 14:10:10 +0200 Subject: [PATCH 2/4] IBX-11766 Replaced phpunit assertions with these from webmozart library --- .../Behat/BrowserContext/BookmarkContext.php | 8 +++---- .../ContentActionsMenuContext.php | 8 +++---- .../BrowserContext/ContentTypeContext.php | 22 ++++++++--------- .../BrowserContext/ContentUpdateContext.php | 4 ++-- .../BrowserContext/ContentViewContext.php | 8 +++---- .../Behat/BrowserContext/DashboardContext.php | 6 ++--- .../Behat/BrowserContext/LanguageContext.php | 8 +++---- .../Behat/BrowserContext/MyDraftsContext.php | 4 ++-- .../BrowserContext/NotificationContext.php | 6 ++--- .../BrowserContext/ObjectStatesContext.php | 16 ++++++------- src/lib/Behat/BrowserContext/RolesContext.php | 14 +++++------ .../Behat/BrowserContext/SearchContext.php | 4 ++-- .../Behat/BrowserContext/SectionsContext.php | 20 ++++++++-------- src/lib/Behat/BrowserContext/TrashContext.php | 10 ++++---- src/lib/Behat/BrowserContext/UDWContext.php | 4 ++-- .../UserNotificationContext.php | 6 ++--- src/lib/Behat/Component/Breadcrumb.php | 4 ++-- src/lib/Behat/Component/ContentTree.php | 4 ++-- src/lib/Behat/Component/Fields/Authors.php | 14 +++++------ src/lib/Behat/Component/Fields/Checkbox.php | 6 ++--- .../Behat/Component/Fields/ContentQuery.php | 4 ++-- .../Fields/ContentRelationMultiple.php | 10 ++++---- .../Fields/ContentRelationSingle.php | 6 ++--- src/lib/Behat/Component/Fields/Date.php | 6 ++--- .../Behat/Component/Fields/DateAndTime.php | 8 +++---- .../Component/Fields/FieldTypeComponent.php | 12 +++++----- src/lib/Behat/Component/Fields/File.php | 10 ++++---- src/lib/Behat/Component/Fields/Image.php | 10 ++++---- src/lib/Behat/Component/Fields/ImageAsset.php | 4 ++-- src/lib/Behat/Component/Fields/Keywords.php | 4 ++-- .../Behat/Component/Fields/MapLocation.php | 20 ++++++++-------- src/lib/Behat/Component/Fields/Matrix.php | 4 ++-- src/lib/Behat/Component/Fields/Media.php | 10 ++++---- src/lib/Behat/Component/Fields/RichText.php | 10 ++++---- src/lib/Behat/Component/Fields/Time.php | 8 +++---- src/lib/Behat/Component/Fields/URL.php | 18 +++++++------- src/lib/Behat/Component/Fields/User.php | 16 ++++++------- src/lib/Behat/Component/LanguagePicker.php | 4 ++-- src/lib/Behat/Component/Notification.php | 4 ++-- src/lib/Behat/Component/SubItemsList.php | 4 ++-- src/lib/Behat/Component/Table/Table.php | 6 ++--- .../Behat/Component/TableNavigationTab.php | 4 ++-- src/lib/Behat/Page/AdminUpdateItemPage.php | 4 ++-- src/lib/Behat/Page/ContentPreviewPage.php | 4 ++-- src/lib/Behat/Page/ContentTypeGroupsPage.php | 8 +++---- src/lib/Behat/Page/ContentUpdateItemPage.php | 12 +++++----- src/lib/Behat/Page/ContentViewPage.php | 24 +++++++++---------- src/lib/Behat/Page/LanguagePage.php | 8 +++---- src/lib/Behat/Page/ObjectStateGroupsPage.php | 8 +++---- src/lib/Behat/Page/ObjectStatePage.php | 8 +++---- src/lib/Behat/Page/RolePage.php | 6 ++--- src/lib/Behat/Page/RolesPage.php | 12 +++++----- src/lib/Behat/Page/SectionsPage.php | 8 +++---- src/lib/Behat/Page/SystemInfoPage.php | 4 ++-- src/lib/Behat/Page/TrashPage.php | 8 +++---- src/lib/Behat/Page/UserProfilePage.php | 8 +++---- src/lib/Behat/Page/UserSettingsPage.php | 4 ++-- 57 files changed, 242 insertions(+), 242 deletions(-) diff --git a/src/lib/Behat/BrowserContext/BookmarkContext.php b/src/lib/Behat/BrowserContext/BookmarkContext.php index 84ca645115..44cec84e93 100644 --- a/src/lib/Behat/BrowserContext/BookmarkContext.php +++ b/src/lib/Behat/BrowserContext/BookmarkContext.php @@ -11,7 +11,7 @@ use Behat\Behat\Context\Context; use Ibexa\AdminUi\Behat\Page\BookmarksPage; use Ibexa\AdminUi\Behat\Page\ContentViewPage; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final readonly class BookmarkContext implements Context { @@ -36,7 +36,7 @@ public function bookmarkContentItem(string $path): void */ public function contentItemIsBookmarked(): void { - Assert::assertTrue($this->contentViewPage->isBookmarked()); + Assert::true($this->contentViewPage->isBookmarked()); } /** @@ -44,7 +44,7 @@ public function contentItemIsBookmarked(): void */ public function contentItemIsDisplayed(string $contentName): void { - Assert::assertTrue($this->bookmarksPage->isBookmarked($contentName)); + Assert::true($this->bookmarksPage->isBookmarked($contentName)); } /** @@ -52,7 +52,7 @@ public function contentItemIsDisplayed(string $contentName): void */ public function contentItemIsNotDisplayed(string $contentName): void { - Assert::assertFalse($this->bookmarksPage->isBookmarked($contentName)); + Assert::false($this->bookmarksPage->isBookmarked($contentName)); } /** diff --git a/src/lib/Behat/BrowserContext/ContentActionsMenuContext.php b/src/lib/Behat/BrowserContext/ContentActionsMenuContext.php index 5572d58f38..f01c670abc 100644 --- a/src/lib/Behat/BrowserContext/ContentActionsMenuContext.php +++ b/src/lib/Behat/BrowserContext/ContentActionsMenuContext.php @@ -11,7 +11,7 @@ use Behat\Behat\Context\Context; use Behat\Gherkin\Node\TableNode; use Ibexa\AdminUi\Behat\Component\ContentActionsMenu; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final readonly class ContentActionsMenuContext implements Context { @@ -35,7 +35,7 @@ public function clickEditActionBar(string $buttonName, ?string $groupName = null public function theButtonsAreDisabled(TableNode $buttons): void { foreach ($buttons->getHash() as $button) { - Assert::assertFalse($this->contentActionsMenu->isButtonActive($button['buttonName'])); + Assert::false($this->contentActionsMenu->isButtonActive($button['buttonName'])); } } @@ -44,7 +44,7 @@ public function theButtonsAreDisabled(TableNode $buttons): void */ public function buttonIsNotVisible(string $buttonName): void { - Assert::assertFalse($this->contentActionsMenu->isButtonVisible($buttonName)); + Assert::false($this->contentActionsMenu->isButtonVisible($buttonName)); } /** @@ -52,6 +52,6 @@ public function buttonIsNotVisible(string $buttonName): void */ public function buttonIsVisible(string $buttonName): void { - Assert::assertTrue($this->contentActionsMenu->isButtonVisible($buttonName)); + Assert::true($this->contentActionsMenu->isButtonVisible($buttonName)); } } diff --git a/src/lib/Behat/BrowserContext/ContentTypeContext.php b/src/lib/Behat/BrowserContext/ContentTypeContext.php index 568dec7175..2222871d5e 100644 --- a/src/lib/Behat/BrowserContext/ContentTypeContext.php +++ b/src/lib/Behat/BrowserContext/ContentTypeContext.php @@ -14,7 +14,7 @@ use Ibexa\AdminUi\Behat\Page\ContentTypeGroupsPage; use Ibexa\AdminUi\Behat\Page\ContentTypePage; use Ibexa\AdminUi\Behat\Page\ContentTypeUpdatePage; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final readonly class ContentTypeContext implements Context { @@ -32,7 +32,7 @@ public function __construct( public function contentTypeHasProperGlobalProperties(TableNode $table): void { foreach ($table->getHash() as $row) { - Assert::assertTrue($this->contentTypePage->hasProperty($row['label'], $row['value'])); + Assert::true($this->contentTypePage->hasProperty($row['label'], $row['value'])); } } @@ -58,7 +58,7 @@ public function createNewContentTypeGroup(): void public function contentTypeHasProperFields(TableNode $table): void { foreach ($table->getHash() as $row) { - Assert::assertTrue($this->contentTypePage->hasFieldType( + Assert::true($this->contentTypePage->hasFieldType( ['Name' => $row['fieldName'], 'Type' => $row['fieldType']] )); } @@ -69,7 +69,7 @@ public function contentTypeHasProperFields(TableNode $table): void */ public function thereSNoOnContentTypesList(string $contentTypeName): void { - Assert::assertFalse($this->contentTypeGroupPage->isContentTypeOnTheList($contentTypeName)); + Assert::false($this->contentTypeGroupPage->isContentTypeOnTheList($contentTypeName)); } /** @@ -77,7 +77,7 @@ public function thereSNoOnContentTypesList(string $contentTypeName): void */ public function thereSNoOnContentTypesGroupList(string $contentTypeGroupName): void { - Assert::assertFalse($this->contentTypeGroupsPage->isContentTypeGroupOnTheList($contentTypeGroupName)); + Assert::false($this->contentTypeGroupsPage->isContentTypeGroupOnTheList($contentTypeGroupName)); } /** @@ -85,7 +85,7 @@ public function thereSNoOnContentTypesGroupList(string $contentTypeGroupName): v */ public function thereSAOnContentTypesGroupList(string $contentTypeGroupName): void { - Assert::assertTrue($this->contentTypeGroupsPage->isContentTypeGroupOnTheList($contentTypeGroupName)); + Assert::true($this->contentTypeGroupsPage->isContentTypeGroupOnTheList($contentTypeGroupName)); } /** @@ -93,7 +93,7 @@ public function thereSAOnContentTypesGroupList(string $contentTypeGroupName): vo */ public function thereAContentTypeOnContentTypesList(string $contentTypeName): void { - Assert::assertTrue($this->contentTypeGroupPage->isContentTypeOnTheList($contentTypeName)); + Assert::true($this->contentTypeGroupPage->isContentTypeOnTheList($contentTypeName)); } /** @@ -187,7 +187,7 @@ public function iShouldBeOnContentTypePage(string $contentTypeName): void */ public function thereAreNoContentTypes(): void { - Assert::assertFalse($this->contentTypeGroupPage->hasContentTypes()); + Assert::false($this->contentTypeGroupPage->hasContentTypes()); } /** @@ -195,7 +195,7 @@ public function thereAreNoContentTypes(): void */ public function thereIsAnEmptyContentTypeGroup(string $contentTypeGroupName): void { - Assert::assertFalse($this->contentTypeGroupPage->hasAssignedContentItems($contentTypeGroupName)); + Assert::false($this->contentTypeGroupPage->hasAssignedContentItems($contentTypeGroupName)); } /** @@ -203,7 +203,7 @@ public function thereIsAnEmptyContentTypeGroup(string $contentTypeGroupName): vo */ public function thereIsANonEmptyContentTypeGroup(string $contentTypeGroupName): void { - Assert::assertTrue($this->contentTypeGroupPage->hasAssignedContentItems($contentTypeGroupName)); + Assert::true($this->contentTypeGroupPage->hasAssignedContentItems($contentTypeGroupName)); } /** @@ -211,7 +211,7 @@ public function thereIsANonEmptyContentTypeGroup(string $contentTypeGroupName): */ public function contentTypeGroupCannotBeSelected(string $contentTypeGroupName): void { - Assert::assertFalse($this->contentTypeGroupsPage->canBeSelected($contentTypeGroupName)); + Assert::false($this->contentTypeGroupsPage->canBeSelected($contentTypeGroupName)); } /** diff --git a/src/lib/Behat/BrowserContext/ContentUpdateContext.php b/src/lib/Behat/BrowserContext/ContentUpdateContext.php index 96c85ebed7..2d70ebb529 100644 --- a/src/lib/Behat/BrowserContext/ContentUpdateContext.php +++ b/src/lib/Behat/BrowserContext/ContentUpdateContext.php @@ -13,7 +13,7 @@ use Ibexa\AdminUi\Behat\Component\Fields\NonEditableField; use Ibexa\AdminUi\Behat\Page\ContentUpdateItemPage; use Ibexa\AdminUi\Behat\Page\UserUpdatePage; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final readonly class ContentUpdateContext implements Context { @@ -50,7 +50,7 @@ public function fieldContainsValidationError(string $fieldName, string $errorMes public function verifyFieldIsNotEditable(string $fieldName): void { $field = $this->contentUpdateItemPage->getField($fieldName); - Assert::assertEquals(NonEditableField::EXPECTED_NON_EDITABLE_TEXT, $field->getValue()[0]); + Assert::eq($field->getValue()[0], NonEditableField::EXPECTED_NON_EDITABLE_TEXT); } /** diff --git a/src/lib/Behat/BrowserContext/ContentViewContext.php b/src/lib/Behat/BrowserContext/ContentViewContext.php index 3a62b77352..ac63bc2e88 100644 --- a/src/lib/Behat/BrowserContext/ContentViewContext.php +++ b/src/lib/Behat/BrowserContext/ContentViewContext.php @@ -13,7 +13,7 @@ use Ibexa\AdminUi\Behat\Component\DraftConflictDialog; use Ibexa\AdminUi\Behat\Page\ContentViewPage; use Ibexa\Behat\Core\Behat\ArgumentParser; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final readonly class ContentViewContext implements Context { @@ -107,7 +107,7 @@ public function startEditingContent(?string $language = null): void public function verifyThereIsItemInSubItemList(string $itemName, string $itemType): void { $this->contentViewPage->verifyIsLoaded(); - Assert::assertTrue($this->contentViewPage->isChildElementPresent(['Name' => $itemName, 'Content type' => $itemType])); + Assert::true($this->contentViewPage->isChildElementPresent(['Name' => $itemName, 'Content type' => $itemType])); } /** @@ -116,7 +116,7 @@ public function verifyThereIsItemInSubItemList(string $itemName, string $itemTyp public function verifyThereIsNoItemInSubItemListInRoot(string $itemName, string $itemType): void { $this->contentViewPage->verifyIsLoaded(); - Assert::assertFalse($this->contentViewPage->isChildElementPresent(['Name' => $itemName, 'Content type' => $itemType])); + Assert::false($this->contentViewPage->isChildElementPresent(['Name' => $itemName, 'Content type' => $itemType])); } /** @@ -181,7 +181,7 @@ public function iCreateNewUrlAlias(string $path, string $languageName, string $r */ public function verifyUrlAliasExists(string $path, string $type): void { - Assert::assertTrue( + Assert::true( $this->contentViewPage->isUrlAliasOnTheList($path, $type), sprintf('Url alias "%s" with type "%s" not found', $path, $type) ); diff --git a/src/lib/Behat/BrowserContext/DashboardContext.php b/src/lib/Behat/BrowserContext/DashboardContext.php index 11b15ea65c..68aaa19bab 100644 --- a/src/lib/Behat/BrowserContext/DashboardContext.php +++ b/src/lib/Behat/BrowserContext/DashboardContext.php @@ -12,7 +12,7 @@ use Ibexa\AdminUi\Behat\Component\UpperMenu; use Ibexa\AdminUi\Behat\Page\ContentUpdateItemPage; use Ibexa\AdminUi\Behat\Page\DashboardPage; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final readonly class DashboardContext implements Context { @@ -36,7 +36,7 @@ public function iGoToDashboard(): void */ public function goingToDashboardISeeDraft(string $draftName): void { - Assert::assertTrue($this->dashboardPage->isDraftOnList($draftName)); + Assert::true($this->dashboardPage->isDraftOnList($draftName)); } /** @@ -44,7 +44,7 @@ public function goingToDashboardISeeDraft(string $draftName): void */ public function goingToDashboardISeeNoDraft(string $draftName): void { - Assert::assertFalse($this->dashboardPage->isDraftOnList($draftName)); + Assert::false($this->dashboardPage->isDraftOnList($draftName)); } /** diff --git a/src/lib/Behat/BrowserContext/LanguageContext.php b/src/lib/Behat/BrowserContext/LanguageContext.php index d79b008396..f53785c9e5 100644 --- a/src/lib/Behat/BrowserContext/LanguageContext.php +++ b/src/lib/Behat/BrowserContext/LanguageContext.php @@ -12,7 +12,7 @@ use Behat\Gherkin\Node\TableNode; use Ibexa\AdminUi\Behat\Page\LanguagePage; use Ibexa\AdminUi\Behat\Page\LanguagesPage; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final readonly class LanguageContext implements Context { @@ -35,7 +35,7 @@ public function deleteLanguage(): void */ public function thereSNoLanguageOnLanguageList(string $languageName): void { - Assert::assertFalse($this->languagesPage->isLanguageOnTheList($languageName)); + Assert::false($this->languagesPage->isLanguageOnTheList($languageName)); } /** @@ -51,7 +51,7 @@ public function deleteLanguageNamed(string $languageName): void */ public function thereALanguageOnLanguageList(string $languageName): void { - Assert::assertTrue($this->languagesPage->isLanguageOnTheList($languageName)); + Assert::true($this->languagesPage->isLanguageOnTheList($languageName)); } /** @@ -72,7 +72,7 @@ public function languageHasProperAttributes(TableNode $languageData): void $expectedCode = $languageData->getHash()[0]['Language code']; $expectedEnabledFlag = $languageData->getHash()[0]['Enabled']; - Assert::assertTrue( + Assert::true( $this->languagePage->hasProperties([ 'Name' => $expectedName, 'Language code' => $expectedCode, diff --git a/src/lib/Behat/BrowserContext/MyDraftsContext.php b/src/lib/Behat/BrowserContext/MyDraftsContext.php index 428430f643..f988117934 100644 --- a/src/lib/Behat/BrowserContext/MyDraftsContext.php +++ b/src/lib/Behat/BrowserContext/MyDraftsContext.php @@ -10,7 +10,7 @@ use Behat\Behat\Context\Context; use Ibexa\AdminUi\Behat\Page\MyDraftsPage; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final readonly class MyDraftsContext implements Context { @@ -32,7 +32,7 @@ public function iDeleteADraftFromTheList(string $draftName): void */ public function iSeeTheDraftIsDeleted(string $draftName): void { - Assert::assertFalse($this->myDraftsPage->isDraftOnTheList($draftName)); + Assert::false($this->myDraftsPage->isDraftOnTheList($draftName)); } /** diff --git a/src/lib/Behat/BrowserContext/NotificationContext.php b/src/lib/Behat/BrowserContext/NotificationContext.php index c94a047c32..b505e8f2a2 100644 --- a/src/lib/Behat/BrowserContext/NotificationContext.php +++ b/src/lib/Behat/BrowserContext/NotificationContext.php @@ -10,7 +10,7 @@ use Behat\Behat\Context\Context; use Ibexa\AdminUi\Behat\Component\Notification; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; /** Context for actions on notifications */ final readonly class NotificationContext implements Context @@ -29,7 +29,7 @@ public function notificationAppears(string $itemType, string $itemName, string $ $this->notification->verifyIsLoaded(); $this->notification->verifyAlertSuccess(); - Assert::assertEquals($expectedMessage, $this->notification->getMessage()); + Assert::eq($this->notification->getMessage(), $expectedMessage); $this->notification->closeAlert(); } @@ -62,7 +62,7 @@ public function specificErrorNotificationAppears(string $message): void { $this->notification->verifyIsLoaded(); $this->notification->verifyAlertFailure(); - Assert::assertStringContainsString($message, $this->notification->getMessage()); + Assert::contains($this->notification->getMessage(), $message); $this->notification->closeAlert(); } } diff --git a/src/lib/Behat/BrowserContext/ObjectStatesContext.php b/src/lib/Behat/BrowserContext/ObjectStatesContext.php index 03f51321a9..259df56295 100644 --- a/src/lib/Behat/BrowserContext/ObjectStatesContext.php +++ b/src/lib/Behat/BrowserContext/ObjectStatesContext.php @@ -13,7 +13,7 @@ use Ibexa\AdminUi\Behat\Page\ObjectStateGroupPage; use Ibexa\AdminUi\Behat\Page\ObjectStateGroupsPage; use Ibexa\AdminUi\Behat\Page\ObjectStatePage; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final readonly class ObjectStatesContext implements Context { @@ -29,7 +29,7 @@ public function __construct( */ public function isObjectStateOnTheList(string $objectStateGroupName): void { - Assert::assertTrue( + Assert::true( $this->objectStateGroupsPage->isObjectStateGroupOnTheList($objectStateGroupName) ); } @@ -58,7 +58,7 @@ public function iShouldBeOnObjectStatePage(string $objectStateGroup): void public function objectStateGroupIsEmpty(string $objectStateGroupName): void { $this->objectStateGroupPage->setExpectedObjectStateGroupName($objectStateGroupName); - Assert::assertFalse($this->objectStateGroupPage->hasObjectStates()); + Assert::false($this->objectStateGroupPage->hasObjectStates()); } /** @@ -67,7 +67,7 @@ public function objectStateGroupIsEmpty(string $objectStateGroupName): void public function objectStateGroupHasAttributes(TableNode $table): void { foreach ($table->getHash() as $row) { - Assert::assertTrue($this->objectStateGroupPage->hasAttribute($row['label'], $row['value'])); + Assert::true($this->objectStateGroupPage->hasAttribute($row['label'], $row['value'])); } } @@ -77,7 +77,7 @@ public function objectStateGroupHasAttributes(TableNode $table): void public function objectStateHasAttributes(TableNode $table): void { foreach ($table->getHash() as $row) { - Assert::assertTrue($this->objectStatePage->hasAttribute($row['label'], $row['value'])); + Assert::true($this->objectStatePage->hasAttribute($row['label'], $row['value'])); } } @@ -86,7 +86,7 @@ public function objectStateHasAttributes(TableNode $table): void */ public function noObjectStateOnTheList(string $objectStateGroupName): void { - Assert::assertFalse($this->objectStateGroupsPage->isObjectStateGroupOnTheList($objectStateGroupName)); + Assert::false($this->objectStateGroupsPage->isObjectStateGroupOnTheList($objectStateGroupName)); } /** @@ -129,7 +129,7 @@ public function thereIsNoObjectStateOnTheList(string $objectStateName, string $o $this->objectStateGroupPage->setExpectedObjectStateGroupName($objectStateGroupName); $this->objectStateGroupPage->verifyIsLoaded(); - Assert::assertFalse( + Assert::false( $this->objectStateGroupPage->hasObjectState($objectStateName), ); } @@ -142,7 +142,7 @@ public function thereIsObjectStateOnTheList(string $objectStateName, string $obj $this->objectStateGroupPage->setExpectedObjectStateGroupName($objectStateGroupName); $this->objectStateGroupPage->verifyIsLoaded(); - Assert::assertTrue( + Assert::true( $this->objectStateGroupPage->hasObjectState($objectStateName), ); } diff --git a/src/lib/Behat/BrowserContext/RolesContext.php b/src/lib/Behat/BrowserContext/RolesContext.php index 242aa29528..833eb8f8a3 100644 --- a/src/lib/Behat/BrowserContext/RolesContext.php +++ b/src/lib/Behat/BrowserContext/RolesContext.php @@ -13,7 +13,7 @@ use Ibexa\AdminUi\Behat\Page\RolePage; use Ibexa\AdminUi\Behat\Page\RolesPage; use Ibexa\AdminUi\Behat\Page\RoleUpdatePage; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final readonly class RolesContext implements Context { @@ -60,7 +60,7 @@ public function iDeleteAPolicyFromRole(string $roleName, TableNode $items): void public function thereIsAPolicy(string $moduleAndFunction, string $limitation, string $roleName): void { $this->rolePage->setExpectedRoleName($roleName); - Assert::assertTrue( + Assert::true( $this->rolePage->isRoleWithLimitationPresent($moduleAndFunction, $limitation) ); } @@ -71,7 +71,7 @@ public function thereIsAPolicy(string $moduleAndFunction, string $limitation, st public function thereIsNoPolicy(string $moduleAndFunction, string $limitation, string $roleName): void { $this->rolePage->setExpectedRoleName($roleName); - Assert::assertFalse( + Assert::false( $this->rolePage->isRoleWithLimitationPresent($moduleAndFunction, $limitation) ); } @@ -150,7 +150,7 @@ public function createNewPolicy(): void */ public function thereSNoRoleOnRoleList(string $roleName): void { - Assert::assertFalse($this->rolesPage->isRoleOnTheList($roleName)); + Assert::false($this->rolesPage->isRoleOnTheList($roleName)); } /** @@ -166,7 +166,7 @@ public function deleteRoleNamed(string $roleName): void */ public function thereARoleOnRoleList(string $roleName): void { - Assert::assertTrue($this->rolesPage->isRoleOnTheList($roleName)); + Assert::true($this->rolesPage->isRoleOnTheList($roleName)); } /** @@ -183,7 +183,7 @@ public function iShouldBeOnRolePage(string $roleName): void */ public function policiesListIsEmpty(): void { - Assert::assertFalse($this->rolePage->hasPolicies()); + Assert::false($this->rolePage->hasPolicies()); } /** @@ -199,7 +199,7 @@ public function startAssigning(string $roleName): void */ public function assignmentsListIsEmpty(): void { - Assert::assertFalse($this->rolePage->hasAssignments()); + Assert::false($this->rolePage->hasAssignments()); } /** diff --git a/src/lib/Behat/BrowserContext/SearchContext.php b/src/lib/Behat/BrowserContext/SearchContext.php index 8bd622b492..3449d04ad5 100644 --- a/src/lib/Behat/BrowserContext/SearchContext.php +++ b/src/lib/Behat/BrowserContext/SearchContext.php @@ -11,7 +11,7 @@ use Behat\Behat\Context\Context; use Ibexa\AdminUi\Behat\Component\UpperMenu; use Ibexa\AdminUi\Behat\Page\SearchPage; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final readonly class SearchContext implements Context { @@ -35,6 +35,6 @@ public function iSearchForContent(string $contentItemName): void */ public function searchResults(string $contentItemName): void { - Assert::assertTrue($this->searchPage->isElementInResults(['Name' => $contentItemName])); + Assert::true($this->searchPage->isElementInResults(['Name' => $contentItemName])); } } diff --git a/src/lib/Behat/BrowserContext/SectionsContext.php b/src/lib/Behat/BrowserContext/SectionsContext.php index a43b9cdbe5..0f178b687b 100644 --- a/src/lib/Behat/BrowserContext/SectionsContext.php +++ b/src/lib/Behat/BrowserContext/SectionsContext.php @@ -12,7 +12,7 @@ use Behat\Gherkin\Node\TableNode; use Ibexa\AdminUi\Behat\Page\SectionPage; use Ibexa\AdminUi\Behat\Page\SectionsPage; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final readonly class SectionsContext implements Context { @@ -49,7 +49,7 @@ public function sectionContainsProperContentItems(string $sectionName, TableNode $expectedName = $contentItem['Name']; $expectedContentType = $contentItem['content type']; $expectedPath = $contentItem['Path']; - Assert::assertTrue( + Assert::true( $this->sectionPage->hasAssignedItem( ['Name' => $expectedName, 'Content type' => $expectedContentType, 'Path' => $expectedPath] ) @@ -62,7 +62,7 @@ public function sectionContainsProperContentItems(string $sectionName, TableNode */ public function thereSNoSectionOnSectionList(string $sectionName): void { - Assert::assertFalse($this->sectionsPage->isSectionOnTheList($sectionName)); + Assert::false($this->sectionsPage->isSectionOnTheList($sectionName)); } /** @@ -94,7 +94,7 @@ public function deleteSectionNamed(string $sectionName): void */ public function thereASectionOnSectionList(string $sectionName): void { - Assert::assertTrue($this->sectionsPage->isSectionOnTheList($sectionName)); + Assert::true($this->sectionsPage->isSectionOnTheList($sectionName)); } /** @@ -102,7 +102,7 @@ public function thereASectionOnSectionList(string $sectionName): void */ public function sectionOnSectionListHasNoAssignedContentItems(string $sectionName): void { - Assert::assertEquals(0, $this->sectionsPage->getAssignedContentItemsCount($sectionName)); + Assert::eq($this->sectionsPage->getAssignedContentItemsCount($sectionName), 0); } /** @@ -111,7 +111,7 @@ public function sectionOnSectionListHasNoAssignedContentItems(string $sectionNam public function sectionHasNoAssignedContentItems(string $sectionName): void { $this->sectionPage->setExpectedSectionName($sectionName); - Assert::assertEquals(0, $this->sectionPage->hasAssignedItems()); + Assert::eq($this->sectionPage->hasAssignedItems(), 0); } /** @@ -128,7 +128,7 @@ public function iShouldBeOnSectionPage(string $sectionName): void */ public function contentListIsEmpty(): void { - Assert::assertTrue($this->sectionPage->isContentListEmpty()); + Assert::true($this->sectionPage->isContentListEmpty()); } /** @@ -147,7 +147,7 @@ public function sectionHasProperAttributes(TableNode $sectionData): void $expectedSectionName = $sectionData->getHash()[0]['Name']; $expectedSectionIdentifier = $sectionData->getHash()[0]['Identifier']; - Assert::assertTrue( + Assert::true( $this->sectionPage->hasProperties(['Name' => $expectedSectionName, 'Identifier' => $expectedSectionIdentifier]) ); } @@ -175,7 +175,7 @@ public function editSection(): void */ public function sectionHasAssignedContentItems(string $sectionName): void { - Assert::assertGreaterThan(0, $this->sectionsPage->getAssignedContentItemsCount($sectionName)); + Assert::greaterThan($this->sectionsPage->getAssignedContentItemsCount($sectionName), 0); } /** @@ -183,6 +183,6 @@ public function sectionHasAssignedContentItems(string $sectionName): void */ public function sectionCannotBeSelected(string $sectionName): void { - Assert::assertFalse($this->sectionsPage->canBeSelected($sectionName)); + Assert::false($this->sectionsPage->canBeSelected($sectionName)); } } diff --git a/src/lib/Behat/BrowserContext/TrashContext.php b/src/lib/Behat/BrowserContext/TrashContext.php index 20851b4048..2a898d2386 100644 --- a/src/lib/Behat/BrowserContext/TrashContext.php +++ b/src/lib/Behat/BrowserContext/TrashContext.php @@ -11,7 +11,7 @@ use Behat\Behat\Context\Context; use Behat\Gherkin\Node\TableNode; use Ibexa\AdminUi\Behat\Page\TrashPage; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final readonly class TrashContext implements Context { @@ -24,7 +24,7 @@ public function __construct(private TrashPage $trashPage) */ public function trashIsEmpty(): void { - Assert::assertTrue( + Assert::true( $this->trashPage->isEmpty(), 'Trash is not empty.' ); @@ -35,7 +35,7 @@ public function trashIsEmpty(): void */ public function trashIsNotEmpty(): void { - Assert::assertFalse( + Assert::false( $this->trashPage->isEmpty(), 'Trash is empty.' ); @@ -90,7 +90,7 @@ public function iRestoreItemFromTrashUnderNewLocation(TableNode $itemsTable, str */ public function thereIsItemOnTrashList(string $itemType, string $itemName): void { - Assert::assertTrue($this->trashPage->hasElement($itemType, $itemName)); + Assert::true($this->trashPage->hasElement($itemType, $itemName)); } /** @@ -98,7 +98,7 @@ public function thereIsItemOnTrashList(string $itemType, string $itemName): void */ public function thereIsNoItemOnTrashList(string $itemType, string $itemName): void { - Assert::assertFalse($this->trashPage->hasElement($itemType, $itemName)); + Assert::false($this->trashPage->hasElement($itemType, $itemName)); } /** diff --git a/src/lib/Behat/BrowserContext/UDWContext.php b/src/lib/Behat/BrowserContext/UDWContext.php index 49b69306fa..52de506173 100644 --- a/src/lib/Behat/BrowserContext/UDWContext.php +++ b/src/lib/Behat/BrowserContext/UDWContext.php @@ -11,7 +11,7 @@ use Behat\Behat\Context\Context; use Ibexa\AdminUi\Behat\Component\UniversalDiscoveryWidget; use Ibexa\Behat\Core\Behat\ArgumentParser; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final readonly class UDWContext implements Context { @@ -74,7 +74,7 @@ public function bookmarkContentItem(string $itemPath): void */ public function itemIsMarkedAsBookmarked(): void { - Assert::assertTrue($this->universalDiscoveryWidget->isBookmarked()); + Assert::true($this->universalDiscoveryWidget->isBookmarked()); } /** diff --git a/src/lib/Behat/BrowserContext/UserNotificationContext.php b/src/lib/Behat/BrowserContext/UserNotificationContext.php index a2fde795bd..cb7e93cd5b 100644 --- a/src/lib/Behat/BrowserContext/UserNotificationContext.php +++ b/src/lib/Behat/BrowserContext/UserNotificationContext.php @@ -13,7 +13,7 @@ use Ibexa\AdminUi\Behat\Component\UpperMenu; use Ibexa\AdminUi\Behat\Component\UserNotificationPopup; use Ibexa\AdminUi\Behat\Page\NotificationsViewAllPage; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final readonly class UserNotificationContext implements Context { @@ -37,7 +37,7 @@ public function __construct(UpperMenu $upperMenu, UserNotificationPopup $userNot */ public function thereIsNotificationForCurrentUser(): void { - Assert::assertTrue($this->upperMenu->hasUnreadNotification()); + Assert::true($this->upperMenu->hasUnreadNotification()); } /** @@ -138,7 +138,7 @@ public function iMarkNotificationAsUnread(string $notificationTitle): void */ public function verifyNotificationStatus(string $notificationTitle, string $notificationStatus): void { - Assert::assertEquals($notificationStatus, $this->notificationsViewAllPage->getStatusForNotification($notificationTitle)); + Assert::eq($this->notificationsViewAllPage->getStatusForNotification($notificationTitle), $notificationStatus); } /** diff --git a/src/lib/Behat/Component/Breadcrumb.php b/src/lib/Behat/Component/Breadcrumb.php index 68157816a0..f30235381d 100644 --- a/src/lib/Behat/Component/Breadcrumb.php +++ b/src/lib/Behat/Component/Breadcrumb.php @@ -11,7 +11,7 @@ use Ibexa\Behat\Browser\Component\Component; use Ibexa\Behat\Browser\Element\Criterion\ElementTextCriterion; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class Breadcrumb extends Component { @@ -36,7 +36,7 @@ public function getBreadcrumb(): string public function verifyIsLoaded(): void { - Assert::assertTrue($this->getHTMLPage()->find($this->getLocator('breadcrumbItem'))->isVisible()); + Assert::true($this->getHTMLPage()->find($this->getLocator('breadcrumbItem'))->isVisible()); } protected function specifyLocators(): array diff --git a/src/lib/Behat/Component/ContentTree.php b/src/lib/Behat/Component/ContentTree.php index 09a692f095..4cb41b9552 100644 --- a/src/lib/Behat/Component/ContentTree.php +++ b/src/lib/Behat/Component/ContentTree.php @@ -10,7 +10,7 @@ use Ibexa\Behat\Browser\Component\Component; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class ContentTree extends Component { @@ -21,7 +21,7 @@ public function verifyIsLoaded(): void public function verifyItemExists(string $itemPath): void { - Assert::assertTrue($this->itemExists($itemPath)); + Assert::true($this->itemExists($itemPath)); } private function itemExists(string $itemPath): bool diff --git a/src/lib/Behat/Component/Fields/Authors.php b/src/lib/Behat/Component/Fields/Authors.php index 83dbc2ed91..fcf1f07816 100644 --- a/src/lib/Behat/Component/Fields/Authors.php +++ b/src/lib/Behat/Component/Fields/Authors.php @@ -10,7 +10,7 @@ use Ibexa\Behat\Browser\Locator\CSSLocatorBuilder; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class Authors extends FieldTypeComponent { @@ -52,15 +52,15 @@ public function verifyValueInEditView(array $values): void $expectedEmail = $values['email']; $actualFieldValues = $this->getValue(); - Assert::assertEquals( - $expectedName, + Assert::eq( $actualFieldValues['name'], + $expectedName, sprintf('Field %s has wrong value', $values['label']) ); - Assert::assertEquals( - $expectedEmail, + Assert::eq( $actualFieldValues['email'], + $expectedEmail, sprintf('Field %s has wrong value', $values['label']) ); } @@ -70,9 +70,9 @@ public function verifyValueInEditView(array $values): void */ public function verifyValueInItemView(array $values): void { - Assert::assertEquals( - sprintf('%s <%s>', $values['name'], $values['email']), + Assert::eq( $this->getHTMLPage()->find($this->parentLocator)->getText(), + sprintf('%s <%s>', $values['name'], $values['email']), 'Field has wrong value' ); } diff --git a/src/lib/Behat/Component/Fields/Checkbox.php b/src/lib/Behat/Component/Fields/Checkbox.php index a903c7f3ac..476fdf80fb 100644 --- a/src/lib/Behat/Component/Fields/Checkbox.php +++ b/src/lib/Behat/Component/Fields/Checkbox.php @@ -10,7 +10,7 @@ use Ibexa\Behat\Browser\Locator\CSSLocatorBuilder; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class Checkbox extends FieldTypeComponent { @@ -53,9 +53,9 @@ public function verifyValueInItemView(array $values): void { $expectedValue = $values['value'] === 'true' ? 'Yes' : 'No'; - Assert::assertEquals( - $expectedValue, + Assert::eq( $this->getHTMLPage()->find($this->parentLocator)->getText(), + $expectedValue, 'Field has wrong value' ); } diff --git a/src/lib/Behat/Component/Fields/ContentQuery.php b/src/lib/Behat/Component/Fields/ContentQuery.php index a2e24d4386..6156d518dc 100644 --- a/src/lib/Behat/Component/Fields/ContentQuery.php +++ b/src/lib/Behat/Component/Fields/ContentQuery.php @@ -11,7 +11,7 @@ use Ibexa\Behat\Browser\Element\Mapper\ElementTextMapper; use Ibexa\Behat\Browser\Locator\CSSLocatorBuilder; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class ContentQuery extends NonEditableField { @@ -24,7 +24,7 @@ public function verifyValueInItemView(array $values): void $actualItems = $this->getValueInItemView(); $commonItems = array_intersect($expectedItems, $actualItems); - Assert::assertEquals([], array_diff($expectedItems, $commonItems)); + Assert::eq(array_diff($expectedItems, $commonItems), []); } public function specifyLocators(): array diff --git a/src/lib/Behat/Component/Fields/ContentRelationMultiple.php b/src/lib/Behat/Component/Fields/ContentRelationMultiple.php index 5988c27ec3..0830fec0a6 100644 --- a/src/lib/Behat/Component/Fields/ContentRelationMultiple.php +++ b/src/lib/Behat/Component/Fields/ContentRelationMultiple.php @@ -14,7 +14,7 @@ use Ibexa\AdminUi\Behat\Component\UniversalDiscoveryWidget; use Ibexa\Behat\Browser\Locator\CSSLocatorBuilder; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class ContentRelationMultiple extends FieldTypeComponent { @@ -76,14 +76,14 @@ public function verifyValueInItemView(array $values): void $secondValue = $explodedValue[count($explodedValue) - 1]; $viewPatternRegex = '/Multiple relations[\w\/,: ]* %s [\w \/,:]*/'; - Assert::assertMatchesRegularExpression( - sprintf($viewPatternRegex, $firstValue), + Assert::regex( $this->getHTMLPage()->find($this->parentLocator)->getText(), + sprintf($viewPatternRegex, $firstValue), 'Field has wrong value' ); - Assert::assertMatchesRegularExpression( - sprintf($viewPatternRegex, $secondValue), + Assert::regex( $this->getHTMLPage()->find($this->parentLocator)->getText(), + sprintf($viewPatternRegex, $secondValue), 'Field has wrong value' ); } diff --git a/src/lib/Behat/Component/Fields/ContentRelationSingle.php b/src/lib/Behat/Component/Fields/ContentRelationSingle.php index 9d1c0d11f6..f2577761a7 100644 --- a/src/lib/Behat/Component/Fields/ContentRelationSingle.php +++ b/src/lib/Behat/Component/Fields/ContentRelationSingle.php @@ -15,7 +15,7 @@ use Ibexa\Behat\Browser\Element\Action\MouseOverAndClick; use Ibexa\Behat\Browser\Locator\CSSLocatorBuilder; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class ContentRelationSingle extends FieldTypeComponent { @@ -89,9 +89,9 @@ public function verifyValueInItemView(array $values): void $viewPatternRegex = '/Single relation[\w\/,: ]* %s [\w \/,:]*/'; - Assert::assertMatchesRegularExpression( - sprintf($viewPatternRegex, $value), + Assert::regex( $this->getHTMLPage()->find($this->parentLocator)->getText(), + sprintf($viewPatternRegex, $value), 'Field has wrong value' ); } diff --git a/src/lib/Behat/Component/Fields/Date.php b/src/lib/Behat/Component/Fields/Date.php index 44a8c343af..4c0d7fb157 100644 --- a/src/lib/Behat/Component/Fields/Date.php +++ b/src/lib/Behat/Component/Fields/Date.php @@ -12,7 +12,7 @@ use Ibexa\AdminUi\Behat\Component\DateAndTimePopup; use Ibexa\Behat\Browser\Locator\CSSLocatorBuilder; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class Date extends FieldTypeComponent { @@ -53,9 +53,9 @@ public function verifyValueInItemView(array $values): void { $expectedDateTime = date_create($values['value']); $actualDateTime = date_create($this->getHTMLPage()->find($this->parentLocator)->getText()); - Assert::assertEquals( - $expectedDateTime, + Assert::eq( $actualDateTime, + $expectedDateTime, 'Field has wrong value' ); } diff --git a/src/lib/Behat/Component/Fields/DateAndTime.php b/src/lib/Behat/Component/Fields/DateAndTime.php index 3c233d30b6..28d3f298d3 100644 --- a/src/lib/Behat/Component/Fields/DateAndTime.php +++ b/src/lib/Behat/Component/Fields/DateAndTime.php @@ -12,7 +12,7 @@ use Ibexa\AdminUi\Behat\Component\DateAndTimePopup; use Ibexa\Behat\Browser\Locator\CSSLocatorBuilder; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class DateAndTime extends FieldTypeComponent { @@ -56,7 +56,7 @@ public function setValue(array $parameters): void self::VIEW_DATE_TIME_FORMAT ); - Assert::assertEquals($expectedDateAndTimeValue, $actualTimeValue); + Assert::eq($actualTimeValue, $expectedDateAndTimeValue); } public function getValue(): array @@ -81,9 +81,9 @@ public function verifyValueInItemView(array $values): void self::VIEW_DATE_TIME_FORMAT ); - Assert::assertEquals( - $expectedDate, + Assert::eq( $actualDate, + $expectedDate, 'Field has wrong value' ); } diff --git a/src/lib/Behat/Component/Fields/FieldTypeComponent.php b/src/lib/Behat/Component/Fields/FieldTypeComponent.php index 2601fb5242..e68ceb8c0e 100644 --- a/src/lib/Behat/Component/Fields/FieldTypeComponent.php +++ b/src/lib/Behat/Component/Fields/FieldTypeComponent.php @@ -11,7 +11,7 @@ use Ibexa\Behat\Browser\Component\Component; use Ibexa\Behat\Browser\Locator\CSSLocatorBuilder; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; abstract class FieldTypeComponent extends Component implements FieldTypeComponentInterface { @@ -48,9 +48,9 @@ public function getValue(): array public function verifyValueInItemView(array $values): void { - Assert::assertEquals( - $values['value'], + Assert::eq( $this->getHTMLPage()->find($this->parentLocator)->getText(), + $values['value'], 'Field has wrong value' ); } @@ -64,9 +64,9 @@ abstract public function getFieldTypeIdentifier(): string; public function verifyValueInEditView(array $values): void { - Assert::assertEquals( - $values['value'], - $this->getValue()[0] + Assert::eq( + $this->getValue()[0], + $values['value'] ); } diff --git a/src/lib/Behat/Component/Fields/File.php b/src/lib/Behat/Component/Fields/File.php index 7e506f676b..fdb3d3a7b6 100644 --- a/src/lib/Behat/Component/Fields/File.php +++ b/src/lib/Behat/Component/Fields/File.php @@ -13,7 +13,7 @@ use Ibexa\Behat\Browser\Locator\CSSLocator; use Ibexa\Behat\Browser\Locator\CSSLocatorBuilder; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class File extends FieldTypeComponent { @@ -39,9 +39,9 @@ public function verifyValueInItemView(array $values): void { $filename = str_replace('.zip', '', $values['value']); - Assert::assertStringContainsString( - $filename, + Assert::contains( $this->getHTMLPage()->find($this->parentLocator)->getText(), + $filename, 'Image has wrong file name' ); @@ -49,9 +49,9 @@ public function verifyValueInItemView(array $values): void ->withDescendant($this->getLocator('file')) ->build(); - Assert::assertStringContainsString( - $filename, + Assert::contains( $this->getHTMLPage()->find($fileFieldSelector)->getAttribute('href'), + $filename, 'File has wrong href' ); } diff --git a/src/lib/Behat/Component/Fields/Image.php b/src/lib/Behat/Component/Fields/Image.php index 6d1421f998..15acbbe127 100644 --- a/src/lib/Behat/Component/Fields/Image.php +++ b/src/lib/Behat/Component/Fields/Image.php @@ -13,7 +13,7 @@ use Ibexa\Behat\Browser\Locator\CSSLocator; use Ibexa\Behat\Browser\Locator\CSSLocatorBuilder; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; class Image extends FieldTypeComponent { @@ -49,9 +49,9 @@ public function verifyValueInItemView(array $values): void { $filename = str_replace('.zip', '', $values['value']); - Assert::assertStringContainsString( - $filename, + Assert::contains( $this->getHTMLPage()->find($this->parentLocator)->getText(), + $filename, 'Image has wrong file name' ); @@ -59,9 +59,9 @@ public function verifyValueInItemView(array $values): void ->withDescendant($this->getLocator('image')) ->build(); - Assert::assertStringContainsString( - $filename, + Assert::contains( $this->getHTMLPage()->setTimeout(5)->find($fileFieldSelector)->getAttribute('src'), + $filename, 'Image has wrong source' ); } diff --git a/src/lib/Behat/Component/Fields/ImageAsset.php b/src/lib/Behat/Component/Fields/ImageAsset.php index 23404100fa..772145744a 100644 --- a/src/lib/Behat/Component/Fields/ImageAsset.php +++ b/src/lib/Behat/Component/Fields/ImageAsset.php @@ -15,7 +15,7 @@ use Ibexa\Behat\Browser\FileUpload\FileUploadHelper; use Ibexa\Behat\Browser\Locator\CSSLocatorBuilder; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class ImageAsset extends Image { @@ -45,7 +45,7 @@ public function setValue(array $parameters): void $this->notification->verifyAlertSuccess(); - Assert::assertEquals(self::IMAGE_ASSET_NOTIFICATION_MESSAGE, $this->notification->getMessage()); + Assert::eq($this->notification->getMessage(), self::IMAGE_ASSET_NOTIFICATION_MESSAGE); } public function selectFromRepository(string $path): void diff --git a/src/lib/Behat/Component/Fields/Keywords.php b/src/lib/Behat/Component/Fields/Keywords.php index 5f8902d255..69a0edd8e8 100644 --- a/src/lib/Behat/Component/Fields/Keywords.php +++ b/src/lib/Behat/Component/Fields/Keywords.php @@ -11,7 +11,7 @@ use Ibexa\Behat\Browser\Element\ElementInterface; use Ibexa\Behat\Browser\Locator\CSSLocatorBuilder; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class Keywords extends FieldTypeComponent { @@ -69,7 +69,7 @@ public function verifyValueInItemView(array $values): void }); sort($actualValues); - Assert::assertEquals($expectedValues, $actualValues); + Assert::eq($actualValues, $expectedValues); } /** diff --git a/src/lib/Behat/Component/Fields/MapLocation.php b/src/lib/Behat/Component/Fields/MapLocation.php index b9ed248dfd..1d0fd7b242 100644 --- a/src/lib/Behat/Component/Fields/MapLocation.php +++ b/src/lib/Behat/Component/Fields/MapLocation.php @@ -10,7 +10,7 @@ use Ibexa\Behat\Browser\Locator\CSSLocatorBuilder; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; use RuntimeException; final class MapLocation extends FieldTypeComponent @@ -60,19 +60,19 @@ public function verifyValueInEditView(array $values): void $expectedLongitude = $values['longitude']; $expectedAddress = $values['address']; - Assert::assertEquals( - $expectedLatitude, + Assert::eq( $this->getValue()['latitude'], + $expectedLatitude, sprintf('Field %s has wrong latitude value', $values['label']) ); - Assert::assertEquals( - $expectedLongitude, + Assert::eq( $this->getValue()['longitude'], + $expectedLongitude, sprintf('Field %s has wrong longitude value', $values['label']) ); - Assert::assertEquals( - $expectedAddress, + Assert::eq( $this->getValue()['address'], + $expectedAddress, sprintf('Field %s has wrong address value', $values['label']) ); } @@ -97,9 +97,9 @@ public function verifyValueInItemView(array $values): void $actualLatitude = $this->formatToOneDecimalPlace($matches[2]); $actualLongitude = $this->formatToOneDecimalPlace($matches[3]); - Assert::assertEquals($values['address'], $actualAddress); - Assert::assertEquals($values['latitude'], $actualLatitude); - Assert::assertEquals($values['longitude'], $actualLongitude); + Assert::eq($actualAddress, $values['address']); + Assert::eq($actualLatitude, $values['latitude']); + Assert::eq($actualLongitude, $values['longitude']); } public function getFieldTypeIdentifier(): string diff --git a/src/lib/Behat/Component/Fields/Matrix.php b/src/lib/Behat/Component/Fields/Matrix.php index 7179f4b710..b58c887556 100644 --- a/src/lib/Behat/Component/Fields/Matrix.php +++ b/src/lib/Behat/Component/Fields/Matrix.php @@ -11,7 +11,7 @@ use Ibexa\Behat\Browser\Element\Mapper\ElementTextMapper; use Ibexa\Behat\Browser\Locator\LocatorInterface; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class Matrix extends FieldTypeComponent { @@ -50,7 +50,7 @@ public function verifyValueInItemView(array $values): void $this->getLocator('viewModeTableRow') ); - Assert::assertEquals($values['value'], $parsedTable); + Assert::eq($parsedTable, $values['value']); } public function getFieldTypeIdentifier(): string diff --git a/src/lib/Behat/Component/Fields/Media.php b/src/lib/Behat/Component/Fields/Media.php index 4782de3b16..17deeb9845 100644 --- a/src/lib/Behat/Component/Fields/Media.php +++ b/src/lib/Behat/Component/Fields/Media.php @@ -13,7 +13,7 @@ use Ibexa\Behat\Browser\Locator\CSSLocator; use Ibexa\Behat\Browser\Locator\CSSLocatorBuilder; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class Media extends FieldTypeComponent { @@ -38,19 +38,19 @@ public function verifyValueInItemView(array $values): void { $filename = str_replace('.zip', '', $values['value']); - Assert::assertStringContainsString( - $filename, + Assert::contains( $this->getHTMLPage()->find($this->parentLocator)->getText(), + $filename, 'Media has wrong file name' ); - Assert::assertStringContainsString( - $filename, + Assert::contains( $this->getHTMLPage()->find( CSSLocatorBuilder::base($this->parentLocator) ->withDescendant($this->getLocator('video')) ->build() )->getAttribute('src'), + $filename, 'Media has wrong source' ); } diff --git a/src/lib/Behat/Component/Fields/RichText.php b/src/lib/Behat/Component/Fields/RichText.php index ed88a00901..f8ae84047e 100644 --- a/src/lib/Behat/Component/Fields/RichText.php +++ b/src/lib/Behat/Component/Fields/RichText.php @@ -13,7 +13,7 @@ use Ibexa\Behat\Browser\Element\ElementInterface; use Ibexa\Behat\Browser\Element\Mapper\ElementTextMapper; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; class RichText extends FieldTypeComponent { @@ -93,9 +93,9 @@ public function insertLine(mixed $value, string $style = ''): void $styleHTMLTag = self::STYLE_MAPPING[$style]; - Assert::assertStringContainsString( - sprintf('%s', $value, $styleHTMLTag), - $this->getHTMLPage()->find($this->parentLocator)->find(new VisibleCSSLocator('style', $styleHTMLTag))->getOuterHtml() + Assert::contains( + $this->getHTMLPage()->find($this->parentLocator)->find(new VisibleCSSLocator('style', $styleHTMLTag))->getOuterHtml(), + sprintf('%s', $value, $styleHTMLTag) ); } @@ -120,7 +120,7 @@ public function addUnorderedList(array $listElements): void ->findAll($this->getLocator('unorderedListElement')) ->mapBy(new ElementTextMapper()); - Assert::assertEquals($listElements, $actualListElements); + Assert::eq($actualListElements, $listElements); $this->insertNewLine(); $this->executeCommand('outdentList'); diff --git a/src/lib/Behat/Component/Fields/Time.php b/src/lib/Behat/Component/Fields/Time.php index 46b1ef15b7..fc5772bf44 100644 --- a/src/lib/Behat/Component/Fields/Time.php +++ b/src/lib/Behat/Component/Fields/Time.php @@ -12,7 +12,7 @@ use Ibexa\AdminUi\Behat\Component\DateAndTimePopup; use Ibexa\Behat\Browser\Locator\CSSLocatorBuilder; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class Time extends FieldTypeComponent { @@ -45,7 +45,7 @@ public function setValue(array $parameters): void $expectedTimeValue = date_format(date_create($parameters['value']), self::VALUE_TIME_FORMAT); $actualTimeValue = date_format(date_create($this->getHTMLPage()->find($fieldSelector)->getValue()), self::VALUE_TIME_FORMAT); - Assert::assertEquals($expectedTimeValue, $actualTimeValue); + Assert::eq($actualTimeValue, $expectedTimeValue); } public function verifyValueInItemView(array $values): void @@ -56,9 +56,9 @@ public function verifyValueInItemView(array $values): void ); $expectedTimeValue = date_format(date_create($values['value']), self::VALUE_TIME_FORMAT); - Assert::assertEquals( - $expectedTimeValue, + Assert::eq( $actualTimeValue, + $expectedTimeValue, 'Field has wrong value' ); } diff --git a/src/lib/Behat/Component/Fields/URL.php b/src/lib/Behat/Component/Fields/URL.php index ab7a978cfc..22f13eeb6a 100644 --- a/src/lib/Behat/Component/Fields/URL.php +++ b/src/lib/Behat/Component/Fields/URL.php @@ -10,7 +10,7 @@ use Ibexa\Behat\Browser\Locator\CSSLocatorBuilder; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class URL extends FieldTypeComponent { @@ -48,23 +48,23 @@ public function getSpecificFieldValue(string $fieldName): string public function verifyValueInEditView(array $values): void { - Assert::assertEquals( - $values['url'], + Assert::eq( $this->getValue()['url'], + $values['url'], sprintf('Field %s has wrong value', $values['label']) ); - Assert::assertEquals( - $values['text'], + Assert::eq( $this->getValue()['text'], + $values['text'], sprintf('Field %s has wrong value', $values['label']) ); } public function verifyValueInItemView(array $values): void { - Assert::assertEquals( - $values['text'], + Assert::eq( $this->getHTMLPage()->find($this->parentLocator)->getText(), + $values['text'], 'Field has wrong value' ); @@ -72,9 +72,9 @@ public function verifyValueInItemView(array $values): void ->withDescendant(new VisibleCSSLocator('', 'a')) ->build(); - Assert::assertEquals( - $values['url'], + Assert::eq( $this->getHTMLPage()->find($urlSelector)->getAttribute('href'), + $values['url'], 'Field has wrong value' ); } diff --git a/src/lib/Behat/Component/Fields/User.php b/src/lib/Behat/Component/Fields/User.php index a7953c9041..bcc85c7782 100644 --- a/src/lib/Behat/Component/Fields/User.php +++ b/src/lib/Behat/Component/Fields/User.php @@ -12,7 +12,7 @@ use Ibexa\Behat\Browser\Element\Mapper\ElementTextMapper; use Ibexa\Behat\Browser\Locator\CSSLocatorBuilder; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class User extends FieldTypeComponent { @@ -53,14 +53,14 @@ public function getSpecificFieldValue(string $fieldName): string */ public function verifyValue(array $value): void { - Assert::assertEquals( - $value['username'], + Assert::eq( $this->getValue()['username'], + $value['username'], sprintf('Field %s has wrong value', $value['label']) ); - Assert::assertEquals( - $value['email'], + Assert::eq( $this->getValue()['email'], + $value['email'], sprintf('Field %s has wrong value', $value['label']) ); } @@ -75,9 +75,9 @@ public function verifyValueInItemView(array $values): void ->findAll($locator) ->mapBy(new ElementTextMapper()); - Assert::assertEquals($values['Username'], $actualUsername, sprintf('Expected: %s Actual: %s', $values['Username'], $actualUsername)); - Assert::assertEquals($values['Email'], $actualEmail, sprintf('Expected: %s Actual: %s', $values['Email'], $actualEmail)); - Assert::assertEquals($values['Enabled'], $actualEnabled, sprintf('Expected: %s Actual: %s', $values['Enabled'], $actualEnabled)); + Assert::eq($actualUsername, $values['Username'], sprintf('Expected: %s Actual: %s', $values['Username'], $actualUsername)); + Assert::eq($actualEmail, $values['Email'], sprintf('Expected: %s Actual: %s', $values['Email'], $actualEmail)); + Assert::eq($actualEnabled, $values['Enabled'], sprintf('Expected: %s Actual: %s', $values['Enabled'], $actualEnabled)); } protected function specifyLocators(): array diff --git a/src/lib/Behat/Component/LanguagePicker.php b/src/lib/Behat/Component/LanguagePicker.php index b385281072..0ed299ec25 100644 --- a/src/lib/Behat/Component/LanguagePicker.php +++ b/src/lib/Behat/Component/LanguagePicker.php @@ -12,7 +12,7 @@ use Ibexa\Behat\Browser\Element\Criterion\ElementTextCriterion; use Ibexa\Behat\Browser\Element\ElementInterface; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class LanguagePicker extends Component { @@ -43,7 +43,7 @@ public function isVisible(): bool public function verifyIsLoaded(): void { - Assert::assertTrue($this->isVisible()); + Assert::true($this->isVisible()); } protected function specifyLocators(): array diff --git a/src/lib/Behat/Component/Notification.php b/src/lib/Behat/Component/Notification.php index 96e0d30060..7fc5577855 100644 --- a/src/lib/Behat/Component/Notification.php +++ b/src/lib/Behat/Component/Notification.php @@ -11,7 +11,7 @@ use Ibexa\Behat\Browser\Component\Component; use Ibexa\Behat\Browser\Element\Condition\ElementExistsCondition; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class Notification extends Component { @@ -37,7 +37,7 @@ public function verifyAlertWarning(): void public function verifyAlertFailure(): void { - Assert::assertTrue( + Assert::true( $this->getHTMLPage() ->setTimeout(self::TIMEOUT) ->find($this->getLocator('failureAlert')) diff --git a/src/lib/Behat/Component/SubItemsList.php b/src/lib/Behat/Component/SubItemsList.php index 9b8df1c45f..73363cfde2 100644 --- a/src/lib/Behat/Component/SubItemsList.php +++ b/src/lib/Behat/Component/SubItemsList.php @@ -18,7 +18,7 @@ use Ibexa\Behat\Browser\Element\Criterion\ElementTextCriterion; use Ibexa\Behat\Browser\Locator\CSSLocator; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class SubItemsList extends Component { @@ -75,7 +75,7 @@ public function shouldHaveGridViewEnabled(bool $enabled): void public function verifyIsLoaded(): void { - Assert::assertTrue($this->getHTMLPage()->find($this->getLocator('table'))->isVisible()); + Assert::true($this->getHTMLPage()->find($this->getLocator('table'))->isVisible()); $this->getHTMLPage()->setTimeout(10)->waitUntilCondition( new ElementNotExistsCondition($this->getHTMLPage(), $this->getLocator('spinner')) ); diff --git a/src/lib/Behat/Component/Table/Table.php b/src/lib/Behat/Component/Table/Table.php index 34d8380559..78fda2523b 100644 --- a/src/lib/Behat/Component/Table/Table.php +++ b/src/lib/Behat/Component/Table/Table.php @@ -18,7 +18,7 @@ use Ibexa\Behat\Browser\Locator\CSSLocator; use Ibexa\Behat\Browser\Locator\LocatorCollection; use Ibexa\Behat\Browser\Locator\LocatorInterface; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class Table extends Component implements TableInterface { @@ -242,9 +242,9 @@ private function getHeaderPositions(array $searchedHeaders, array $allHeaders): return in_array($header, $searchedHeaders, true); }); - Assert::assertCount( - count($searchedHeaders), + Assert::count( $foundHeaders, + count($searchedHeaders), sprintf('Could not find all expected headers in the table. Found: %s', implode(',', $foundHeaders)) ); diff --git a/src/lib/Behat/Component/TableNavigationTab.php b/src/lib/Behat/Component/TableNavigationTab.php index 3f74a03edf..b4bc0df715 100644 --- a/src/lib/Behat/Component/TableNavigationTab.php +++ b/src/lib/Behat/Component/TableNavigationTab.php @@ -11,7 +11,7 @@ use Ibexa\Behat\Browser\Component\Component; use Ibexa\Behat\Browser\Element\Criterion\ElementTextFragmentCriterion; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class TableNavigationTab extends Component { @@ -34,7 +34,7 @@ public function goToTab(string $tabName): void public function verifyIsLoaded(): void { - Assert::assertTrue($this->getHTMLPage()->find($this->getLocator('activeNavLink'))->isVisible()); + Assert::true($this->getHTMLPage()->find($this->getLocator('activeNavLink'))->isVisible()); } protected function specifyLocators(): array diff --git a/src/lib/Behat/Page/AdminUpdateItemPage.php b/src/lib/Behat/Page/AdminUpdateItemPage.php index 35f9382439..a77e160a8d 100644 --- a/src/lib/Behat/Page/AdminUpdateItemPage.php +++ b/src/lib/Behat/Page/AdminUpdateItemPage.php @@ -18,7 +18,7 @@ use Ibexa\Behat\Browser\Locator\XPathLocator; use Ibexa\Behat\Browser\Page\Page; use Ibexa\Behat\Browser\Routing\Router; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; class AdminUpdateItemPage extends Page { @@ -75,7 +75,7 @@ public function clickButton(string $label): void public function verifyIsLoaded(): void { $this->contentActionsMenu->verifyIsLoaded(); - Assert::assertTrue($this->getHTMLPage()->find($this->getLocator('formElement'))->isVisible()); + Assert::true($this->getHTMLPage()->find($this->getLocator('formElement'))->isVisible()); } protected function specifyLocators(): array diff --git a/src/lib/Behat/Page/ContentPreviewPage.php b/src/lib/Behat/Page/ContentPreviewPage.php index 002094792a..8191f1fdca 100644 --- a/src/lib/Behat/Page/ContentPreviewPage.php +++ b/src/lib/Behat/Page/ContentPreviewPage.php @@ -11,7 +11,7 @@ use ErrorException; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; use Ibexa\Behat\Browser\Page\Page; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class ContentPreviewPage extends Page { @@ -22,7 +22,7 @@ protected function getRoute(): string public function verifyIsLoaded(): void { - Assert::assertTrue($this->getHTMLPage()->find($this->getLocator('previewNav'))->isVisible()); + Assert::true($this->getHTMLPage()->find($this->getLocator('previewNav'))->isVisible()); } public function getName(): string diff --git a/src/lib/Behat/Page/ContentTypeGroupsPage.php b/src/lib/Behat/Page/ContentTypeGroupsPage.php index 914875f77e..877e575621 100644 --- a/src/lib/Behat/Page/ContentTypeGroupsPage.php +++ b/src/lib/Behat/Page/ContentTypeGroupsPage.php @@ -15,7 +15,7 @@ use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; use Ibexa\Behat\Browser\Page\Page; use Ibexa\Behat\Browser\Routing\Router; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class ContentTypeGroupsPage extends Page { @@ -62,9 +62,9 @@ public function canBeSelected(string $contentTypeGroupName): bool public function verifyIsLoaded(): void { - Assert::assertEquals( - 'Content type groups', - $this->getHTMLPage()->find($this->getLocator('pageTitle'))->getText() + Assert::eq( + $this->getHTMLPage()->find($this->getLocator('pageTitle'))->getText(), + 'Content type groups' ); $this->getHTMLPage() ->find($this->getLocator('listHeader'))->assert()->textContains('List'); diff --git a/src/lib/Behat/Page/ContentUpdateItemPage.php b/src/lib/Behat/Page/ContentUpdateItemPage.php index ac58c3ce75..ffacfe9179 100644 --- a/src/lib/Behat/Page/ContentUpdateItemPage.php +++ b/src/lib/Behat/Page/ContentUpdateItemPage.php @@ -20,7 +20,7 @@ use Ibexa\Behat\Browser\Page\Page; use Ibexa\Behat\Browser\Routing\Router; use InvalidArgumentException; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; use RuntimeException; class ContentUpdateItemPage extends Page @@ -50,11 +50,11 @@ public function __construct( public function verifyIsLoaded(): void { if ($this->pageTitle !== null) { - Assert::assertEquals( - $this->pageTitle, + Assert::eq( $this->getHTMLPage() ->setTimeout(20) - ->find($this->getLocator('pageTitle'))->getText() + ->find($this->getLocator('pageTitle'))->getText(), + $this->pageTitle ); } $this->getHTMLPage() @@ -198,7 +198,7 @@ protected function getFieldPosition(string $fieldName): int } } - Assert::fail(sprintf('Field %s not found. Found: %s', $fieldName, implode(',', $foundFields))); + throw new \RuntimeException(sprintf('Field %s not found. Found: %s', $fieldName, implode(',', $foundFields))); } /** @@ -285,7 +285,7 @@ public function verifyAutosaveDraftIsSavedNotificationIsDisplayed(): void usleep(500000); --$iteration_count; } - Assert::fail('Draft has not been autosaved for 15 seconds'); + throw new \RuntimeException('Draft has not been autosaved for 15 seconds'); } public function isAutosaveDraftSavedNotificationVisible(): bool diff --git a/src/lib/Behat/Page/ContentViewPage.php b/src/lib/Behat/Page/ContentViewPage.php index b1effcf6b5..cb77bd634f 100644 --- a/src/lib/Behat/Page/ContentViewPage.php +++ b/src/lib/Behat/Page/ContentViewPage.php @@ -33,7 +33,7 @@ use Ibexa\Contracts\Core\Repository\Repository; use Ibexa\Contracts\Core\Repository\Values\Content\Content; use Ibexa\Contracts\Core\Repository\Values\Content\URLAlias; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; use Symfony\Component\Filesystem\Exception\IOExceptionInterface; use Symfony\Component\Filesystem\Filesystem; @@ -184,20 +184,20 @@ public function verifyIsLoaded(): void $this->getHTMLPage()->find($this->getLocator('mainContainer'))->assert()->isVisible(); $this->contentActionsMenu->verifyIsLoaded(); - Assert::assertStringContainsString( - $this->expectedContentName ?? '', + Assert::contains( $this->breadcrumb->getBreadcrumb(), + $this->expectedContentName ?? '', 'Breadcrumb shows invalid path' ); - Assert::assertEquals( - $this->expectedContentName, - $this->getHTMLPage()->find($this->getLocator('pageTitle'))->getText() + Assert::eq( + $this->getHTMLPage()->find($this->getLocator('pageTitle'))->getText(), + $this->expectedContentName ); - Assert::assertEquals( - $this->expectedContentType, - $this->getHTMLPage()->find($this->getLocator('contentType'))->getText() + Assert::eq( + $this->getHTMLPage()->find($this->getLocator('contentType'))->getText(), + $this->expectedContentType ); } @@ -216,8 +216,8 @@ public function editContent(?string $language = null): void if ($language !== null) { $availableLanguages = $this->languagePicker->getLanguages(); - Assert::assertGreaterThan(1, count($availableLanguages)); - Assert::assertContains($language, $availableLanguages); + Assert::greaterThan(count($availableLanguages), 1); + Assert::inArray($language, $availableLanguages); $this->languagePicker->chooseLanguage($language); } } @@ -342,7 +342,7 @@ static function () use ($repository, $locationPath): bool { ); $urlAlias = $repository->getURLAliasService()->lookup($locationPath); - Assert::assertEquals(URLAlias::LOCATION, $urlAlias->type); + Assert::eq($urlAlias->type, URLAlias::LOCATION); return $repository->getLocationService() ->loadLocation((int) $urlAlias->destination) diff --git a/src/lib/Behat/Page/LanguagePage.php b/src/lib/Behat/Page/LanguagePage.php index 15a8eaf8b0..9b51734af9 100644 --- a/src/lib/Behat/Page/LanguagePage.php +++ b/src/lib/Behat/Page/LanguagePage.php @@ -16,7 +16,7 @@ use Ibexa\Behat\Browser\Page\Page; use Ibexa\Behat\Browser\Routing\Router; use Ibexa\Contracts\Core\Repository\Repository; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class LanguagePage extends Page { @@ -121,9 +121,9 @@ public function setExpectedLanguageName(string $languageName): void public function verifyIsLoaded(): void { - Assert::assertEquals( - sprintf('Language "%s"', $this->expectedLanguageName), - $this->getHTMLPage()->find($this->getLocator('pageTitle'))->getText() + Assert::eq( + $this->getHTMLPage()->find($this->getLocator('pageTitle'))->getText(), + sprintf('Language "%s"', $this->expectedLanguageName) ); } diff --git a/src/lib/Behat/Page/ObjectStateGroupsPage.php b/src/lib/Behat/Page/ObjectStateGroupsPage.php index 5eadb7793e..2081e6c5e7 100644 --- a/src/lib/Behat/Page/ObjectStateGroupsPage.php +++ b/src/lib/Behat/Page/ObjectStateGroupsPage.php @@ -15,7 +15,7 @@ use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; use Ibexa\Behat\Browser\Page\Page; use Ibexa\Behat\Browser\Routing\Router; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class ObjectStateGroupsPage extends Page { @@ -57,9 +57,9 @@ public function deleteObjectStateGroup(string $objectStateGroupName): void public function verifyIsLoaded(): void { - Assert::assertEquals( - 'Object state groups', - $this->getHTMLPage()->find($this->getLocator('pageTitle'))->getText() + Assert::eq( + $this->getHTMLPage()->find($this->getLocator('pageTitle'))->getText(), + 'Object state groups' ); } diff --git a/src/lib/Behat/Page/ObjectStatePage.php b/src/lib/Behat/Page/ObjectStatePage.php index b5c2207187..d394d3869f 100644 --- a/src/lib/Behat/Page/ObjectStatePage.php +++ b/src/lib/Behat/Page/ObjectStatePage.php @@ -16,7 +16,7 @@ use Ibexa\Behat\Browser\Routing\Router; use Ibexa\Contracts\Core\Repository\Repository; use Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectState; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class ObjectStatePage extends Page { @@ -72,9 +72,9 @@ public function setExpectedObjectStateName(string $objectStateName): void public function verifyIsLoaded(): void { - Assert::assertEquals( - sprintf('Object state: %s', $this->expectedObjectStateName), - $this->getHTMLPage()->find($this->getLocator('pageTitle'))->getText() + Assert::eq( + $this->getHTMLPage()->find($this->getLocator('pageTitle'))->getText(), + sprintf('Object state: %s', $this->expectedObjectStateName) ); } diff --git a/src/lib/Behat/Page/RolePage.php b/src/lib/Behat/Page/RolePage.php index 67bdca9ff5..ef029e0522 100644 --- a/src/lib/Behat/Page/RolePage.php +++ b/src/lib/Behat/Page/RolePage.php @@ -18,7 +18,7 @@ use Ibexa\Behat\Browser\Page\Page; use Ibexa\Behat\Browser\Routing\Router; use Ibexa\Contracts\Core\Repository\Repository; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; class RolePage extends Page { @@ -176,10 +176,10 @@ public function verifyAssignments(array $expectedAssignments): void $actualAssignments = $this->assignments->getColumnValues(['User/Group', 'Limitation']); foreach ($expectedAssignments as $expectedAssignment) { - Assert::assertContains($expectedAssignment, $actualAssignments); + Assert::inArray($expectedAssignment, $actualAssignments); } - Assert::assertCount(count($expectedAssignments), $actualAssignments); + Assert::count($actualAssignments, count($expectedAssignments)); } public function startAssigningUsers(): void diff --git a/src/lib/Behat/Page/RolesPage.php b/src/lib/Behat/Page/RolesPage.php index 40e28e6234..7935963b1b 100644 --- a/src/lib/Behat/Page/RolesPage.php +++ b/src/lib/Behat/Page/RolesPage.php @@ -16,7 +16,7 @@ use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; use Ibexa\Behat\Browser\Page\Page; use Ibexa\Behat\Browser\Routing\Router; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class RolesPage extends Page { @@ -35,9 +35,9 @@ public function __construct( public function verifyItemAttribute(string $label, string $value, string $itemName): void { - Assert::assertEquals( - $value, + Assert::eq( $this->adminList->table->getTableCellValue($itemName, $label), + $value, sprintf('Attribute "%s" of item "%s" has wrong value.', $label, $itemName) ); } @@ -83,9 +83,9 @@ public function getName(): string public function verifyIsLoaded(): void { - Assert::assertEquals( - 'Roles', - $this->getHTMLPage()->find($this->getLocator('pageTitle'))->getText() + Assert::eq( + $this->getHTMLPage()->find($this->getLocator('pageTitle'))->getText(), + 'Roles' ); } diff --git a/src/lib/Behat/Page/SectionsPage.php b/src/lib/Behat/Page/SectionsPage.php index 21cd410b81..5a719d2d69 100644 --- a/src/lib/Behat/Page/SectionsPage.php +++ b/src/lib/Behat/Page/SectionsPage.php @@ -15,7 +15,7 @@ use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; use Ibexa\Behat\Browser\Page\Page; use Ibexa\Behat\Browser\Routing\Router; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class SectionsPage extends Page { @@ -88,9 +88,9 @@ public function getName(): string public function verifyIsLoaded(): void { - Assert::assertEquals( - 'Sections', - $this->getHTMLPage()->find($this->getLocator('pageTitle'))->getText() + Assert::eq( + $this->getHTMLPage()->find($this->getLocator('pageTitle'))->getText(), + 'Sections' ); } diff --git a/src/lib/Behat/Page/SystemInfoPage.php b/src/lib/Behat/Page/SystemInfoPage.php index e3b0acc814..0d24d20aca 100644 --- a/src/lib/Behat/Page/SystemInfoPage.php +++ b/src/lib/Behat/Page/SystemInfoPage.php @@ -17,7 +17,7 @@ use Ibexa\Behat\Browser\Page\Page; use Ibexa\Behat\Browser\Routing\Router; use InvalidArgumentException; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class SystemInfoPage extends Page { @@ -57,7 +57,7 @@ public function verifyPackages(array $packages): void $names = array_column($actualPackageData, 'Name'); foreach ($packages as $package) { - Assert::assertContains($package, $names); + Assert::inArray($package, $names); } } diff --git a/src/lib/Behat/Page/TrashPage.php b/src/lib/Behat/Page/TrashPage.php index b2da03f363..778750fb55 100644 --- a/src/lib/Behat/Page/TrashPage.php +++ b/src/lib/Behat/Page/TrashPage.php @@ -18,7 +18,7 @@ use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; use Ibexa\Behat\Browser\Page\Page; use Ibexa\Behat\Browser\Routing\Router; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class TrashPage extends Page { @@ -107,9 +107,9 @@ public function restoreSelectedItems(): void public function verifyIsLoaded(): void { - Assert::assertEquals( - 'Trash', - $this->getHTMLPage()->find($this->getLocator('pageTitle'))->getText() + Assert::eq( + $this->getHTMLPage()->find($this->getLocator('pageTitle'))->getText(), + 'Trash' ); } diff --git a/src/lib/Behat/Page/UserProfilePage.php b/src/lib/Behat/Page/UserProfilePage.php index 5ead1792fb..1e7c5baba6 100644 --- a/src/lib/Behat/Page/UserProfilePage.php +++ b/src/lib/Behat/Page/UserProfilePage.php @@ -13,7 +13,7 @@ use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; use Ibexa\Behat\Browser\Page\Page; use Ibexa\Behat\Browser\Routing\Router; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class UserProfilePage extends Page { @@ -29,9 +29,9 @@ public function __construct( public function verifyIsLoaded(): void { - Assert::assertEquals( - 'User profile', - $this->getHTMLPage()->find($this->getLocator('pageTitle'))->getText() + Assert::eq( + $this->getHTMLPage()->find($this->getLocator('pageTitle'))->getText(), + 'User profile' ); } diff --git a/src/lib/Behat/Page/UserSettingsPage.php b/src/lib/Behat/Page/UserSettingsPage.php index 9a4ef04d7f..8f62180b78 100644 --- a/src/lib/Behat/Page/UserSettingsPage.php +++ b/src/lib/Behat/Page/UserSettingsPage.php @@ -17,7 +17,7 @@ use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; use Ibexa\Behat\Browser\Page\Page; use Ibexa\Behat\Browser\Routing\Router; -use PHPUnit\Framework\Assert; +use Webmozart\Assert\Assert; final class UserSettingsPage extends Page { @@ -34,7 +34,7 @@ public function __construct( public function verifyIsLoaded(): void { $pageHeaderText = $this->getHTMLPage()->find($this->getLocator('title'))->getText(); - Assert::AssertContains($pageHeaderText, ['User settings', 'Content authoring', 'Browsing']); + Assert::inArray($pageHeaderText, ['User settings', 'Content authoring', 'Browsing']); } public function switchTab(string $tabName): void From a1cf19cfe76eefd7244d579133e37e05e5a6f6f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Nowak?= Date: Tue, 19 May 2026 14:37:12 +0200 Subject: [PATCH 3/4] IBX-11766 Fixed code styles --- src/lib/Behat/Component/Fields/MapLocation.php | 2 +- src/lib/Behat/Page/ContentUpdateItemPage.php | 2 +- src/lib/Behat/Page/ContentViewPage.php | 2 +- .../Loader/SearchContentTypeChoiceLoader.php | 2 +- src/lib/Permission/PermissionChecker.php | 4 ++-- src/lib/Tab/LocationView/ContentTab.php | 2 +- .../Processor/ContentTypeFormProcessorTest.php | 14 +++++++------- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/lib/Behat/Component/Fields/MapLocation.php b/src/lib/Behat/Component/Fields/MapLocation.php index 1d0fd7b242..718d64225d 100644 --- a/src/lib/Behat/Component/Fields/MapLocation.php +++ b/src/lib/Behat/Component/Fields/MapLocation.php @@ -10,8 +10,8 @@ use Ibexa\Behat\Browser\Locator\CSSLocatorBuilder; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use Webmozart\Assert\Assert; use RuntimeException; +use Webmozart\Assert\Assert; final class MapLocation extends FieldTypeComponent { diff --git a/src/lib/Behat/Page/ContentUpdateItemPage.php b/src/lib/Behat/Page/ContentUpdateItemPage.php index ffacfe9179..681c0aa32a 100644 --- a/src/lib/Behat/Page/ContentUpdateItemPage.php +++ b/src/lib/Behat/Page/ContentUpdateItemPage.php @@ -20,8 +20,8 @@ use Ibexa\Behat\Browser\Page\Page; use Ibexa\Behat\Browser\Routing\Router; use InvalidArgumentException; -use Webmozart\Assert\Assert; use RuntimeException; +use Webmozart\Assert\Assert; class ContentUpdateItemPage extends Page { diff --git a/src/lib/Behat/Page/ContentViewPage.php b/src/lib/Behat/Page/ContentViewPage.php index cb77bd634f..67e50a00ad 100644 --- a/src/lib/Behat/Page/ContentViewPage.php +++ b/src/lib/Behat/Page/ContentViewPage.php @@ -33,9 +33,9 @@ use Ibexa\Contracts\Core\Repository\Repository; use Ibexa\Contracts\Core\Repository\Values\Content\Content; use Ibexa\Contracts\Core\Repository\Values\Content\URLAlias; -use Webmozart\Assert\Assert; use Symfony\Component\Filesystem\Exception\IOExceptionInterface; use Symfony\Component\Filesystem\Filesystem; +use Webmozart\Assert\Assert; class ContentViewPage extends Page { diff --git a/src/lib/Form/Type/Trash/ChoiceList/Loader/SearchContentTypeChoiceLoader.php b/src/lib/Form/Type/Trash/ChoiceList/Loader/SearchContentTypeChoiceLoader.php index ffdbace2ea..fbef98d713 100644 --- a/src/lib/Form/Type/Trash/ChoiceList/Loader/SearchContentTypeChoiceLoader.php +++ b/src/lib/Form/Type/Trash/ChoiceList/Loader/SearchContentTypeChoiceLoader.php @@ -25,7 +25,7 @@ public function __construct( private readonly ConfigResolverInterface $configResolver ) { parent::__construct($contentTypeService, $userLanguagePreferenceProvider); - } + } public function loadChoiceList(?callable $value = null): ChoiceListInterface { diff --git a/src/lib/Permission/PermissionChecker.php b/src/lib/Permission/PermissionChecker.php index 1a5a72f587..fb97002aa9 100644 --- a/src/lib/Permission/PermissionChecker.php +++ b/src/lib/Permission/PermissionChecker.php @@ -117,8 +117,8 @@ public function canCreateInLocation(Location $location, array|bool $hasAccess): $restrictedSubtrees = $this->getRestrictions($hasAccess, SubtreeLimitation::class); $canCreateInSubtree = empty($restrictedSubtrees) || !empty(array_filter($restrictedSubtrees, static function ($restrictedSubtree) use ($location): bool { - return str_starts_with($location->getPathString(), $restrictedSubtree); - })); + return str_starts_with($location->getPathString(), $restrictedSubtree); + })); if (false === $canCreateInSubtree) { return false; diff --git a/src/lib/Tab/LocationView/ContentTab.php b/src/lib/Tab/LocationView/ContentTab.php index f8df4f2ad2..d827158dc2 100644 --- a/src/lib/Tab/LocationView/ContentTab.php +++ b/src/lib/Tab/LocationView/ContentTab.php @@ -31,7 +31,7 @@ public function __construct( private readonly ConfigResolverInterface $configResolver ) { parent::__construct($twig, $translator, $eventDispatcher); - } + } public function getIdentifier(): string { diff --git a/tests/lib/Form/Processor/ContentTypeFormProcessorTest.php b/tests/lib/Form/Processor/ContentTypeFormProcessorTest.php index c0d4a272cf..f3cf9446c5 100644 --- a/tests/lib/Form/Processor/ContentTypeFormProcessorTest.php +++ b/tests/lib/Form/Processor/ContentTypeFormProcessorTest.php @@ -279,13 +279,13 @@ static function ( ContentTypeDraft $actualContentTypeDraft, FieldDefinition $actualFieldDefinition ) use ($matcher, $contentTypeDraft, $fieldDefinition2, $fieldDefinition3): void { - self::assertSame($contentTypeDraft, $actualContentTypeDraft); - match ($matcher->getInvocationCount()) { - 1 => self::assertSame($fieldDefinition2, $actualFieldDefinition), - 2 => self::assertSame($fieldDefinition3, $actualFieldDefinition), - default => self::fail('Unexpected invocation count matched'), - }; - } + self::assertSame($contentTypeDraft, $actualContentTypeDraft); + match ($matcher->getInvocationCount()) { + 1 => self::assertSame($fieldDefinition2, $actualFieldDefinition), + 2 => self::assertSame($fieldDefinition3, $actualFieldDefinition), + default => self::fail('Unexpected invocation count matched'), + }; + } ) ; From 7b0c91970729ce8de70578afd9f925109ef39599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Nowak?= Date: Thu, 21 May 2026 13:37:37 +0200 Subject: [PATCH 4/4] IBX-11766 Removed not neccesary "\" before RuntimeException --- src/lib/Behat/Page/ContentUpdateItemPage.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/Behat/Page/ContentUpdateItemPage.php b/src/lib/Behat/Page/ContentUpdateItemPage.php index 681c0aa32a..15eaa90941 100644 --- a/src/lib/Behat/Page/ContentUpdateItemPage.php +++ b/src/lib/Behat/Page/ContentUpdateItemPage.php @@ -198,7 +198,7 @@ protected function getFieldPosition(string $fieldName): int } } - throw new \RuntimeException(sprintf('Field %s not found. Found: %s', $fieldName, implode(',', $foundFields))); + throw new RuntimeException(sprintf('Field %s not found. Found: %s', $fieldName, implode(',', $foundFields))); } /** @@ -285,7 +285,7 @@ public function verifyAutosaveDraftIsSavedNotificationIsDisplayed(): void usleep(500000); --$iteration_count; } - throw new \RuntimeException('Draft has not been autosaved for 15 seconds'); + throw new RuntimeException('Draft has not been autosaved for 15 seconds'); } public function isAutosaveDraftSavedNotificationVisible(): bool