From 106c7f40af5d59baab507d1fa6ada4ae5371280e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Mon, 15 Dec 2025 23:00:56 +0100 Subject: [PATCH] Removed Behat testing --- tests/README.md | 21 -- tests/behat_suites.yml | 11 -- tests/config/services.yaml | 14 -- tests/features/EnterpriseTutorial.feature | 85 -------- tests/scripts/setup.sh | 39 ---- .../step2/landingpagetemplate.html.twig | 6 - .../source_files/step2/layoutdefinition.yaml | 13 -- .../step2/sidebartemplate.html.twig | 36 ---- tests/source_files/step3/article.html.twig | 4 - .../step3/contentlisttemplate.html.twig | 24 --- tests/source_files/step3/contentscheduler.css | 30 --- tests/source_files/step3/landingpage.css | 23 --- .../step3/scheduleblock.html.twig | 19 -- .../step4/RandomBlockListener.php | 122 ------------ tests/source_files/step4/random.html.twig | 7 - tests/source_files/step4/randomblock.css | 20 -- .../step5/form_field_theme.html.twig | 12 -- .../step5/form_newsletter_view.html.twig | 10 - tests/source_files/step5/form_style.css | 50 ----- tests/src/ConfigurationEditor.php | 62 ------ tests/src/ContentDataCreator.php | 105 ---------- tests/src/Context/ConfigurationContext.php | 184 ------------------ tests/src/Context/ContentContext.php | 84 -------- tests/src/Context/FileContext.php | 76 -------- .../Context/TutorialContentTypeContext.php | 83 -------- 25 files changed, 1140 deletions(-) delete mode 100644 tests/README.md delete mode 100644 tests/behat_suites.yml delete mode 100644 tests/config/services.yaml delete mode 100644 tests/features/EnterpriseTutorial.feature delete mode 100755 tests/scripts/setup.sh delete mode 100644 tests/source_files/step2/landingpagetemplate.html.twig delete mode 100644 tests/source_files/step2/layoutdefinition.yaml delete mode 100644 tests/source_files/step2/sidebartemplate.html.twig delete mode 100644 tests/source_files/step3/article.html.twig delete mode 100644 tests/source_files/step3/contentlisttemplate.html.twig delete mode 100644 tests/source_files/step3/contentscheduler.css delete mode 100644 tests/source_files/step3/landingpage.css delete mode 100644 tests/source_files/step3/scheduleblock.html.twig delete mode 100644 tests/source_files/step4/RandomBlockListener.php delete mode 100644 tests/source_files/step4/random.html.twig delete mode 100644 tests/source_files/step4/randomblock.css delete mode 100644 tests/source_files/step5/form_field_theme.html.twig delete mode 100644 tests/source_files/step5/form_newsletter_view.html.twig delete mode 100644 tests/source_files/step5/form_style.css delete mode 100644 tests/src/ConfigurationEditor.php delete mode 100644 tests/src/ContentDataCreator.php delete mode 100644 tests/src/Context/ConfigurationContext.php delete mode 100644 tests/src/Context/ContentContext.php delete mode 100644 tests/src/Context/FileContext.php delete mode 100644 tests/src/Context/TutorialContentTypeContext.php diff --git a/tests/README.md b/tests/README.md deleted file mode 100644 index 9d187ad7a1..0000000000 --- a/tests/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# How to run tests - -## Enterprise Tutorial - -These tests should be run using the ezplatform-ee metarepository. - -1. Add developer-documentation to your project by running the following commands: -``` -composer config repositories.doc vcs http://github.com/ezsystems/developer-documentation.git -composer require --dev ezsystems/developer-documentation:dev-master - -# optional: run to list all available branches -composer show -a ezystems/developer-documentation -``` -2. Run setup script: -`./vendor/ezsystems/developer-documentation/tests/scripts/setup.sh` -3. Run `export APP_ENV=behat` in the console. -4. Run tests by using one of the following commands: -- To run all tests, use: `bin/behat --profile=doc` -- To run a specific test step, use: `bin/behat --profile=doc --tags=step1` -5. After execution, run `composer run post-install-cmd`. diff --git a/tests/behat_suites.yml b/tests/behat_suites.yml deleted file mode 100644 index 5e78c5f392..0000000000 --- a/tests/behat_suites.yml +++ /dev/null @@ -1,11 +0,0 @@ -doc: - suites: - enterpriseTutorial: - paths: - - '%paths.base%/vendor/ezsystems/developer-documentation/tests/features' - contexts: - - EzSystems\DeveloperDocumentation\Test\Context\TutorialContentTypeContext - - EzSystems\DeveloperDocumentation\Test\Context\ConfigurationContext - - EzSystems\DeveloperDocumentation\Test\Context\FileContext - - EzSystems\EzPlatformContentForms\Behat\Context\ContentTypeContext - - EzSystems\DeveloperDocumentation\Test\Context\ContentContext diff --git a/tests/config/services.yaml b/tests/config/services.yaml deleted file mode 100644 index 48c0d530df..0000000000 --- a/tests/config/services.yaml +++ /dev/null @@ -1,14 +0,0 @@ - -# This file is not used directly but copied to config/services.yaml in setup script - EzSystems\DeveloperDocumentation\Test\Context\FileContext: - arguments: - $basePath: '%kernel.project_dir%' - - EzSystems\DeveloperDocumentation\Test\Context\ConfigurationContext: - arguments: - $basePath: '%kernel.project_dir%' - - EzSystems\DeveloperDocumentation\Test\Context\ContentContext: - arguments: - $repository: '@ezpublish.api.repository' - $basePath: '%kernel.project_dir%' diff --git a/tests/features/EnterpriseTutorial.feature b/tests/features/EnterpriseTutorial.feature deleted file mode 100644 index 5c30518dc8..0000000000 --- a/tests/features/EnterpriseTutorial.feature +++ /dev/null @@ -1,85 +0,0 @@ -Feature: Setup eZ Platform Enterprise dogs tutorial - - @step1 - Scenario: Get a starter website - Given I create a "Dog Breed" content type with "dog_breed" identifier: - | Field type | Name | Identifier | Required | Searchable | Translatable | - | Text line | Name | name | yes | yes | yes | - | Text line | Short Description | short_description | yes | yes | yes | - | Image | Photo | photo | yes | no | no | - | RichText | Full Description | description | yes | yes | yes | - And I create a "Tip" content type with "tip" identifier: - | Field type | Name | Identifier | Required | Searchable | Translatable | - | Text line | Title | title | yes | yes | yes | - | Text block | Body | body | no | no | yes | - And I remove "image" field from Article content type - And I add field to Article content type - | Field type | Name | Identifier | Required | Searchable | Translatable | - | Image | Image | image | no | no | yes | - And I create "folder" content items in "Home" - | contentName | - | All Articles | - | Dog Breed Catalog | - | All Tips | - And I create "article" content items in "Home/All Articles" - | contentName | imageName | - | Dog favorites | article1.jpg | - | Adopt or buy? | article2.jpg | - | Dogs and other pets | article3.jpg | - | Taking care of your dog during a heatwave | article4.jpg | - | Dog owner's first steps | article5.jpg | - | Traveling with your dog | article6.jpg | - And I create "dog_breed" content items in "Home/Dog Breed Catalog" - | contentName | imageName | - | Alsatian | alsatian.jpg | - | King Charles Spaniel | king-charles-spaniel.jpg | - | St Bernard | st-bernard.jpg | - And I create "tip" content items in "Home/All Tips" - | contentName | - | Tip1 | - | Tip2 | - | Tip3 | - And I delete eZ Platform Folder under Home - And I rebuild Webpack Encore assets - - @step2 - Scenario: Prepare the Landing Page - Given I create a file "config/packages/ezplatform_page_fieldtype.yaml" containing "step2/layoutdefinition.yaml" - And I add thumbnail image to "public/assets/images/layouts/" - And I create a file "templates/layouts/sidebar.html.twig" containing "step2/sidebartemplate.html.twig" - And I create a file "templates/full/landing_page.html.twig" containing "step2/landingpagetemplate.html.twig" - And I set the Landing Page template configuration in "config/packages/views.yaml" - And I rebuild Webpack Encore assets - - @step3 - Scenario: Use existing blocks - Given I create a file "templates/blocks/contentlist/default.html.twig" containing "step3/contentlisttemplate.html.twig" - And I add Content List layout configuration to "config/packages/ezplatform_page_fieldtype.yaml" - And I set Content List image variations in "config/packages/image_variations.yaml" - And I append to "assets/css/style.css" file "step3/landingpage.css" - And I add Content Scheduler layout configuration to "config/packages/ezplatform_page_fieldtype.yaml" - And I create a file "templates/blocks/schedule/featured.html.twig" containing "step3/scheduleblock.html.twig" - And I set template for Article in "config/packages/views.yaml" - And I create a file "templates/featured/article.html.twig" containing "step3/article.html.twig" - And I set Content Scheduler image variations in "config/packages/image_variations.yaml" - And I append to "assets/css/style.css" file "step3/contentscheduler.css" - And I rebuild Webpack Encore assets - - @step4 - Scenario: Create a custom block - Given I create configuration of Random block to "config/packages/ezplatform_page_fieldtype.yaml" - And I create a file "templates/blocks/random/default.html.twig" containing "step4/random.html.twig" - And I create a file "src/Event/RandomBlockListener.php" containing "step4/RandomBlockListener.php" - And I copy the block icon to "public/assets/images/blocks" - And I append to "assets/css/style.css" file "step4/randomblock.css" - And I rebuild Webpack Encore assets - - @step5 - Scenario: Create a newsletter form block - Given I create configuration of Form block to "config/packages/ezplatform_page_fieldtype.yaml" - And I create a file "templates/blocks/form/newsletter.html.twig" containing "step5/form_newsletter_view.html.twig" - And I create a file "templates/fields/form_field.html.twig" containing "step5/form_field_theme.html.twig" - And I create configuration of Form field to "config/packages/views.yaml" - And I create configuration of Captcha field to "config/packages/gregwar_captcha.yaml" - And I append to "assets/css/style.css" file "step5/form_style.css" - And I rebuild Webpack Encore assets diff --git a/tests/scripts/setup.sh b/tests/scripts/setup.sh deleted file mode 100755 index c999f4291d..0000000000 --- a/tests/scripts/setup.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -TUTORIAL_REPOSITORY=https://github.com/ezsystems/ezplatform-ee-beginner-tutorial -STEP1_BRANCH=v3-step1 -STEP4_BRANCH=v3-step4 -TUTORIAL_DATA_DIRECTORY_1=tutorial_data_1 -TUTORIAL_DATA_DIRECTORY_2=tutorial_data_2 -IMAGES_SOURCE=vendor/ezsystems/developer-documentation/docs/tutorials/enterprise_beginner/img/photos.zip -IMAGES_DESTINATION=./images - -# clone tutorial data -git clone $TUTORIAL_REPOSITORY --depth=1 -b $STEP1_BRANCH $TUTORIAL_DATA_DIRECTORY_1 -git clone $TUTORIAL_REPOSITORY --depth=1 -b $STEP4_BRANCH $TUTORIAL_DATA_DIRECTORY_2 - -# add suite to Behat -echo ' - vendor/ezsystems/developer-documentation/tests/behat_suites.yml' >> behat.yml.dist - -# copy images -mkdir $IMAGES_DESTINATION -unzip $IMAGES_SOURCE -d $IMAGES_DESTINATION - -# copy templates, styles and configuration files -cp $TUTORIAL_DATA_DIRECTORY_1/templates/{pagelayout.html.twig,pagelayout_menu.html.twig} ./templates - -mkdir ./templates/full -cp $TUTORIAL_DATA_DIRECTORY_1/templates/full/{article.html.twig,dog_breed.html.twig,folder.html.twig,tip.html.twig} ./templates/full -cp $TUTORIAL_DATA_DIRECTORY_1/config/packages/{views.yaml,image_variations.yaml} ./config/packages - -cp $TUTORIAL_DATA_DIRECTORY_1/webpack.config.js ./ - -mkdir -p ./assets/{css,images} -cp $TUTORIAL_DATA_DIRECTORY_1/assets/css/style.css assets/css -cp $TUTORIAL_DATA_DIRECTORY_1/assets/images/header.jpg assets/images - -mkdir ./src/QueryType -cp $TUTORIAL_DATA_DIRECTORY_1/src/QueryType/MenuQueryType.php ./src/QueryType - -# add Context service definitions to the appplication -cat ./vendor/ezsystems/developer-documentation/tests/config/services.yaml >> config/services.yaml diff --git a/tests/source_files/step2/landingpagetemplate.html.twig b/tests/source_files/step2/landingpagetemplate.html.twig deleted file mode 100644 index 57bb78b596..0000000000 --- a/tests/source_files/step2/landingpagetemplate.html.twig +++ /dev/null @@ -1,6 +0,0 @@ -{% extends 'pagelayout.html.twig' %} -{% block content %} -
- {{ ez_render_field(content, 'page') }} -
-{% endblock %} diff --git a/tests/source_files/step2/layoutdefinition.yaml b/tests/source_files/step2/layoutdefinition.yaml deleted file mode 100644 index e62f1f0c63..0000000000 --- a/tests/source_files/step2/layoutdefinition.yaml +++ /dev/null @@ -1,13 +0,0 @@ -ezplatform_page_fieldtype: - layouts: - sidebar: - identifier: sidebar - name: Right sidebar - description: Main section with sidebar on the right - thumbnail: /assets/images/layouts/sidebar.png - template: layouts/sidebar.html.twig - zones: - first: - name: First zone - second: - name: Second zone \ No newline at end of file diff --git a/tests/source_files/step2/sidebartemplate.html.twig b/tests/source_files/step2/sidebartemplate.html.twig deleted file mode 100644 index 109c181d0f..0000000000 --- a/tests/source_files/step2/sidebartemplate.html.twig +++ /dev/null @@ -1,36 +0,0 @@ -
-
- {% if zones[0].blocks %} - {% set locationId = parameters.location is not null ? parameters.location.id : contentInfo.mainLocationId %} - - {% for block in zones[0].blocks %} -
- {{ render_esi(controller('EzSystems\\EzPlatformPageFieldTypeBundle\\Controller\\BlockController::renderAction', { - 'locationId': locationId, - 'contentId': contentInfo.id, - 'blockId': block.id, - 'versionNo': versionInfo.versionNo, - 'languageCode': field.languageCode - })) }} -
- {% endfor %} - {% endif %} -
- -
\ No newline at end of file diff --git a/tests/source_files/step3/article.html.twig b/tests/source_files/step3/article.html.twig deleted file mode 100644 index fb95e0884c..0000000000 --- a/tests/source_files/step3/article.html.twig +++ /dev/null @@ -1,4 +0,0 @@ -{% set imageAlias = ez_image_alias(content.getField('image'), content.versionInfo, 'featured_article') %} -
-

