From 33c6056eaf5b45a7e4be4247d45520b3068732f0 Mon Sep 17 00:00:00 2001 From: Dawid Parafinski Date: Thu, 27 Aug 2026 19:22:04 +0200 Subject: [PATCH] IBX-12374: Converted Behat annotations to attributes and added PHP suite configuration --- behat_suites.php | 50 +++++++++++ composer.json | 2 +- phpstan-baseline.neon | 24 ------ rector.php | 3 +- src/lib/Behat/Context/ContentEditContext.php | 52 ++++-------- src/lib/Behat/Context/ContentTypeContext.php | 11 +-- .../Behat/Context/FieldTypeFormContext.php | 46 ++++------ src/lib/Behat/Context/PagelayoutContext.php | 10 +-- .../Context/SelectionFieldTypeFormContext.php | 29 +++---- .../Behat/Context/UserRegistrationContext.php | 85 ++++++------------- 10 files changed, 132 insertions(+), 180 deletions(-) create mode 100644 behat_suites.php diff --git a/behat_suites.php b/behat_suites.php new file mode 100644 index 00000000..00597f46 --- /dev/null +++ b/behat_suites.php @@ -0,0 +1,50 @@ +withProfile((new Profile('setup-content-forms')) + ->withSuite((new Suite('setup')) + ->withContexts( + UserRegistrationContext::class, + YamlConfigurationContext::class + ) + ->withPaths('vendor/ibexa/content-forms/features/User/Setup'))) + ->withProfile((new Profile('content-forms')) + ->withSuite((new Suite('content_edit')) + ->withContexts( + ContentEditContext::class, + ContentTypeContext::class, + PagelayoutContext::class + ) + ->withPaths('vendor/ibexa/content-forms/features/ContentEdit')) + ->withSuite((new Suite('fieldtype_form')) + ->withContexts( + ContentTypeContext::class, + FieldTypeFormContext::class, + SelectionFieldTypeFormContext::class + ) + ->withPaths('vendor/ibexa/content-forms/features/FieldTypeForm')) + ->withSuite((new Suite('user_registration')) + ->withContexts( + UserRegistrationContext::class, + MinkContext::class, + YamlConfigurationContext::class + ) + ->withPaths('vendor/ibexa/content-forms/features/User/Registration'))); diff --git a/composer.json b/composer.json index ea191ee9..9c4bcc60 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "symfony/yaml": "^7.4" }, "require-dev": { - "behat/behat": "^3.5", + "behat/behat": "^3.32 || ^4.0", "ibexa/behat": "~6.0.x-dev", "ibexa/code-style": "~2.0.0", "ibexa/doctrine-schema": "~6.0.x-dev", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index a960a60f..128adc04 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -54,12 +54,6 @@ parameters: count: 1 path: src/lib/Behat/Context/ContentTypeContext.php - - - message: '#^Method Ibexa\\ContentForms\\Behat\\Context\\ContentTypeContext\:\:iRemoveFieldFromContentType\(\) has parameter \$fieldIdentifier with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: src/lib/Behat/Context/ContentTypeContext.php - - message: '#^Method Ibexa\\ContentForms\\Behat\\Context\\ContentTypeContext\:\:newContentTypeCreateStruct\(\) has parameter \$identifier with no type specified\.$#' identifier: missingType.parameter @@ -96,30 +90,12 @@ parameters: count: 2 path: src/lib/Behat/Context/FieldTypeFormContext.php - - - message: '#^Method Ibexa\\ContentForms\\Behat\\Context\\FieldTypeFormContext\:\:aContentTypeWithAGivenFieldDefinition\(\) has parameter \$contentTypeName with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: src/lib/Behat/Context/FieldTypeFormContext.php - - - - message: '#^Method Ibexa\\ContentForms\\Behat\\Context\\FieldTypeFormContext\:\:aContentTypeWithAGivenFieldDefinition\(\) has parameter \$fieldTypeIdentifier with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: src/lib/Behat/Context/FieldTypeFormContext.php - - message: '#^Method Ibexa\\ContentForms\\Behat\\Context\\FieldTypeFormContext\:\:getRequiredFieldTypeExceptions\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 path: src/lib/Behat/Context/FieldTypeFormContext.php - - - message: '#^Method Ibexa\\ContentForms\\Behat\\Context\\FieldTypeFormContext\:\:itShouldContainAGivenTypeInputField\(\) has parameter \$inputType with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: src/lib/Behat/Context/FieldTypeFormContext.php - - message: '#^Call to an undefined method Behat\\Testwork\\Environment\\Environment\:\:getContext\(\)\.$#' identifier: method.notFound diff --git a/rector.php b/rector.php index 76418e21..769f88b9 100644 --- a/rector.php +++ b/rector.php @@ -25,4 +25,5 @@ SymfonySetList::SYMFONY_70, SymfonySetList::SYMFONY_71, SymfonySetList::SYMFONY_72, - ]); + ]) + ->withAttributesSets(behat: true); diff --git a/src/lib/Behat/Context/ContentEditContext.php b/src/lib/Behat/Context/ContentEditContext.php index a5729453..50b13004 100644 --- a/src/lib/Behat/Context/ContentEditContext.php +++ b/src/lib/Behat/Context/ContentEditContext.php @@ -11,7 +11,11 @@ use Behat\Behat\Context\Context; use Behat\Behat\Context\SnippetAcceptingContext; use Behat\Behat\Hook\Scope\BeforeScenarioScope; +use Behat\Hook\BeforeScenario; use Behat\MinkExtension\Context\MinkContext; +use Behat\Step\Given; +use Behat\Step\Then; +use Behat\Step\When; use Exception; use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinitionCreateStruct; @@ -29,7 +33,7 @@ final class ContentEditContext extends MinkContext implements Context, SnippetAc */ private static string $constrainedFieldIdentifier = 'constrained_field'; - /** @BeforeScenario */ + #[BeforeScenario] public function gatherContexts(BeforeScenarioScope $scope): void { $environment = $scope->getEnvironment(); @@ -37,18 +41,14 @@ public function gatherContexts(BeforeScenarioScope $scope): void $this->contentTypeContext = $environment->getContext(ContentTypeContext::class); } - /** - * @Then /^I should see a folder content edit form$/ - * @Then /^I should see a content edit form$/ - */ + #[Then('/^I should see a folder content edit form$/')] + #[Then('/^I should see a content edit form$/')] public function iShouldSeeAContentEditForm(): void { $this->assertSession()->elementExists('css', 'form[name=ezplatform_content_forms_content_edit]'); } - /** - * @Then /^I am on the View of the Content that was published$/ - */ + #[Then('/^I am on the View of the Content that was published$/')] public function iAmOnTheViewOfTheContentThatWasPublished(): void { if (!isset($this->createdContentName)) { @@ -59,9 +59,7 @@ public function iAmOnTheViewOfTheContentThatWasPublished(): void $this->assertElementContainsText('span.ibexa_string-field', $this->createdContentName); } - /** - * @When /^I fill in the folder edit form$/ - */ + #[When('/^I fill in the folder edit form$/')] public function iFillInTheFolderEditForm(): void { // will only work for single value fields @@ -69,9 +67,7 @@ public function iFillInTheFolderEditForm(): void $this->fillField('ezplatform_content_forms_content_edit_fieldsData_name_value', $this->createdContentName); } - /** - * @Given /^that I have permission to create folders$/ - */ + #[Given('/^that I have permission to create folders$/')] public function thatIHavePermissionToCreateFolders(): void { $this->visit('/login'); @@ -80,17 +76,13 @@ public function thatIHavePermissionToCreateFolders(): void $this->getSession()->getPage()->find('css', 'form')->submit(); } - /** - * @Given /^that I have permission to create content of this type$/ - */ + #[Given('/^that I have permission to create content of this type$/')] public function thatIHavePermissionToCreateContentOfThisType(): void { $this->thatIHavePermissionToCreateFolders(); } - /** - * @When /^I go to the content creation page for this type$/ - */ + #[When('/^I go to the content creation page for this type$/')] public function iGoToTheContentCreationPageForThisType(): void { $uri = sprintf( @@ -101,9 +93,7 @@ public function iGoToTheContentCreationPageForThisType(): void $this->visit($uri); } - /** - * @Given /^I fill in the constrained field with an invalid value$/ - */ + #[Given('/^I fill in the constrained field with an invalid value$/')] public function iFillInTheConstrainedFieldWithAnInvalidValue(): void { $this->fillField( @@ -123,9 +113,7 @@ public function iFillInTheConstrainedFieldWithAnInvalidValue(): void } } - /** - * @Then /^I am shown the content creation form$/ - */ + #[Then('/^I am shown the content creation form$/')] public function iAmShownTheContentCreationForm(): void { $uri = sprintf( @@ -142,9 +130,7 @@ public function iAmShownTheContentCreationForm(): void ); } - /** - * @Given /^there is a relevant error message linked to the invalid field$/ - */ + #[Given('/^there is a relevant error message linked to the invalid field$/')] public function thereIsARelevantErrorMessageLinkedToTheInvalidField(): void { $selector = sprintf( @@ -156,9 +142,7 @@ public function thereIsARelevantErrorMessageLinkedToTheInvalidField(): void $this->assertSession()->elementTextContains('css', $selector, 'The string cannot be shorter than 5 characters.'); } - /** - * @Given /^that there is a content type with any kind of constraints on a Field Definition$/ - */ + #[Given('/^that there is a content type with any kind of constraints on a Field Definition$/')] public function thereIsAContentTypeWithAnyKindOfConstraintsOnAFieldDefinition(): void { $contentTypeCreateStruct = $this->contentTypeContext->newContentTypeCreateStruct(); @@ -179,9 +163,7 @@ public function thereIsAContentTypeWithAnyKindOfConstraintsOnAFieldDefinition(): $this->contentTypeContext->createContentType($contentTypeCreateStruct); } - /** - * @When /^a content creation form is displayed$/ - */ + #[When('/^a content creation form is displayed$/')] public function aContentCreationFormIsDisplayed(): void { $this->visit('/content/create/nodraft/folder/eng-GB/2'); diff --git a/src/lib/Behat/Context/ContentTypeContext.php b/src/lib/Behat/Context/ContentTypeContext.php index 886776bb..d7e49b44 100644 --- a/src/lib/Behat/Context/ContentTypeContext.php +++ b/src/lib/Behat/Context/ContentTypeContext.php @@ -11,6 +11,7 @@ use Behat\Behat\Context\Context; use Behat\Behat\Context\SnippetAcceptingContext; use Behat\MinkExtension\Context\RawMinkContext; +use Behat\Step\Given; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException; use Ibexa\Contracts\Core\Repository\PermissionResolver; @@ -32,9 +33,7 @@ public function __construct( $permissionResolver->setCurrentUserReference(new UserReference(14)); } - /** - * @Given /^there is a content type "([^"]*)" with the id "([^"]*)"$/ - */ + #[Given('/^there is a content type "([^"]*)" with the id "([^"]*)"$/')] public function thereIsAContentTypeWithId(string $contentTypeIdentifier, int $id): void { try { @@ -45,10 +44,8 @@ public function thereIsAContentTypeWithId(string $contentTypeIdentifier, int $id } } - /** - * @Given I remove :fieldIdentifier field from :contentTypeIdentifier content type - */ - public function iRemoveFieldFromContentType($fieldIdentifier, string $contentTypeIdentifier): void + #[Given('I remove :fieldIdentifier field from :contentTypeIdentifier content type')] + public function iRemoveFieldFromContentType(string $fieldIdentifier, string $contentTypeIdentifier): void { $contentType = $this->contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier); $contentTypeDraft = $this->contentTypeService->createContentTypeDraft($contentType); diff --git a/src/lib/Behat/Context/FieldTypeFormContext.php b/src/lib/Behat/Context/FieldTypeFormContext.php index 2038264d..2c591fb1 100644 --- a/src/lib/Behat/Context/FieldTypeFormContext.php +++ b/src/lib/Behat/Context/FieldTypeFormContext.php @@ -11,7 +11,11 @@ use Behat\Behat\Context\SnippetAcceptingContext; use Behat\Behat\Hook\Scope\BeforeScenarioScope; use Behat\Gherkin\Node\TableNode; +use Behat\Hook\BeforeScenario; use Behat\MinkExtension\Context\RawMinkContext; +use Behat\Step\Given; +use Behat\Step\Then; +use Behat\Step\When; use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinitionCreateStruct; use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinitionUpdateStruct; use Webmozart\Assert\Assert as Assertion; @@ -29,18 +33,16 @@ final class FieldTypeFormContext extends RawMinkContext implements SnippetAccept private ContentTypeContext $contentTypeContext; - /** @BeforeScenario */ + #[BeforeScenario] public function gatherContexts(BeforeScenarioScope $scope): void { $environment = $scope->getEnvironment(); $this->contentTypeContext = $environment->getContext(ContentTypeContext::class); } - /** - * @Given a content type with a(n) :fieldTypeIdentifier field definition - * @Given a content type :contentTypeName with a(n) :fieldTypeIdentifier field definition - */ - public function aContentTypeWithAGivenFieldDefinition($fieldTypeIdentifier, $contentTypeName = null): void + #[Given('a content type with a(n) :fieldTypeIdentifier field definition')] + #[Given('a content type :contentTypeName with a(n) :fieldTypeIdentifier field definition')] + public function aContentTypeWithAGivenFieldDefinition(string $fieldTypeIdentifier, ?string $contentTypeName = null): void { if (isset(self::$fieldTypeIdentifierMap[$fieldTypeIdentifier])) { $fieldTypeIdentifier = self::$fieldTypeIdentifierMap[$fieldTypeIdentifier]; @@ -77,9 +79,7 @@ public function aContentTypeWithAGivenFieldDefinition($fieldTypeIdentifier, $con $this->contentTypeContext->createContentType($contentTypeCreateStruct); } - /** - * @When /^I view the edit form for this field$/ - */ + #[When('/^I view the edit form for this field$/')] public function iEditOrCreateContentOfThisType(): void { $this->visitPath( @@ -90,9 +90,7 @@ public function iEditOrCreateContentOfThisType(): void ); } - /** - * @When /^I view the edit user form for this field$/ - */ + #[When('/^I view the edit user form for this field$/')] public function iEditOrCreateContentOfUserType(): void { $this->visitPath( @@ -103,9 +101,7 @@ public function iEditOrCreateContentOfUserType(): void ); } - /** - * @Then the edit form should contain an identifiable widget for :fieldTypeIdentifier field definition - */ + #[Then('the edit form should contain an identifiable widget for :fieldTypeIdentifier field definition')] public function theEditFormShouldContainAFieldsetNamedAfterTheFieldDefinition(string $fieldTypeIdentifier): void { $this->assertSession()->elementTextContains( @@ -115,10 +111,8 @@ public function theEditFormShouldContainAFieldsetNamedAfterTheFieldDefinition(st ); } - /** - * @Given it should contain a :type input field - */ - public function itShouldContainAGivenTypeInputField($inputType): void + #[Given('it should contain a :type input field')] + public function itShouldContainAGivenTypeInputField(string $inputType): void { $this->assertSession()->elementExists( 'css', @@ -131,9 +125,7 @@ public function itShouldContainAGivenTypeInputField($inputType): void ); } - /** - * @Given /^it should contain the following set of labels, and input fields of the following types:$/ - */ + #[Given('/^it should contain the following set of labels, and input fields of the following types:$/')] public function itShouldContainTheFollowingSetOfLabelsAndInputFieldsTypes(TableNode $table): void { $inputNodeElements = $this->getSession()->getPage()->findAll( @@ -158,10 +150,8 @@ public function itShouldContainTheFollowingSetOfLabelsAndInputFieldsTypes(TableN } } - /** - * @Given /^the field definition is required$/ - * @Given /^the field definition is marked as required$/ - */ + #[Given('/^the field definition is required$/')] + #[Given('/^the field definition is marked as required$/')] public function theFieldDefinitionIsMarkedAsRequired(): void { $this->contentTypeContext->updateFieldDefinition( @@ -170,9 +160,7 @@ public function theFieldDefinitionIsMarkedAsRequired(): void ); } - /** - * @Then the value input fields for :fieldIdentifier field should be flagged as required - */ + #[Then('the value input fields for :fieldIdentifier field should be flagged as required')] public function theInputFieldsShouldBeFlaggedAsRequired(string $fieldTypeIdentifier): void { $inputNodeElements = $this->getSession()->getPage()->findAll( diff --git a/src/lib/Behat/Context/PagelayoutContext.php b/src/lib/Behat/Context/PagelayoutContext.php index f4fdcb0a..84c69530 100644 --- a/src/lib/Behat/Context/PagelayoutContext.php +++ b/src/lib/Behat/Context/PagelayoutContext.php @@ -11,6 +11,8 @@ use Behat\Behat\Context\Context; use Behat\Behat\Context\SnippetAcceptingContext; use Behat\MinkExtension\Context\RawMinkContext; +use Behat\Step\Given; +use Behat\Step\Then; use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface; use Webmozart\Assert\Assert as Assertion; @@ -24,17 +26,13 @@ public function __construct( ) { } - /** - * @Given /^a pagelayout is configured$/ - */ + #[Given('/^a pagelayout is configured$/')] public function aPagelayoutIsConfigured(): void { Assertion::true($this->configResolver->hasParameter('page_layout')); } - /** - * @Then /^it is rendered using the configured pagelayout$/ - */ + #[Then('/^it is rendered using the configured pagelayout$/')] public function itIsRenderedUsingTheConfiguredPagelayout(): void { $pageLayout = $this->getPageLayout(); diff --git a/src/lib/Behat/Context/SelectionFieldTypeFormContext.php b/src/lib/Behat/Context/SelectionFieldTypeFormContext.php index 9cff6ea8..2c2c159b 100644 --- a/src/lib/Behat/Context/SelectionFieldTypeFormContext.php +++ b/src/lib/Behat/Context/SelectionFieldTypeFormContext.php @@ -10,7 +10,10 @@ use Behat\Behat\Context\SnippetAcceptingContext; use Behat\Behat\Hook\Scope\BeforeScenarioScope; +use Behat\Hook\BeforeScenario; use Behat\MinkExtension\Context\RawMinkContext; +use Behat\Step\Given; +use Behat\Step\Then; use Webmozart\Assert\Assert as Assertion; final class SelectionFieldTypeFormContext extends RawMinkContext implements SnippetAcceptingContext @@ -19,31 +22,25 @@ final class SelectionFieldTypeFormContext extends RawMinkContext implements Snip private FieldTypeFormContext $fieldTypeFormContext; - /** @BeforeScenario */ + #[BeforeScenario] public function gatherContexts(BeforeScenarioScope $scope): void { $this->fieldTypeFormContext = $scope->getEnvironment()->getContext(FieldTypeFormContext::class); } - /** - * @Given /^the field definition is set to single choice$/ - */ + #[Given('/^the field definition is set to single choice$/')] public function setFieldDefinitionToSingleChoice(): void { $this->fieldTypeFormContext->setFieldDefinitionOption('isMultiple', false); } - /** - * @Given /^the field definition is set to multiple choice$/ - */ + #[Given('/^the field definition is set to multiple choice$/')] public function setFieldDefinitionToMultipleChoice(): void { $this->fieldTypeFormContext->setFieldDefinitionOption('isMultiple', true); } - /** - * @Then it should contain a select field - */ + #[Then('it should contain a select field')] public function itShouldContainASelectField(): void { $this->assertSession()->elementExists( @@ -56,9 +53,7 @@ public function itShouldContainASelectField(): void ); } - /** - * @Then the select field should be flagged as required - */ + #[Then('the select field should be flagged as required')] public function theSelectFieldShouldBeFlaggedAsRequired(): void { $nodeElements = $this->getSession()->getPage()->findAll( @@ -81,9 +76,7 @@ public function theSelectFieldShouldBeFlaggedAsRequired(): void } } - /** - * @Then the input is a single selection dropdown - */ + #[Then('the input is a single selection dropdown')] public function theInputIsASingleSelectionDropdown(): void { $selector = sprintf( @@ -95,9 +88,7 @@ public function theInputIsASingleSelectionDropdown(): void $this->assertSession()->elementNotContains('css', $selector, 'multiple="multiple"'); } - /** - * @Then the input is a multiple selection dropdown - */ + #[Then('the input is a multiple selection dropdown')] public function theInputIsAMultipleSelectionDropdown(): void { $selector = sprintf( diff --git a/src/lib/Behat/Context/UserRegistrationContext.php b/src/lib/Behat/Context/UserRegistrationContext.php index f75efa8d..0d3dbb8e 100644 --- a/src/lib/Behat/Context/UserRegistrationContext.php +++ b/src/lib/Behat/Context/UserRegistrationContext.php @@ -12,7 +12,11 @@ use Behat\Behat\Context\SnippetAcceptingContext; use Behat\Behat\Hook\Scope\BeforeScenarioScope; use Behat\Gherkin\Node\PyStringNode; +use Behat\Hook\BeforeScenario; use Behat\MinkExtension\Context\RawMinkContext; +use Behat\Step\Given; +use Behat\Step\Then; +use Behat\Step\When; use Ibexa\Bundle\Core\Features\Context\YamlConfigurationContext; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\PermissionResolver; @@ -58,15 +62,13 @@ public function __construct( $permissionResolver->setCurrentUserReference(new UserReference(14)); } - /** @BeforeScenario */ + #[BeforeScenario] public function gatherContexts(BeforeScenarioScope $scope): void { $this->yamlConfigurationContext = $scope->getEnvironment()->getContext(YamlConfigurationContext::class); } - /** - * @Given /^I do not have the user\/register policy$/ - */ + #[Given('/^I do not have the user\/register policy$/')] public function loginAsUserWithoutRegisterPolicy(): void { $role = $this->createRegistrationRole(false); @@ -74,9 +76,7 @@ public function loginAsUserWithoutRegisterPolicy(): void $this->loginAs($user); } - /** - * @Given /^I do have the user\/register policy$/ - */ + #[Given('/^I do have the user\/register policy$/')] public function loginAsUserWithUserRegisterPolicy(): void { $role = $this->createRegistrationRole(true); @@ -128,9 +128,7 @@ private function createRegistrationRole(bool $withUserRegisterPolicy = true): Ro return $this->roleService->loadRoleByIdentifier($roleIdentifier); } - /** - * @Then /^I see an error message saying that I can not register$/ - */ + #[Then('/^I see an error message saying that I can not register$/')] public function iSeeAnErrorMessageSayingThatICanNotRegister(): void { $this->assertSession()->pageTextContains('You are not allowed to register a new account'); @@ -150,18 +148,14 @@ private function loginAs(User $user): void $this->assertSession()->statusCodeEquals(200); } - /** - * @Then /^I can see the registration form$/ - */ + #[Then('/^I can see the registration form$/')] public function iCanSeeTheRegistrationForm(): void { $this->assertSession()->pageTextNotContains('You are not allowed to register a new account'); $this->assertSession()->elementExists('css', 'form[name=ezplatform_content_forms_user_register]'); } - /** - * @Given /^it matches the structure of the configured registration user content type$/ - */ + #[Given('/^it matches the structure of the configured registration user content type$/')] public function itMatchesTheStructureOfTheConfiguredRegistrationUserContentType(): void { $userContentType = $this->contentTypeService->loadContentTypeByIdentifier('user'); @@ -177,9 +171,7 @@ public function itMatchesTheStructureOfTheConfiguredRegistrationUserContentType( } } - /** - * @Given /^it has a register button$/ - */ + #[Given('/^it has a register button$/')] public function itHasARegisterButton(): void { $this->assertSession()->elementExists( @@ -188,9 +180,7 @@ public function itHasARegisterButton(): void ); } - /** - * @When /^I fill in the form with valid values$/ - */ + #[When('/^I fill in the form with valid values$/')] public function iFillInTheFormWithValidValues(): void { $page = $this->getSession()->getPage(); @@ -205,34 +195,26 @@ public function iFillInTheFormWithValidValues(): void $page->fillField('ezplatform_content_forms_user_register[fieldsData][user_account][value][password][second]', self::$password); } - /** - * @When /^I click on the register button$/ - */ + #[When('/^I click on the register button$/')] public function iClickOnTheRegisterButton(): void { $this->getSession()->getPage()->pressButton('ezplatform_content_forms_user_register[register]'); $this->assertSession()->statusCodeEquals(200); } - /** - * @Then /^I am on the registration confirmation page$/ - */ + #[Then('/^I am on the registration confirmation page$/')] public function iAmOnTheRegistrationConfirmationPage(): void { $this->assertSession()->addressEquals('/register-confirm'); } - /** - * @Given /^I see a registration confirmation message$/ - */ + #[Given('/^I see a registration confirmation message$/')] public function iSeeARegistrationConfirmationMessage(): void { $this->assertSession()->pageTextContains('Your account has been created'); } - /** - * @Given /^the user account has been created$/ - */ + #[Given('/^the user account has been created$/')] public function theUserAccountHasBeenCreated(): void { if (null === $this->registrationUsername) { @@ -242,9 +224,7 @@ public function theUserAccountHasBeenCreated(): void $this->userService->loadUserByLogin($this->registrationUsername); } - /** - * @Given a User Group :userGroupName - */ + #[Given('a User Group :userGroupName')] public function createUserGroup(string $userGroupName): void { $groupCreateStruct = $this->userService->newUserGroupCreateStruct(self::$language); @@ -255,9 +235,7 @@ public function createUserGroup(string $userGroupName): void ); } - /** - * @Given /^the following user registration group configuration:$/ - */ + #[Given('/^the following user registration group configuration:$/')] public function addUserRegistrationConfiguration(PyStringNode $extraConfigurationString): void { $this->yamlConfigurationContext->addConfiguration(Yaml::parse( @@ -269,9 +247,7 @@ public function addUserRegistrationConfiguration(PyStringNode $extraConfiguratio )); } - /** - * @When /^I register a user account$/ - */ + #[When('/^I register a user account$/')] public function iRegisterAUserAccount(): void { $this->loginAsUserWithUserRegisterPolicy(); @@ -283,9 +259,7 @@ public function iRegisterAUserAccount(): void $this->iSeeARegistrationConfirmationMessage(); } - /** - * @Then /^the user is created in :userGroupName user group$/ - */ + #[Then('/^the user is created in :userGroupName user group$/')] public function theUserIsCreatedInThisUserGroup(string $userGroupName): void { if (null === $this->registrationUsername) { @@ -301,17 +275,13 @@ public function theUserIsCreatedInThisUserGroup(string $userGroupName): void ); } - /** - * @Given /^the following user registration templates configuration:$/ - */ + #[Given('/^the following user registration templates configuration:$/')] public function addRegistrationTemplatesConfiguration(PyStringNode $pyStringNode): void { $this->yamlConfigurationContext->addConfiguration(Yaml::parse((string) $pyStringNode)); } - /** - * @Given /^the following template in "([^"]*)":$/ - */ + #[Given('/^the following template in "([^"]*)":$/')] public function createTemplateAt(string $path, PyStringNode $contents): void { $fs = new Filesystem(); @@ -320,13 +290,12 @@ public function createTemplateAt(string $path, PyStringNode $contents): void } /** - * @Then /^the confirmation page is rendered using the "([^"]*)" template$/ - * @Then /^the form is rendered using the "([^"]*)" template$/ - * - * The template path to look for. - * If relative to app/Resources/views (example: user/register.html.twig), - * the path is checked with the :path:file.html.twig syntax as well. + * The template path to look for. + * If relative to app/Resources/views (example: user/register.html.twig), + * the path is checked with the :path:file.html.twig syntax as well. */ + #[Then('/^the confirmation page is rendered using the "([^"]*)" template$/')] + #[Then('/^the form is rendered using the "([^"]*)" template$/')] public function thePageIsRenderedUsingTheTemplateConfiguredIn(string $template): void { $html = $this->getSession()->getPage()->getOuterHtml();