From a49002bc35bb9a3b2f5d83b603997a4497cbb215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Nowak?= Date: Tue, 19 May 2026 13:03:22 +0200 Subject: [PATCH 1/4] IBX-11766 composer require --dev webmozart/assert:^2.3 Co-Authored-By: Claude Sonnet 4.6 --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index fd026962..fb668746 100644 --- a/composer.json +++ b/composer.json @@ -34,10 +34,11 @@ "ibexa/rest": "~5.0.x-dev", "ibexa/test-core": "~5.0.x-dev", "matthiasnoback/symfony-dependency-injection-test": "^5.0", - "phpunit/phpunit": "^9.6", "phpstan/phpstan": "^2.1", "phpstan/phpstan-phpunit": "^2.0", - "phpstan/phpstan-symfony": "^2.0" + "phpstan/phpstan-symfony": "^2.0", + "phpunit/phpunit": "^9.6", + "webmozart/assert": "^2.3" }, "autoload": { "psr-4": { From 10ed4c5ba86125b97299738d0f05aafe23c72269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Nowak?= Date: Tue, 19 May 2026 13:06:04 +0200 Subject: [PATCH 2/4] IBX-11766 Replaced phpunit assertions with these from webmozart library Co-Authored-By: Claude Sonnet 4.6 --- src/lib/Behat/Context/ContentTypeContext.php | 6 +++--- src/lib/Behat/Context/FieldTypeFormContext.php | 10 +++++----- src/lib/Behat/Context/PagelayoutContext.php | 6 +++--- .../Behat/Context/SelectionFieldTypeFormContext.php | 8 ++++---- src/lib/Behat/Context/UserRegistrationContext.php | 10 +++++----- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/lib/Behat/Context/ContentTypeContext.php b/src/lib/Behat/Context/ContentTypeContext.php index 8b94dc13..5855fc60 100644 --- a/src/lib/Behat/Context/ContentTypeContext.php +++ b/src/lib/Behat/Context/ContentTypeContext.php @@ -18,7 +18,7 @@ use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeCreateStruct; use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinitionUpdateStruct; use Ibexa\Core\Repository\Values\User\UserReference; -use PHPUnit\Framework\Assert as Assertion; +use Webmozart\Assert\Assert as Assertion; final class ContentTypeContext extends RawMinkContext implements Context, SnippetAcceptingContext { @@ -38,9 +38,9 @@ public function thereIsAContentTypeWithId(string $contentTypeIdentifier, int $id { try { $contentType = $this->contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier); - Assertion::assertEquals($id, $contentType->id); + Assertion::eq($contentType->id, $id); } catch (NotFoundException) { - Assertion::fail("No ContentType with the identifier '$contentTypeIdentifier' could be found."); + throw new \RuntimeException("No ContentType with the identifier '$contentTypeIdentifier' could be found."); } } diff --git a/src/lib/Behat/Context/FieldTypeFormContext.php b/src/lib/Behat/Context/FieldTypeFormContext.php index 3dd1908e..2038264d 100644 --- a/src/lib/Behat/Context/FieldTypeFormContext.php +++ b/src/lib/Behat/Context/FieldTypeFormContext.php @@ -14,7 +14,7 @@ use Behat\MinkExtension\Context\RawMinkContext; use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinitionCreateStruct; use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinitionUpdateStruct; -use PHPUnit\Framework\Assert as Assertion; +use Webmozart\Assert\Assert as Assertion; final class FieldTypeFormContext extends RawMinkContext implements SnippetAcceptingContext { @@ -154,7 +154,7 @@ public function itShouldContainTheFollowingSetOfLabelsAndInputFieldsTypes(TableN } foreach ($table->getColumnsHash() as $expectedField) { - Assertion::assertContains($expectedField, $actualInputFields); + Assertion::inArray($expectedField, $actualInputFields); } } @@ -184,7 +184,7 @@ public function theInputFieldsShouldBeFlaggedAsRequired(string $fieldTypeIdentif ) ); - Assertion::assertNotEmpty($inputNodeElements, 'The input field is not marked as required'); + Assertion::notEmpty($inputNodeElements, 'The input field is not marked as required'); $exceptions = $this->getRequiredFieldTypeExceptions($fieldTypeIdentifier); @@ -194,9 +194,9 @@ public function theInputFieldsShouldBeFlaggedAsRequired(string $fieldTypeIdentif $expectedState = array_key_exists($label, $exceptions) ? $exceptions[$label] : true; - Assertion::assertEquals( - $expectedState, + Assertion::eq( $inputNodeElement->hasAttribute('required'), + $expectedState, sprintf( '%s input with id %s is not flagged as required', $inputNodeElement->getAttribute('type'), diff --git a/src/lib/Behat/Context/PagelayoutContext.php b/src/lib/Behat/Context/PagelayoutContext.php index 7b8df389..f4fdcb0a 100644 --- a/src/lib/Behat/Context/PagelayoutContext.php +++ b/src/lib/Behat/Context/PagelayoutContext.php @@ -12,7 +12,7 @@ use Behat\Behat\Context\SnippetAcceptingContext; use Behat\MinkExtension\Context\RawMinkContext; use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface; -use PHPUnit\Framework\Assert as Assertion; +use Webmozart\Assert\Assert as Assertion; final class PagelayoutContext extends RawMinkContext implements Context, SnippetAcceptingContext { @@ -29,7 +29,7 @@ public function __construct( */ public function aPagelayoutIsConfigured(): void { - Assertion::assertTrue($this->configResolver->hasParameter('page_layout')); + Assertion::true($this->configResolver->hasParameter('page_layout')); } /** @@ -40,7 +40,7 @@ public function itIsRenderedUsingTheConfiguredPagelayout(): void $pageLayout = $this->getPageLayout(); $searchedPattern = sprintf(self::TWIG_DEBUG_STOP_REGEX, preg_quote($pageLayout, null)); - Assertion::assertMatchesRegularExpression($searchedPattern, $this->getSession()->getPage()->getOuterHtml()); + Assertion::regex($this->getSession()->getPage()->getOuterHtml(), $searchedPattern); } public function getPageLayout(): string diff --git a/src/lib/Behat/Context/SelectionFieldTypeFormContext.php b/src/lib/Behat/Context/SelectionFieldTypeFormContext.php index a8035180..9cff6ea8 100644 --- a/src/lib/Behat/Context/SelectionFieldTypeFormContext.php +++ b/src/lib/Behat/Context/SelectionFieldTypeFormContext.php @@ -11,7 +11,7 @@ use Behat\Behat\Context\SnippetAcceptingContext; use Behat\Behat\Hook\Scope\BeforeScenarioScope; use Behat\MinkExtension\Context\RawMinkContext; -use PHPUnit\Framework\Assert as Assertion; +use Webmozart\Assert\Assert as Assertion; final class SelectionFieldTypeFormContext extends RawMinkContext implements SnippetAcceptingContext { @@ -68,11 +68,11 @@ public function theSelectFieldShouldBeFlaggedAsRequired(): void self::$fieldIdentifier ) ); - Assertion::assertNotEmpty($nodeElements, 'The select field is not marked as required'); + Assertion::notEmpty($nodeElements, 'The select field is not marked as required'); foreach ($nodeElements as $nodeElement) { - Assertion::assertEquals( - 'required', + Assertion::eq( $nodeElement->getAttribute('required'), + 'required', sprintf( 'The select with ID %s is not flagged as required', $nodeElement->getAttribute('id') diff --git a/src/lib/Behat/Context/UserRegistrationContext.php b/src/lib/Behat/Context/UserRegistrationContext.php index 9c11de83..f75efa8d 100644 --- a/src/lib/Behat/Context/UserRegistrationContext.php +++ b/src/lib/Behat/Context/UserRegistrationContext.php @@ -23,9 +23,9 @@ use Ibexa\Contracts\Core\Repository\Values\User\UserGroup; use Ibexa\Core\Repository\Values\User\RoleCreateStruct; use Ibexa\Core\Repository\Values\User\UserReference; -use PHPUnit\Framework\Assert as Assertion; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Yaml\Yaml; +use Webmozart\Assert\Assert as Assertion; final class UserRegistrationContext extends RawMinkContext implements Context, SnippetAcceptingContext { @@ -295,9 +295,9 @@ public function theUserIsCreatedInThisUserGroup(string $userGroupName): void $user = $this->userService->loadUserByLogin($this->registrationUsername); $userGroups = $this->userService->loadUserGroupsOfUser($user); - Assertion::assertEquals( - $userGroupName, - $userGroups[0]->getName() + Assertion::eq( + $userGroups[0]->getName(), + $userGroupName ); } @@ -343,7 +343,7 @@ public function thePageIsRenderedUsingTheTemplateConfiguredIn(string $template): $found = preg_match($searchedPattern, $html) === 1; } - Assertion::assertTrue( + Assertion::true( $found, "Couldn't find $template " . (isset($alternativeTemplate) ? "nor $alternativeTemplate " : ' ') . From c0cb51c868b6564d9a0c8390d6d115c0a323e15d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Nowak?= Date: Tue, 19 May 2026 15:11:51 +0200 Subject: [PATCH 3/4] IBX-11766 phpstan baseline regenerated --- phpstan-baseline.neon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ee88e80e..a960a60f 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -433,7 +433,7 @@ parameters: path: src/lib/Form/Type/FieldType/AuthorFieldType.php - - message: '#^Method Ibexa\\ContentForms\\Form\\Type\\FieldType\\AuthorFieldType\:\:getViewTransformer\(\) return type with generic interface Symfony\\Component\\Form\\DataTransformerInterface does not specify its types\: T, R$#' + message: '#^Method Ibexa\\ContentForms\\Form\\Type\\FieldType\\AuthorFieldType\:\:getViewTransformer\(\) return type with generic interface Symfony\\Component\\Form\\DataTransformerInterface does not specify its types\: TValue, TTransformedValue$#' identifier: missingType.generics count: 1 path: src/lib/Form/Type/FieldType/AuthorFieldType.php From f9c9764961b61fe49bd86e67f46ee92447d3fd36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Nowak?= Date: Thu, 21 May 2026 14:10:15 +0200 Subject: [PATCH 4/4] IBX-11766 Imported RuntimeException in \Ibexa\ContentForms\Behat\Context\ContentTypeContext --- src/lib/Behat/Context/ContentTypeContext.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/Behat/Context/ContentTypeContext.php b/src/lib/Behat/Context/ContentTypeContext.php index 5855fc60..886776bb 100644 --- a/src/lib/Behat/Context/ContentTypeContext.php +++ b/src/lib/Behat/Context/ContentTypeContext.php @@ -18,6 +18,7 @@ use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeCreateStruct; use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinitionUpdateStruct; use Ibexa\Core\Repository\Values\User\UserReference; +use RuntimeException; use Webmozart\Assert\Assert as Assertion; final class ContentTypeContext extends RawMinkContext implements Context, SnippetAcceptingContext @@ -40,7 +41,7 @@ public function thereIsAContentTypeWithId(string $contentTypeIdentifier, int $id $contentType = $this->contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier); Assertion::eq($contentType->id, $id); } catch (NotFoundException) { - throw new \RuntimeException("No ContentType with the identifier '$contentTypeIdentifier' could be found."); + throw new RuntimeException("No ContentType with the identifier '$contentTypeIdentifier' could be found."); } }