{{ ez_content_name(content) }}

-
diff --git a/tests/source_files/step3/contentlisttemplate.html.twig b/tests/source_files/step3/contentlisttemplate.html.twig deleted file mode 100644 index 2e79e0b6f3..0000000000 --- a/tests/source_files/step3/contentlisttemplate.html.twig +++ /dev/null @@ -1,24 +0,0 @@ -
-

{{ parentName }}

- {% if contentArray|length > 0 %} -
- {% for content in contentArray %} -
-
- {{ ez_render_field(content.content, 'photo', { - 'parameters': { - 'alias': 'content_list' - } - }) }} -
-

{{ ez_content_name(content.content) }}

- {% if not ez_field_is_empty(content.content, 'short_description') %} -
- {{ ez_render_field(content.content, 'short_description') }} -
- {% endif %} -
- {% endfor %} -
- {% endif %} -
diff --git a/tests/source_files/step3/contentscheduler.css b/tests/source_files/step3/contentscheduler.css deleted file mode 100644 index 768f251355..0000000000 --- a/tests/source_files/step3/contentscheduler.css +++ /dev/null @@ -1,30 +0,0 @@ -/* Featured articles Content Scheduler block */ -.featured-article-container { - background-size: cover; - padding: 0; - margin-bottom: 20px; -} - -.featured-article { - height: 200px; - padding: 0; - background-repeat: no-repeat; -} - -.featured-article-link:link, -.featured-article-link:visited { - position: absolute; - bottom: 0; - margin-bottom: 0; - background-color: rgba(255,255,255,.8); - color: #000; - font-size: 1.1em; - padding: 7px; -} - -.featured-article-link:hover, -.featured-article-link:focus { - color: #654d31; - text-decoration: none; - border-bottom: none; -} \ No newline at end of file diff --git a/tests/source_files/step3/landingpage.css b/tests/source_files/step3/landingpage.css deleted file mode 100644 index 1a2c4ecc53..0000000000 --- a/tests/source_files/step3/landingpage.css +++ /dev/null @@ -1,23 +0,0 @@ -/* Landing Page */ -@media only screen and (min-width: 992px) { - aside > div { - padding-left: 45px; - } -} - -/* Content list block */ -.content-list-item { - clear: left; - min-height: 90px; - padding-bottom: 5px; - border-bottom: 1px solid black; -} - -.content-list h5 { - font-size: 1.3em; -} - -.content-list-item-image { - float: left; - margin-right: 10px; -} \ No newline at end of file diff --git a/tests/source_files/step3/scheduleblock.html.twig b/tests/source_files/step3/scheduleblock.html.twig deleted file mode 100644 index 58353fe451..0000000000 --- a/tests/source_files/step3/scheduleblock.html.twig +++ /dev/null @@ -1,19 +0,0 @@ -{% apply spaceless %} -
- -
-{% endapply %} diff --git a/tests/source_files/step4/RandomBlockListener.php b/tests/source_files/step4/RandomBlockListener.php deleted file mode 100644 index 5151296c84..0000000000 --- a/tests/source_files/step4/RandomBlockListener.php +++ /dev/null @@ -1,122 +0,0 @@ -contentService = $contentService; - $this->locationService = $locationService; - $this->searchService = $searchService; - } - - /** - * @return array The event names to listen to - */ - public static function getSubscribedEvents() - { - return [ - BlockRenderEvents::getBlockPreRenderEventName('random') => 'onBlockPreRender', - ]; - } - - /** - * @param \EzSystems\EzPlatformPageFieldType\FieldType\Page\Block\Renderer\Event\PreRenderEvent $event - * - * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException - * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException - */ - public function onBlockPreRender(PreRenderEvent $event): void - { - $blockValue = $event->getBlockValue(); - $renderRequest = $event->getRenderRequest(); - - $parameters = $renderRequest->getParameters(); - - $contentIdAttribute = $blockValue->getAttribute('parent'); - $location = $this->loadLocationByContentId((int) $contentIdAttribute->getValue()); - $contents = $this->findContentItems($location); - shuffle($contents); - - $parameters['randomContent'] = reset($contents); - - $renderRequest->setParameters($parameters); - } - - /** - * @param \eZ\Publish\API\Repository\Values\Content\Location $location - * - * @return \eZ\Publish\API\Repository\Values\Content\Content[] - * - * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException - */ - private function findContentItems(Location $location): array - { - $query = new Query(); - $query->query = new Criterion\LogicalAnd( - [ - new Criterion\ParentLocationId($location->id), - new Criterion\Visibility(Criterion\Visibility::VISIBLE), - ] - ); - - $searchHits = $this->searchService->findContent($query)->searchHits; - - $contentArray = []; - foreach ($searchHits as $searchHit) { - $contentArray[] = $searchHit->valueObject; - } - - return $contentArray; - } - - /** - * @param int $contentId - * - * @return \eZ\Publish\API\Repository\Values\Content\Location - * - * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException - */ - private function loadLocationByContentId(int $contentId): Location - { - $contentInfo = $this->contentService->loadContentInfo($contentId); - - return $this->locationService->loadLocation($contentInfo->mainLocationId); - } -} diff --git a/tests/source_files/step4/random.html.twig b/tests/source_files/step4/random.html.twig deleted file mode 100644 index 3609236476..0000000000 --- a/tests/source_files/step4/random.html.twig +++ /dev/null @@ -1,7 +0,0 @@ -
-

