From 0ddb44329d8116ef5a59c0f2fd814c3de1d3546b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Fri, 25 Aug 2023 11:44:10 +0200 Subject: [PATCH] Add taxonomy test v45 (#74) * Changed ezstring data provider * Added ElementAttributeMapper * Added timeout setting * Added Taxonomy suites --- behat_ibexa_commerce.yaml | 36 ++++++++++--------- behat_ibexa_content.yaml | 26 ++++++++------ behat_ibexa_experience.yaml | 20 ++++++----- .../FieldTypeData/TextLineDataProvider.php | 11 ++++-- .../ContentData/FieldTypeNameConverter.php | 1 + src/lib/API/Context/ContentTypeContext.php | 9 ++++- src/lib/Browser/Element/BaseElement.php | 2 ++ .../Element/Mapper/ElementAttributeMapper.php | 26 ++++++++++++++ .../Mapper/ElementAttributeMapperTest.php | 32 +++++++++++++++++ ...TestCase.php => ElementTextMapperTest.php} | 2 +- 10 files changed, 126 insertions(+), 39 deletions(-) create mode 100644 src/lib/Browser/Element/Mapper/ElementAttributeMapper.php create mode 100644 tests/lib/Browser/Element/Mapper/ElementAttributeMapperTest.php rename tests/lib/Browser/Element/Mapper/{TextMapperTestCase.php => ElementTextMapperTest.php} (94%) diff --git a/behat_ibexa_commerce.yaml b/behat_ibexa_commerce.yaml index 9cdea043..75ed85fa 100644 --- a/behat_ibexa_commerce.yaml +++ b/behat_ibexa_commerce.yaml @@ -26,30 +26,25 @@ regression: - Ibexa\Migration\Behat\Context\MigrationContext commerce: paths: - - '%paths.base%/vendor/ibexa/scheduler/features' - '%paths.base%/vendor/ibexa/admin-ui/features/personas' - '%paths.base%/vendor/ibexa/admin-ui/features/standard' - '%paths.base%/vendor/ibexa/corporate-account/features/browser' + - '%paths.base%/vendor/ibexa/fieldtype-page/features/eventSource' - '%paths.base%/vendor/ibexa/form-builder/features' - '%paths.base%/vendor/ibexa/page-builder/features/DynamicLandingPage' - '%paths.base%/vendor/ibexa/page-builder/features/personas' + - '%paths.base%/vendor/ibexa/payment/features' - '%paths.base%/vendor/ibexa/product-catalog/features/browser' - - '%paths.base%/vendor/ibexa/fieldtype-page/features/eventSource' - - '%paths.base%/vendor/ibexa/user/features/browser' - - '%paths.base%/vendor/ibexa/workflow/features/browser' + - '%paths.base%/vendor/ibexa/scheduler/features' - '%paths.base%/vendor/ibexa/segmentation/features' + - '%paths.base%/vendor/ibexa/taxonomy/features' + - '%paths.base%/vendor/ibexa/user/features/browser' - '%paths.base%/vendor/ibexa/version-comparison/features' - - '%paths.base%/vendor/ibexa/payment/features' + - '%paths.base%/vendor/ibexa/workflow/features/browser' filters: tags: "~@broken&&@IbexaCommerce" contexts: - Behat\MinkExtension\Context\MinkContext - - Ibexa\Behat\API\Context\ContentContext - - Ibexa\Behat\API\Context\ContentTypeContext - - Ibexa\Behat\API\Context\RoleContext - - Ibexa\Behat\API\Context\TestContext - - Ibexa\Behat\API\Context\TrashContext - - Ibexa\Behat\API\Context\UserContext - Ibexa\AdminUi\Behat\BrowserContext\AdminUpdateContext - Ibexa\AdminUi\Behat\BrowserContext\BookmarkContext - Ibexa\AdminUi\Behat\BrowserContext\ContentActionsMenuContext @@ -70,6 +65,12 @@ regression: - Ibexa\AdminUi\Behat\BrowserContext\UDWContext - Ibexa\AdminUi\Behat\BrowserContext\UserNotificationContext - Ibexa\AdminUi\Behat\BrowserContext\UserPreferencesContext + - Ibexa\Behat\API\Context\ContentContext + - Ibexa\Behat\API\Context\ContentTypeContext + - Ibexa\Behat\API\Context\RoleContext + - Ibexa\Behat\API\Context\TestContext + - Ibexa\Behat\API\Context\TrashContext + - Ibexa\Behat\API\Context\UserContext - Ibexa\Behat\Browser\Context\AuthenticationContext - Ibexa\Behat\Browser\Context\DebuggingContext - Ibexa\CorporateAccount\Behat\Context\CompaniesContext @@ -81,18 +82,21 @@ regression: - Ibexa\FormBuilder\Behat\BrowserContext\FormFrontContext - Ibexa\Migration\Behat\Context\MigrationContext - Ibexa\PageBuilder\Behat\Context\PageBuilderContext - - Ibexa\ProductCatalog\Behat\Context\AttributesContext + - Ibexa\Payment\Behat\Context\PaymentMethodsContext - Ibexa\ProductCatalog\Behat\Context\AttributeGroupsContext + - Ibexa\ProductCatalog\Behat\Context\AttributesContext - Ibexa\ProductCatalog\Behat\Context\CatalogsContext + - Ibexa\ProductCatalog\Behat\Context\CurrenciesContext - Ibexa\ProductCatalog\Behat\Context\CustomerGroupsContext - - Ibexa\ProductCatalog\Behat\Context\ProductTypesContext - Ibexa\ProductCatalog\Behat\Context\ProductsContext - - Ibexa\ProductCatalog\Behat\Context\CurrenciesContext + - Ibexa\ProductCatalog\Behat\Context\ProductTypesContext - Ibexa\Scheduler\Behat\BrowserContext\DateBasedPublisherContext + - Ibexa\Segmentation\Behat\Context\SegmentationContext + - Ibexa\Segmentation\Behat\Context\SegmentationContext + - Ibexa\Taxonomy\Behat\Context\Browser\TaxonomyContext + - Ibexa\Taxonomy\Behat\Context\Service\TaxonomyContext - Ibexa\User\Behat\Context\UserSettingsContext - Ibexa\User\Behat\Context\UserSetupContext - Ibexa\VersionComparison\Behat\Context\VersionComparisonContext - Ibexa\Workflow\Behat\Context\WorkflowAdminContext - Ibexa\Workflow\Behat\Context\WorkflowContext - - Ibexa\Segmentation\Behat\Context\SegmentationContext - - Ibexa\Payment\Behat\Context\PaymentMethodsContext diff --git a/behat_ibexa_content.yaml b/behat_ibexa_content.yaml index 04b1a231..aaeeb3e8 100644 --- a/behat_ibexa_content.yaml +++ b/behat_ibexa_content.yaml @@ -1,9 +1,10 @@ imports: - behat_ibexa_oss.yaml - - vendor/ibexa/scheduler/behat_suites_content.yml - - vendor/ibexa/workflow/behat_suites_content.yml - vendor/ibexa/product-catalog/behat_suites.yml + - vendor/ibexa/scheduler/behat_suites_content.yml + - vendor/ibexa/taxonomy/behat_suites_content.yml - vendor/ibexa/version-comparison/behat_suites.yml + - vendor/ibexa/workflow/behat_suites_content.yml regression: suites: @@ -28,13 +29,14 @@ regression: - Ibexa\Migration\Behat\Context\MigrationContext content: paths: - - '%paths.base%/vendor/ibexa/scheduler/features' - - '%paths.base%/vendor/ibexa/admin-ui/features/personas' - - '%paths.base%/vendor/ibexa/admin-ui/features/standard' - - '%paths.base%/vendor/ibexa/product-catalog/features/browser' - - '%paths.base%/vendor/ibexa/user/features/browser' - - '%paths.base%/vendor/ibexa/workflow/features/browser' - - '%paths.base%/vendor/ibexa/version-comparison/features' + - '%paths.base%/vendor/ibexa/admin-ui/features/personas' + - '%paths.base%/vendor/ibexa/admin-ui/features/standard' + - '%paths.base%/vendor/ibexa/product-catalog/features/browser' + - '%paths.base%/vendor/ibexa/scheduler/features' + - '%paths.base%/vendor/ibexa/taxonomy/features' + - '%paths.base%/vendor/ibexa/user/features/browser' + - '%paths.base%/vendor/ibexa/version-comparison/features' + - '%paths.base%/vendor/ibexa/workflow/features/browser' filters: tags: "~@broken&&@IbexaContent" contexts: @@ -73,9 +75,11 @@ regression: - Ibexa\ProductCatalog\Behat\Context\CatalogsContext - Ibexa\ProductCatalog\Behat\Context\CustomerGroupsContext - Ibexa\ProductCatalog\Behat\Context\ProductTypesContext - - Ibexa\ProductCatalog\Behat\Context\ProductsContext - - Ibexa\ProductCatalog\Behat\Context\CurrenciesContext + - Ibexa\ProductCatalog\Behat\Context\ProductsContext + - Ibexa\ProductCatalog\Behat\Context\CurrenciesContext - Ibexa\Scheduler\Behat\BrowserContext\DateBasedPublisherContext + - Ibexa\Taxonomy\Behat\Context\Browser\TaxonomyContext + - Ibexa\Taxonomy\Behat\Context\Service\TaxonomyContext - Ibexa\User\Behat\Context\UserSettingsContext - Ibexa\User\Behat\Context\UserSetupContext - Ibexa\VersionComparison\Behat\Context\VersionComparisonContext diff --git a/behat_ibexa_experience.yaml b/behat_ibexa_experience.yaml index 819a804c..09c99c1b 100644 --- a/behat_ibexa_experience.yaml +++ b/behat_ibexa_experience.yaml @@ -1,13 +1,14 @@ imports: - behat_ibexa_content.yaml - - vendor/ibexa/scheduler/behat_suites_experience.yml + - vendor/ibexa/corporate-account/behat_suites.yml + - vendor/ibexa/fieldtype-page/behat_suites.yml - vendor/ibexa/form-builder/behat_suites.yml - vendor/ibexa/page-builder/behat_suites.yml - - vendor/ibexa/fieldtype-page/behat_suites.yml + - vendor/ibexa/scheduler/behat_suites_experience.yml + - vendor/ibexa/segmentation/behat_suites.yml - vendor/ibexa/site-factory/behat_suites.yml + - vendor/ibexa/taxonomy/behat_suites_experience.yml - vendor/ibexa/workflow/behat_suites_experience.yml - - vendor/ibexa/segmentation/behat_suites.yml - - vendor/ibexa/corporate-account/behat_suites.yml regression: suites: @@ -33,19 +34,20 @@ regression: - Ibexa\Migration\Behat\Context\MigrationContext experience: paths: - - '%paths.base%/vendor/ibexa/scheduler/features' - '%paths.base%/vendor/ibexa/admin-ui/features/personas' - '%paths.base%/vendor/ibexa/admin-ui/features/standard' - '%paths.base%/vendor/ibexa/corporate-account/features/browser' + - '%paths.base%/vendor/ibexa/fieldtype-page/features/eventSource' - '%paths.base%/vendor/ibexa/form-builder/features' - '%paths.base%/vendor/ibexa/page-builder/features/DynamicLandingPage' - '%paths.base%/vendor/ibexa/page-builder/features/personas' - '%paths.base%/vendor/ibexa/product-catalog/features/browser' - - '%paths.base%/vendor/ibexa/fieldtype-page/features/eventSource' - - '%paths.base%/vendor/ibexa/user/features/browser' - - '%paths.base%/vendor/ibexa/workflow/features/browser' + - '%paths.base%/vendor/ibexa/scheduler/features' - '%paths.base%/vendor/ibexa/segmentation/features' + - '%paths.base%/vendor/ibexa/taxonomy/features' + - '%paths.base%/vendor/ibexa/user/features/browser' - '%paths.base%/vendor/ibexa/version-comparison/features' + - '%paths.base%/vendor/ibexa/workflow/features/browser' filters: tags: "~@broken&&@IbexaExperience" contexts: @@ -95,6 +97,8 @@ regression: - Ibexa\ProductCatalog\Behat\Context\ProductsContext - Ibexa\ProductCatalog\Behat\Context\CurrenciesContext - Ibexa\Scheduler\Behat\BrowserContext\DateBasedPublisherContext + - Ibexa\Taxonomy\Behat\Context\Browser\TaxonomyContext + - Ibexa\Taxonomy\Behat\Context\Service\TaxonomyContext - Ibexa\User\Behat\Context\UserSettingsContext - Ibexa\User\Behat\Context\UserSetupContext - Ibexa\VersionComparison\Behat\Context\VersionComparisonContext diff --git a/src/lib/API/ContentData/FieldTypeData/TextLineDataProvider.php b/src/lib/API/ContentData/FieldTypeData/TextLineDataProvider.php index 778067ce..cf95b421 100644 --- a/src/lib/API/ContentData/FieldTypeData/TextLineDataProvider.php +++ b/src/lib/API/ContentData/FieldTypeData/TextLineDataProvider.php @@ -8,6 +8,8 @@ namespace Ibexa\Behat\API\ContentData\FieldTypeData; +use Ibexa\Core\FieldType\TextLine\Value; + class TextLineDataProvider extends AbstractFieldTypeDataProvider { public function supports(string $fieldTypeIdentifier): bool @@ -15,11 +17,16 @@ public function supports(string $fieldTypeIdentifier): bool return 'ezstring' === $fieldTypeIdentifier; } - public function generateData(string $contentTypeIdentifier, string $fieldIdentifier, string $language = 'eng-GB'): string + public function generateData(string $contentTypeIdentifier, string $fieldIdentifier, string $language = 'eng-GB'): Value { $this->setLanguage($language); - return $this->getFaker()->realText(80, 1); + return new Value($this->getFaker()->realText(80, 1)); + } + + public function parseFromString(string $value): Value + { + return new Value($value); } } diff --git a/src/lib/API/ContentData/FieldTypeNameConverter.php b/src/lib/API/ContentData/FieldTypeNameConverter.php index 337b22eb..6558c7a0 100644 --- a/src/lib/API/ContentData/FieldTypeNameConverter.php +++ b/src/lib/API/ContentData/FieldTypeNameConverter.php @@ -41,6 +41,7 @@ class FieldTypeNameConverter 'eztime' => 'Time', 'ezurl' => 'URL', 'ezuser' => 'User account', + 'ibexa_taxonomy_entry_assignment' => 'Taxonomy Entry Assignment', ]; public static function getFieldTypeNameByIdentifier(string $fieldTypeIdentifier): string diff --git a/src/lib/API/Context/ContentTypeContext.php b/src/lib/API/Context/ContentTypeContext.php index a38bf86a..a2730f14 100644 --- a/src/lib/API/Context/ContentTypeContext.php +++ b/src/lib/API/Context/ContentTypeContext.php @@ -76,7 +76,6 @@ private function parseBool(string $value): bool private function parseFieldSettings(string $fieldTypeIdentifier, string $settings) { $parsedSettings = []; - // TODO: Clean this up in the future if needed switch ($fieldTypeIdentifier) { case 'ezcontentquery': return $this->parseContentQuerySettings($settings); @@ -87,6 +86,9 @@ private function parseFieldSettings(string $fieldTypeIdentifier, string $setting case 'ezselection': return $this->parseSelectionSettings($settings); + case 'ibexa_taxonomy_entry_assignment': + return $this->parseTaxonomySettings($settings); + default: return $parsedSettings; } @@ -141,6 +143,11 @@ private function parseContentQuerySettings(string $settings): array return $parsedSettings; } + + private function parseTaxonomySettings(string $settings): array + { + return ['taxonomy' => $settings]; + } } class_alias(ContentTypeContext::class, 'EzSystems\Behat\API\Context\ContentTypeContext'); diff --git a/src/lib/Browser/Element/BaseElement.php b/src/lib/Browser/Element/BaseElement.php index faf33c83..9c52f53e 100644 --- a/src/lib/Browser/Element/BaseElement.php +++ b/src/lib/Browser/Element/BaseElement.php @@ -89,6 +89,8 @@ function () use ($locator) { $wrappedElement = $this->elementFactory->createElement($this->elementFactory, $locator, $foundMinkElement); if ($locator->elementMeetsCriteria($wrappedElement)) { + $wrappedElement->setTimeout($this->getTimeout()); + return $wrappedElement; } } diff --git a/src/lib/Browser/Element/Mapper/ElementAttributeMapper.php b/src/lib/Browser/Element/Mapper/ElementAttributeMapper.php new file mode 100644 index 00000000..c3d94c3d --- /dev/null +++ b/src/lib/Browser/Element/Mapper/ElementAttributeMapper.php @@ -0,0 +1,26 @@ +attribute = $attribute; + } + + public function map(ElementInterface $element): string + { + return $element->getAttribute($this->attribute); + } +} diff --git a/tests/lib/Browser/Element/Mapper/ElementAttributeMapperTest.php b/tests/lib/Browser/Element/Mapper/ElementAttributeMapperTest.php new file mode 100644 index 00000000..3d049e32 --- /dev/null +++ b/tests/lib/Browser/Element/Mapper/ElementAttributeMapperTest.php @@ -0,0 +1,32 @@ +mapper = new ElementAttributeMapper('data-id'); + } + + public function testMapsSingleElement(): void + { + $element = $this->createStub(ElementInterface::class); + $element->method('getAttribute')->willReturn('AttributeValue'); + + Assert::assertEquals('AttributeValue', $this->mapper->map($element)); + } +} diff --git a/tests/lib/Browser/Element/Mapper/TextMapperTestCase.php b/tests/lib/Browser/Element/Mapper/ElementTextMapperTest.php similarity index 94% rename from tests/lib/Browser/Element/Mapper/TextMapperTestCase.php rename to tests/lib/Browser/Element/Mapper/ElementTextMapperTest.php index 37c2966d..5b84c7f8 100644 --- a/tests/lib/Browser/Element/Mapper/TextMapperTestCase.php +++ b/tests/lib/Browser/Element/Mapper/ElementTextMapperTest.php @@ -12,7 +12,7 @@ use Ibexa\Tests\Behat\Browser\Element\BaseTestCase; use PHPUnit\Framework\Assert; -class TextMapperTestCase extends BaseTestCase +class ElementTextMapperTest extends BaseTestCase { /** @var \Ibexa\Behat\Browser\Element\Mapper\ElementTextMapper */ private $mapper;