diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1c4923f..052f5aa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -164,10 +164,6 @@ jobs: name: Run PHPStan run: vendor/bin/phpstan analyse -c phpstan.neon -l max src/ -# - -# name: Run Psalm -# run: vendor/bin/psalm - - name: Run PHPSpec run: vendor/bin/phpspec run --ansi -f progress --no-interaction diff --git a/.github/workflows/coding_standards.yml b/.github/workflows/coding_standards.yml new file mode 100644 index 0000000..8998241 --- /dev/null +++ b/.github/workflows/coding_standards.yml @@ -0,0 +1,91 @@ +name: Coding standard + +on: + push: + branches-ignore: + - 'dependabot/**' + pull_request: ~ + release: + types: [created] + schedule: + - + cron: "0 1 * * 6" # Run at 1am every Saturday + workflow_dispatch: ~ + +jobs: + tests: + runs-on: ubuntu-latest + + name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}" + + strategy: + fail-fast: false + matrix: + php: ["8.0", "8.1"] + symfony: ["5.4.*", "^6.0"] + sylius: ["^1.12.13"] + node: ["14.x"] + mysql: ["8.0"] + + env: + APP_ENV: test + DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" + + steps: + - + uses: actions/checkout@v2 + - + name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php }}" + extensions: intl + tools: symfony + coverage: none + - + name: Get Composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - + name: Cache Composer + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php-${{ matrix.php }}-composer- + - + name: Restrict Symfony version + if: matrix.symfony != '' + run: | + composer global config --no-plugins allow-plugins.symfony/flex true + composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10" + composer config extra.symfony.require "${{ matrix.symfony }}" + - + name: Restrict Sylius version + if: matrix.sylius != '' + run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction + + - + name: Install PHP dependencies + run: composer install --no-interaction + + - + name: Run PHPStan + run: vendor/bin/phpstan analyse -c phpstan.neon -l 9 src/ + + - name: Run ECS + run: vendor/bin/ecs + + - name: Failed build Slack notification + uses: rtCamp/action-slack-notify@v2 + if: ${{ failure() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') }} + env: + SLACK_CHANNEL: ${{ secrets.FAILED_BUILD_SLACK_CHANNEL }} + SLACK_COLOR: ${{ job.status }} + SLACK_ICON: https://github.com/rtCamp.png?size=48 + SLACK_MESSAGE: ':x:' + SLACK_TITLE: Failed build on ${{ github.event.repository.name }} repository + SLACK_USERNAME: ${{ secrets.FAILED_BUILD_SLACK_USERNAME }} + SLACK_WEBHOOK: ${{ secrets.FAILED_BUILD_SLACK_WEBHOOK }} diff --git a/config/routing/shop_routing.yml b/config/routing/shop_routing.yml index f130559..2185f95 100644 --- a/config/routing/shop_routing.yml +++ b/config/routing/shop_routing.yml @@ -5,6 +5,7 @@ bitbag_render_sulu_page: _controller: bitbag.sylius_sulu_plugin.controller.action.render_page_action _sylius: permission: false + bitbag_render_sulu_sub_page: path: /{locale}/page/{slug}/{second_slug} methods: [GET] diff --git a/config/services/strategy.xml b/config/services/strategy.xml index b606638..7313192 100644 --- a/config/services/strategy.xml +++ b/config/services/strategy.xml @@ -6,7 +6,6 @@ http://symfony.com/schema/dic/services/services-1.0.xsd" > - diff --git a/ecs.php b/ecs.php index 3cf43de..fb0426f 100644 --- a/ecs.php +++ b/ecs.php @@ -18,4 +18,3 @@ VisibilityRequiredFixer::class => ['*Spec.php'], ]); }; - diff --git a/features/caching_sulu_request.feature b/features/caching_sulu_request.feature index 4cc118d..2171b53 100644 --- a/features/caching_sulu_request.feature +++ b/features/caching_sulu_request.feature @@ -9,7 +9,6 @@ Feature: Caching sulu page request And Sulu has defined page "blog_page_with_blocks_and_links" in locale "en_US" And Cache for sulu not exists - @ui Scenario: See the featured pages on homepage When I visit this channel's homepage diff --git a/spec/ApiClient/SuluApiClientSpec.php b/spec/ApiClient/SuluApiClientSpec.php deleted file mode 100644 index 96d6f07..0000000 --- a/spec/ApiClient/SuluApiClientSpec.php +++ /dev/null @@ -1,68 +0,0 @@ -beConstructedWith($client, $shopperContext, $suluBaseUri, $cacheDir); - } - - public function it_is_initializable(): void - { - $this->shouldHaveType(SuluApiClient::class); - } - - public function it_implements_sulu_api_client_interface_interface(): void - { - $this->shouldHaveType(SuluApiClientInterface::class); - } - -// function it_fetches_cms_content( -// HttpClientInterface $client, -// ShopperContextInterface $shopperContext, -// ChannelInterface $channel, -// ) { -// $url = '/cms/content'; -// $locale = 'en_US'; -// -// $shopperContext->getChannel()->willReturn($channel); -// $shopperContext->getLocaleCode()->willReturn($locale); -// $channel->isSuluUseLocalizedUrls()->willReturn(true); -// -// $client->request('GET', 'http://example.com/en_US/cms/content.json', ['headers' => ['Accept' => 'application/json']])->shouldBeCalled(); -// -// $this->fetchCmsContent($url); -// } -// -// function it_fetches_cms_content_with_global_channel( -// HttpClientInterface $client, -// ShopperContextInterface $shopperContext, -// ChannelInterface $channel, -// ) { -// $url = '/cms/content'; -// -// $shopperContext->getChannel()->willReturn($channel); -// $shopperContext->getLocaleCode()->willReturn(null); -// $channel->isSuluUseLocalizedUrls()->willReturn(false); -// -// -// $client->request('GET', 'http://example.com/cms/content.json', ['headers' => ['Accept' => 'application/json']])->shouldBeCalled(); -// -// $this->fetchCmsContent($url); -// } -} diff --git a/src/ApiClient/SuluApiClient.php b/src/ApiClient/SuluApiClient.php index e345cdf..1412522 100644 --- a/src/ApiClient/SuluApiClient.php +++ b/src/ApiClient/SuluApiClient.php @@ -1,5 +1,11 @@ $block['type'] === $type); - return count($blocks) !== 0; + return 0 !== count($blocks); } } diff --git a/src/Twig/Runtime/SuluRuntimeInterface.php b/src/Twig/Runtime/SuluRuntimeInterface.php index f1c7753..f9a4dd7 100644 --- a/src/Twig/Runtime/SuluRuntimeInterface.php +++ b/src/Twig/Runtime/SuluRuntimeInterface.php @@ -1,5 +1,11 @@ {{ quote }} diff --git a/tests/Application/templates/bundles/BitBagSyliusSuluPlugin/shop/block/text.html.twig b/tests/Application/templates/bundles/BitBagSyliusSuluPlugin/shop/block/text.html.twig index 6e7fc52..43b1eb6 100644 --- a/tests/Application/templates/bundles/BitBagSyliusSuluPlugin/shop/block/text.html.twig +++ b/tests/Application/templates/bundles/BitBagSyliusSuluPlugin/shop/block/text.html.twig @@ -1 +1 @@ -{{ description }} +
{{ description }}
diff --git a/tests/Application/templates/bundles/BitBagSyliusSuluPlugin/shop/page/blog.html.twig b/tests/Application/templates/bundles/BitBagSyliusSuluPlugin/shop/page/blog.html.twig index e6bf512..d8b0626 100644 --- a/tests/Application/templates/bundles/BitBagSyliusSuluPlugin/shop/page/blog.html.twig +++ b/tests/Application/templates/bundles/BitBagSyliusSuluPlugin/shop/page/blog.html.twig @@ -17,7 +17,7 @@ {% if bitbag_page_has_sulu_block(page, 'text') %} -
{{ bitbag_render_sulu_block_with_type(page.blocks, 'text') }}
+
{{ bitbag_render_sulu_block_with_type(page.blocks, 'text')|raw }}
{% elseif page.content is defined and page.content is not null %}
{{ page.content }}
{% endif %} @@ -25,7 +25,7 @@ {% if bitbag_page_has_sulu_block(page, 'quote') %} -
{{ bitbag_render_sulu_block_with_type(page.blocks, 'quote') }}
+
{{ bitbag_render_sulu_block_with_type(page.blocks, 'quote')|raw }}
{% endif %} {% if page.tags is defined and page.tags|length > 0 %} diff --git a/tests/Behat/Context/Ui/SuluAdminPanelContext.php b/tests/Behat/Context/Ui/SuluAdminPanelContext.php index 9f9fa2c..6d0213f 100644 --- a/tests/Behat/Context/Ui/SuluAdminPanelContext.php +++ b/tests/Behat/Context/Ui/SuluAdminPanelContext.php @@ -1,5 +1,7 @@ click(); } - } diff --git a/tests/Behat/Services/SuluApiClient.php b/tests/Behat/Services/SuluApiClient.php index bde2e33..cff2941 100644 --- a/tests/Behat/Services/SuluApiClient.php +++ b/tests/Behat/Services/SuluApiClient.php @@ -87,9 +87,9 @@ private function makeApiCall(string $url): ResponseInterface private function mockResponses(): array { - $featured = file_get_contents(__DIR__.'/../ApiResponseMock/featured_pages.json'); - $pageWithProperties = file_get_contents(__DIR__.'/../ApiResponseMock/blog_page_with_properties.json'); - $pageWithBlocks = file_get_contents(__DIR__.'/../ApiResponseMock/blog_page_with_blocks_and_links.json'); + $featured = file_get_contents(__DIR__ . '/../ApiResponseMock/featured_pages.json'); + $pageWithProperties = file_get_contents(__DIR__ . '/../ApiResponseMock/blog_page_with_properties.json'); + $pageWithBlocks = file_get_contents(__DIR__ . '/../ApiResponseMock/blog_page_with_blocks_and_links.json'); return [ 'featured_pages' => new MockResponse($featured, ['http_code' => 200]),