{{ 'Tip of the Day'|trans }}

-
{{ ez_content_name(randomContent) }}
-
- {{ ez_render_field(randomContent, 'body') }} -
-
\ No newline at end of file diff --git a/tests/source_files/step4/randomblock.css b/tests/source_files/step4/randomblock.css deleted file mode 100644 index 9fa36a1280..0000000000 --- a/tests/source_files/step4/randomblock.css +++ /dev/null @@ -1,20 +0,0 @@ -/* Random block */ -.random-block { - border: 1px solid #83705a; - border-radius: 5px; - padding: 0 25px 25px 25px; - margin-top: 15px; -} - -.random-block h4 { - font-variant: small-caps; - font-size: 1.2em; -} - -.random-block h5 { - font-size: 1.2em; -} - -.random-block-text { - font-size: .85em; -} \ No newline at end of file diff --git a/tests/source_files/step5/form_field_theme.html.twig b/tests/source_files/step5/form_field_theme.html.twig deleted file mode 100644 index 598d28ee18..0000000000 --- a/tests/source_files/step5/form_field_theme.html.twig +++ /dev/null @@ -1,12 +0,0 @@ -{% block ezform_field %} - {% set formValue = field.value.getForm() %} - {% if formValue %} - {% set form = formValue.createView() %} - {% form_theme form 'bootstrap_4_layout.html.twig' %} - {% apply spaceless %} - {% if not ez_field_is_empty(content, field) %} - {{ form(form) }} - {% endif %} - {% endapply %} - {% endif %} -{% endblock %} \ No newline at end of file diff --git a/tests/source_files/step5/form_newsletter_view.html.twig b/tests/source_files/step5/form_newsletter_view.html.twig deleted file mode 100644 index c00c18d4f8..0000000000 --- a/tests/source_files/step5/form_newsletter_view.html.twig +++ /dev/null @@ -1,10 +0,0 @@ -
-
- {{ fos_httpcache_tag('relation-location-' ~ locationId) }} - {{ render(controller('ez_content:viewAction', { - 'locationId': locationId, - 'viewType': 'embed' - })) }} - -
-
diff --git a/tests/source_files/step5/form_style.css b/tests/source_files/step5/form_style.css deleted file mode 100644 index 5e08bb8ccb..0000000000 --- a/tests/source_files/step5/form_style.css +++ /dev/null @@ -1,50 +0,0 @@ -/* Newsletter Form block */ -.block-form { - border: 1px solid #8b7f7b; - border-radius: 5px; - padding: 0 25px 25px 25px; - margin-top: 15px; -} - -.block-form .ezstring-field { - display: inline-block; - font-variant: small-caps; - font-size: 1.2em; - width: 100%; - text-align: right; - padding-top: 20px; -} - -.block-form .col-form-label { - display: none; -} - -.block-form .form-group { - font-variant: small-caps; - font-size: 1em; - margin-top: 12px; -} - -.captcha_image { - padding-left: 10px; - padding-bottom: 10px; -} - -.captcha_reload { - font-variant: all-small-caps; - padding-left: 5px; -} - -.btn-primary { - background-color: rgb(103,85,80); - border-color: rgb(103,85,80); - margin-top: 15px; - margin-bottom: -20px; -} - -/* Newsletter Form block - Thank you message */ - -.block-form h3 { - font-variant: all-small-caps; - text-align: center; -} diff --git a/tests/src/ConfigurationEditor.php b/tests/src/ConfigurationEditor.php deleted file mode 100644 index da1221107a..0000000000 --- a/tests/src/ConfigurationEditor.php +++ /dev/null @@ -1,62 +0,0 @@ -configFilePath = $configFilePath; - } - - public function add($configEntries): void - { - $parsedConfig = Yaml::parse(file_get_contents($this->configFilePath)); - - foreach ($configEntries as $key => $value) { - $this->addSingle($parsedConfig, $key, $value); - } - - file_put_contents($this->configFilePath, Yaml::dump($parsedConfig, 5, 4)); - } - - private function addSingle(&$parsedConfig, $key, $value): void - { - $propertyAccessor = PropertyAccess::createPropertyAccessor(); - $parsedKey = $this->parseKey($key); - $currentValue = $propertyAccessor->getValue($parsedConfig, $parsedKey); - - if (is_array($currentValue)) { - if (is_array($value)) { - $value = array_merge($currentValue, $value); - } else { - $currentValue[] = $value; - $value = $currentValue; - } - } - - $propertyAccessor->setValue($parsedConfig, $parsedKey, $value); - } - - private function parseKey(string $key): string - { - $keys = explode('.', $key); - $parsed = ''; - foreach ($keys as $keyPart) { - $parsed .= sprintf('[%s]', $keyPart); - } - - return $parsed; - } -} diff --git a/tests/src/ContentDataCreator.php b/tests/src/ContentDataCreator.php deleted file mode 100644 index c0ac4cc7b6..0000000000 --- a/tests/src/ContentDataCreator.php +++ /dev/null @@ -1,105 +0,0 @@ - -
-%s -
'; - - public function __construct($basePath) - { - $this->basePath = $basePath; - } - - public function fillWithData(ContentCreateStruct $contentCreateStruct, string $contentTypeIdentifier, $contentItemData): void - { - switch ($contentTypeIdentifier) { - case 'folder': - $this->createFolder($contentCreateStruct, $contentItemData); - - return; - case 'article': - $this->createArticle($contentCreateStruct, $contentItemData); - - return; - case 'tip': - $this->createTip($contentCreateStruct, $contentItemData); - - return; - case 'dog_breed': - $this->createDogBreed($contentCreateStruct, $contentItemData); - - return; - default: - throw new \InvalidArgumentException(sprintf('Unrecognised content type: %s', $contentTypeIdentifier)); - } - } - - private function createDogBreed(ContentCreateStruct $contentCreateStruct, $data): void - { - $contentCreateStruct->setField('name', $data['contentName']); - $contentCreateStruct->setField('short_description', $data['contentName']); - - $filePath = sprintf('%s/%s/%s', $this->basePath, self::DOG_IMAGES_PATH, $data['imageName']); - $value = new Value( - [ - 'path' => $filePath, - 'fileSize' => filesize($filePath), - 'fileName' => basename($filePath), - 'alternativeText' => 'test', - ] - ); - $contentCreateStruct->setField('photo', $value); - $contentCreateStruct->setField('description', sprintf(self::RICHTEXT_XML, 'I am a dog. Woof woof.')); - } - - private function createTip(ContentCreateStruct $contentCreateStruct, $data): void - { - $contentCreateStruct->setField('title', $data['contentName']); - $contentCreateStruct->setField('body', $data['contentName']); - } - - private function createArticle(ContentCreateStruct $contentCreateStruct, $data): void - { - $contentCreateStruct->setField('title', $data['contentName']); - $contentCreateStruct->setField('short_title', $data['contentName']); - - $filePath = sprintf('%s/%s/%s', $this->basePath, self::ARTICLE_IMAGES_PATH, $data['imageName']); - $value = new Value( - [ - 'path' => $filePath, - 'fileSize' => filesize($filePath), - 'fileName' => basename($filePath), - 'alternativeText' => 'test', - ] - ); - $contentCreateStruct->setField('image', $value); - - $inputString = sprintf(self::RICHTEXT_XML, 'This is an article about a dog.'); - $contentCreateStruct->setField('body', $inputString); - $contentCreateStruct->setField('intro', $inputString); - } - - private function createFolder(ContentCreateStruct $contentCreateStruct, $data): void - { - $contentCreateStruct->setField('name', $data['contentName']); - $contentCreateStruct->setField('short_name', $data['contentName']); - } -} diff --git a/tests/src/Context/ConfigurationContext.php b/tests/src/Context/ConfigurationContext.php deleted file mode 100644 index 5f6e5143a1..0000000000 --- a/tests/src/Context/ConfigurationContext.php +++ /dev/null @@ -1,184 +0,0 @@ -basePath = $basePath; - } - - /** - * @Given I set the Landing Page template configuration in :filePath - */ - public function iSetTheLandingPageTemplateConfigurationIn($filePath): void - { - $config = new ConfigurationEditor(sprintf('%s/%s', $this->basePath, $filePath)); - $config->add([ - 'ezpublish.system.site_group.content_view.full.landing_page.template' => 'full/landing_page.html.twig', - 'ezpublish.system.site_group.content_view.full.landing_page.match.Identifier\ContentType' => 'landing_page', - ]); - } - - /** - * @Given I add imports to :configPath - */ - public function iAddImport($configPath, TableNode $imports): void - { - $config = new ConfigurationEditor(sprintf('%s/%s', $this->basePath, $configPath)); - - $entriesToAdd['imports'] = []; - foreach ($imports->getHash() as $import) { - $entriesToAdd['imports'][] = ['resource' => $import['name']]; - } - - $config->add($entriesToAdd); - } - - /** - * @Given I add Content List layout configuration to :filePath - */ - public function addContentListLayout($filePath): void - { - $config = new ConfigurationEditor(sprintf('%s/%s', $this->basePath, $filePath)); - $config->add([ - 'ezplatform_page_fieldtype.blocks.contentlist.views.contentList.template' => 'blocks/contentlist/default.html.twig', - 'ezplatform_page_fieldtype.blocks.contentlist.views.contentList.name' => 'Content List', - ]); - } - - /** - * @Given I set Content List image variations in :filePath - */ - public function setContentListImageVariation($filePath): void - { - $config = new ConfigurationEditor(sprintf('%s/%s', $this->basePath, $filePath)); - $config->add([ - 'ezpublish.system.default.image_variations.content_list.reference' => null, - 'ezpublish.system.default.image_variations.content_list.filters' => [['name' => 'geometry/scaleheightdownonly', 'params' => [81]], ['name' => 'geometry/crop', 'params' => [80, 80, 0, 0]]], - ]); - } - - /** - * @Given I add Content Scheduler layout configuration to :filePath - */ - public function addContentSchedulerLayout($filePath): void - { - $config = new ConfigurationEditor(sprintf('%s/%s', $this->basePath, $filePath)); - $config->add([ - 'ezplatform_page_fieldtype.blocks.schedule.views.featured.template' => 'blocks/schedule/featured.html.twig', - 'ezplatform_page_fieldtype.blocks.schedule.views.featured.name' => 'Featured Schedule Block', - ]); - } - - /** - * @Given I set template for Article in :filePath - */ - public function setTemplateForArticle($filePath): void - { - $config = new ConfigurationEditor(sprintf('%s/%s', $this->basePath, $filePath)); - $config->add([ - 'ezpublish.system.site_group.content_view.featured.article.template' => 'featured/article.html.twig', - 'ezpublish.system.site_group.content_view.featured.article.match.Identifier\ContentType' => 'article', - ]); - } - - /** - * @Given I set Content Scheduler image variations in :filePath - */ - public function setContentSchedulerVariations($filePath): void - { - $config = new ConfigurationEditor(sprintf('%s/%s', $this->basePath, $filePath)); - $config->add([ - 'ezpublish.system.default.image_variations.featured_article.reference' => null, - 'ezpublish.system.default.image_variations.featured_article.filters' => [['name' => 'geometry/scaleheightdownonly', 'params' => [200]]], - ]); - } - - /** - * @Given I add RandomBlockListener service configuration to :filePath - */ - public function addService($filePath): void - { - $config = new ConfigurationEditor(sprintf('%s/%s', $this->basePath, $filePath)); - $config->add([ - 'services.AppBundle\Event\RandomBlockListener.tags' => ['name' => 'kernel.event_subscriber'], - ]); - } - - /** - * @Given I create configuration of Random block to :filePath - */ - public function addRandomBlockConfig($filePath): void - { - $config = new ConfigurationEditor(sprintf('%s/%s', $this->basePath, $filePath)); - $config->add([ - 'ezplatform_page_fieldtype.blocks.random.name' => 'Random block', - 'ezplatform_page_fieldtype.blocks.random.thumbnail' => '/assets/images/blocks/random_block.svg#random', - 'ezplatform_page_fieldtype.blocks.random.views.random.template' => 'blocks/random/default.html.twig', - 'ezplatform_page_fieldtype.blocks.random.views.random.name' => 'Random Content Block View', - 'ezplatform_page_fieldtype.blocks.random.attributes.parent.type' => 'embed', - 'ezplatform_page_fieldtype.blocks.random.attributes.parent.name' => 'Parent', - 'ezplatform_page_fieldtype.blocks.random.attributes.parent.validators.not_blank.message' => 'You must provide value', - 'ezplatform_page_fieldtype.blocks.random.attributes.parent.validators.regexp.message' => 'Choose a content item', - 'ezplatform_page_fieldtype.blocks.random.attributes.parent.validators.regexp.options.pattern' => '/[0-9]+/', - ]); - } - - /** - * @Given I create configuration of Form block to :filePath - */ - public function addFormBlockConfig($filePath): void - { - $config = new ConfigurationEditor(sprintf('%s/%s', $this->basePath, $filePath)); - $config->add([ - 'ezplatform_page_fieldtype.blocks.form.views.newsletter.template' => 'blocks/form/newsletter.html.twig', - 'ezplatform_page_fieldtype.blocks.form.views.newsletter.name' => 'Newsletter Form View', - ]); - } - - /** - * @Given I create configuration of Form field to :filePath - */ - public function addFormFieldConfig($configPath): void - { - $config = new ConfigurationEditor(sprintf('%s/%s', $this->basePath, $configPath)); - $config->add([ - 'ezpublish.system.site.field_templates' => [['template' => 'fields/form_field.html.twig', 'priority' => 30]], - ]); - } - - /** - * @Given I create configuration of Captcha field to :filePath - */ - public function addCaptchaConfig($configPath): void - { - $config = new ConfigurationEditor(sprintf('%s/%s', $this->basePath, $configPath)); - $config->add([ - 'gregwar_captcha.width' => '150', - 'gregwar_captcha.invalid_message' => 'Please, enter again.', - 'gregwar_captcha.reload' => 'true', - 'gregwar_captcha.length' => '4', - ]); - } - - /** - * @Given I rebuild Webpack Encore assets - */ - public function rebuildYarn(): void - { - shell_exec('bin/console ezplatform:encore:compile'); - } -} diff --git a/tests/src/Context/ContentContext.php b/tests/src/Context/ContentContext.php deleted file mode 100644 index 071596f73d..0000000000 --- a/tests/src/Context/ContentContext.php +++ /dev/null @@ -1,84 +0,0 @@ -basePath = $basePath; - $this->repository = $repository; - $this->contentService = $this->repository->getContentService(); - $this->locationService = $this->repository->getLocationService(); - $this->pathStringLocationMap = ['Home' => 2]; - } - - public function createContent($contentTypeIdentifier, $parentPathString, $contentItemData): void - { - $permissionResolver = $this->repository->getPermissionResolver(); - $user = $this->repository->getUserService()->loadUser(self::ADMIN_USER_ID); - $permissionResolver->setCurrentUserReference($user); - - $locationCreateStruct = $this->locationService->newLocationCreateStruct($this->pathStringLocationMap[$parentPathString]); - $contentType = $this->repository->getContentTypeService()->loadContentTypeByIdentifier($contentTypeIdentifier); - $contentCreateStruct = $this->contentService->newContentCreateStruct($contentType, 'eng-GB'); - - $contentDataCreator = new ContentDataCreator($this->basePath); - $contentDataCreator->fillWithData($contentCreateStruct, $contentTypeIdentifier, $contentItemData); - - $draft = $this->contentService->createContent($contentCreateStruct, [$locationCreateStruct]); - $content = $this->contentService->publishVersion($draft->versionInfo); - - $newItemPathString = sprintf('%s/%s', $parentPathString, $contentItemData['contentName']); - $this->pathStringLocationMap[$newItemPathString] = $content->contentInfo->mainLocationId; - } - - /** - * @Given I delete eZ Platform Folder under Home - */ - public function deleteContentItem(): void - { - $permissionResolver = $this->repository->getPermissionResolver(); - $user = $this->repository->getUserService()->loadUser(self::ADMIN_USER_ID); - $permissionResolver->setCurrentUserReference($user); - - $contentInfo = $this->contentService->loadContentInfo(self::EZ_PLATFORM_FOLDER_CONTENT_ID); - $this->contentService->deleteContent($contentInfo); - } - - /** - * @Given I create :contentTypeIdentifier content items in :parentPathString - */ - public function createContentItems($contentTypeIdentifier, $parentPathString, TableNode $contentItemsData): void - { - foreach ($contentItemsData as $contentItemData) { - $this->createContent($contentTypeIdentifier, $parentPathString, $contentItemData); - } - } -} diff --git a/tests/src/Context/FileContext.php b/tests/src/Context/FileContext.php deleted file mode 100644 index 34e8525cfe..0000000000 --- a/tests/src/Context/FileContext.php +++ /dev/null @@ -1,76 +0,0 @@ -basePath = $basePath; - } - - /** - * @Given I create a file :path containing :sourceFile - */ - public function createFile($path, $sourceFile): void - { - $content = file_get_contents(sprintf('%s/%s/%s', $this->basePath, self::SOURCE_FILE_DIRECTORY, $sourceFile)); - $destinationPath = sprintf('%s/%s', $this->basePath, $path); - $this->createDirectoryStructure($destinationPath); - - file_put_contents($destinationPath, $content); - } - - /** - * @Given I add thumbnail image to :path - */ - public function addThumbnail($path): void - { - $sourcePath = sprintf('%s/%s', $this->basePath, 'tutorial_data_2/public/assets/images/layouts/sidebar.png'); - $destinationPath = sprintf('%s/%s/%s', $this->basePath, $path, 'sidebar.png'); - $this->createDirectoryStructure($destinationPath); - - copy($sourcePath, $destinationPath); - } - - /** - * @Given I copy the block icon to :path - */ - public function copyIcon($path): void - { - $sourcePath = sprintf('%s/%s', $this->basePath, 'tutorial_data_2/public/assets/images/blocks/random_block.svg'); - $destinationPath = sprintf('%s/%s/%s', $this->basePath, $path, 'random_block.svg'); - $this->createDirectoryStructure($destinationPath); - - copy($sourcePath, $destinationPath); - } - - /** - * @Given I append to :file file :sourcePath - */ - public function appendToFile($file, $sourceFile): void - { - $content = file_get_contents(sprintf('%s/%s/%s', $this->basePath, self::SOURCE_FILE_DIRECTORY, $sourceFile)); - file_put_contents($file, $content, FILE_APPEND | LOCK_EX); - } - - private function createDirectoryStructure($destinationPath): void - { - $directoryStructure = dirname($destinationPath); - if (!file_exists($directoryStructure)) { - mkdir($directoryStructure, 0777, true); - } - } -} diff --git a/tests/src/Context/TutorialContentTypeContext.php b/tests/src/Context/TutorialContentTypeContext.php deleted file mode 100644 index f4ca29f347..0000000000 --- a/tests/src/Context/TutorialContentTypeContext.php +++ /dev/null @@ -1,83 +0,0 @@ - 'ezstring', 'Image' => 'ezimage', 'RichText' => 'ezrichtext', 'Text block' => 'eztext']; - - /** @BeforeScenario */ - public function gatherContexts(BeforeScenarioScope $scope) - { - $environment = $scope->getEnvironment(); - $this->contentTypeContext = $environment->getContext('EzSystems\EzPlatformContentForms\Behat\Context\ContentTypeContext'); - } - - /** - * @Given I create a :contentTypeName content type with :contentTypeIdentifier identifier: - */ - public function iCreateAContentTypeWithIdentifier($contentTypeName, $contentTypeIdentifier, TableNode $fieldDetails): void - { - $contentTypeCreateStruct = $this->contentTypeContext->newContentTypeCreateStruct($contentTypeIdentifier); - $contentTypeCreateStruct->names = ['eng-GB' => $contentTypeName]; - $fieldDefinitions = $this->createFieldDefinitions($fieldDetails); - - foreach ($fieldDefinitions as $definition) { - $contentTypeCreateStruct->addFieldDefinition($definition); - } - - $this->contentTypeContext->createContentType($contentTypeCreateStruct); - } - - /** - * @Given I add field to :contentTypeIdentifier content type - */ - public function iAddFieldToArticleContentType($contentTypeIdentifier, TableNode $fieldDetails): void - { - $fieldDefinitions = $this->createFieldDefinitions($fieldDetails); - $this->contentTypeContext->addFieldsTo($contentTypeIdentifier, $fieldDefinitions); - } - - private function getFieldDefinitionData(array $tableRow, int $position): array - { - return [ - 'fieldTypeIdentifier' => $this->fieldTypeMap[$tableRow['Field type']], - 'identifier' => $tableRow['Identifier'], - 'names' => ['eng-GB' => $tableRow['Name']], - 'position' => $position, - 'isRequired' => $this->parseBool($tableRow['Required']), - 'isTranslatable' => $this->parseBool($tableRow['Translatable']), - 'isSearchable' => $this->parseBool($tableRow['Searchable']), - ]; - } - - private function createFieldDefinitions(TableNode $fieldDetails): array - { - $positionCounter = 1; - $fieldDefinitions = []; - - foreach ($fieldDetails->getHash() as $field) { - $fieldDefinitions[] = new FieldDefinitionCreateStruct($this->getFieldDefinitionData($field, $positionCounter++)); - } - - return $fieldDefinitions; - } - - private function parseBool(string $value): bool - { - return $value === 'yes'; - } -}