Skip to content

Commit

Permalink
Add taxonomy test v45 (#74)
Browse files Browse the repository at this point in the history
* Changed ezstring data provider

* Added ElementAttributeMapper

* Added timeout setting

* Added Taxonomy suites
  • Loading branch information
mnocon authored Aug 25, 2023
1 parent 576e774 commit 0ddb443
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 39 deletions.
36 changes: 20 additions & 16 deletions behat_ibexa_commerce.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
26 changes: 15 additions & 11 deletions behat_ibexa_content.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
20 changes: 12 additions & 8 deletions behat_ibexa_experience.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions src/lib/API/ContentData/FieldTypeData/TextLineDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,25 @@

namespace Ibexa\Behat\API\ContentData\FieldTypeData;

use Ibexa\Core\FieldType\TextLine\Value;

class TextLineDataProvider extends AbstractFieldTypeDataProvider
{
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);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/lib/API/ContentData/FieldTypeNameConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion src/lib/API/Context/ContentTypeContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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');
2 changes: 2 additions & 0 deletions src/lib/Browser/Element/BaseElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
26 changes: 26 additions & 0 deletions src/lib/Browser/Element/Mapper/ElementAttributeMapper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Behat\Browser\Element\Mapper;

use Ibexa\Behat\Browser\Element\ElementInterface;

class ElementAttributeMapper implements MapperInterface
{
private string $attribute;

public function __construct(string $attribute)
{
$this->attribute = $attribute;
}

public function map(ElementInterface $element): string
{
return $element->getAttribute($this->attribute);
}
}
32 changes: 32 additions & 0 deletions tests/lib/Browser/Element/Mapper/ElementAttributeMapperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Tests\Behat\Browser\Element\Mapper;

use Ibexa\Behat\Browser\Element\ElementInterface;
use Ibexa\Behat\Browser\Element\Mapper\ElementAttributeMapper;
use Ibexa\Tests\Behat\Browser\Element\BaseTestCase;
use PHPUnit\Framework\Assert;

class ElementAttributeMapperTest extends BaseTestCase
{
private ElementAttributeMapper $mapper;

protected function setUp(): void
{
$this->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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0ddb443

Please sign in to comment.