From bc9a1d182c7307720cec194819ae2acd539b4184 Mon Sep 17 00:00:00 2001 From: Ronny Gericke Date: Fri, 17 Nov 2023 10:04:20 +0100 Subject: [PATCH] [FIX] non-existent references to BrowserContext in symfony behat bundle @1.5 --- .circleci/config.yml | 16 +++++------ .github/workflows/docker-image.yml | 46 ++++++++++++++++++++++++++++++ README.md | 4 +-- behat.yml | 2 ++ composer.json | 9 ++++-- config/bundles.php | 1 - config/packages/config.yaml | 8 +----- doc/development.md | 2 +- docker-compose.yml | 4 +-- docker/Dockerfile | 43 ++++++++++++++++++++++++++++ docker/php.ini | 3 ++ features/logging.feature | 6 ---- src/Context/BrowserContext.php | 4 +-- src/Resources/config/services.yml | 2 +- tests/BundleTest.php | 2 +- 15 files changed, 118 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/docker-image.yml create mode 100644 docker/Dockerfile create mode 100644 docker/php.ini delete mode 100644 features/logging.feature diff --git a/.circleci/config.yml b/.circleci/config.yml index e5baec3..cb655ec 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,7 +10,7 @@ orbs: jobs: build: docker: - - image: 'hgiesenow/php:7.4' + - image: 'ghcr.io/elbformat/sulu-behat-bundle/php' steps: - checkout - run: 'composer install --dev' @@ -19,9 +19,9 @@ jobs: paths: 'vendor' behat: docker: - - image: 'hgiesenow/php:7.4' + - image: 'ghcr.io/elbformat/sulu-behat-bundle/php' environment: - DATABASE_URL: 'mysql://test:test@127.0.0.1:3306/test' + DATABASE_URL: 'mysql://test:test@127.0.0.1:3306/test?serverVersion=mariadb-10.6.15' ELASTICSEARCH_HOST: '127.0.0.1:9200' - image: 'mariadb:10.6' environment: @@ -46,9 +46,9 @@ jobs: file: 'build/coverage.xml' behat-admin: docker: - - image: 'hgiesenow/php:7.4' + - image: 'ghcr.io/elbformat/sulu-behat-bundle/php' environment: - DATABASE_URL: 'mysql://test:test@127.0.0.1:3306/test' + DATABASE_URL: 'mysql://test:test@127.0.0.1:3306/test?serverVersion=mariadb-10.6.15' ELASTICSEARCH_HOST: '127.0.0.1:9200' - image: 'mariadb:10.6' environment: @@ -74,7 +74,7 @@ jobs: # Unittests are incomplete by now # phpunit: # docker: -# - image: 'hgiesenow/php:7.4' +# - image: 'hgiesenow/php:8.1' # steps: # - checkout # - attach_workspace: @@ -86,7 +86,7 @@ jobs: # file: 'build/clover.xml' php-cs-fixer: docker: - - image: 'hgiesenow/php:7.4' + - image: 'ghcr.io/elbformat/sulu-behat-bundle/php' steps: - checkout - attach_workspace: @@ -95,7 +95,7 @@ jobs: - run: 'vendor/bin/php-cs-fixer fix --diff --dry-run tests' psalm: docker: - - image: 'hgiesenow/php:7.4' + - image: 'ghcr.io/elbformat/sulu-behat-bundle/php' steps: - checkout - attach_workspace: diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..1caf46e --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,46 @@ +name: Create and publish a Docker image + +on: + schedule: + - cron: '0 9 1 * *' + push: + branches: + - fix_non_existent_references + - main + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }}/php + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: docker + push: true + #tags: ${{ steps.meta.outputs.tags }} + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/README.md b/README.md index 1bdfa01..bf59ebe 100644 --- a/README.md +++ b/README.md @@ -70,8 +70,8 @@ bin/console -e test sulu:build prod You can then run the tests in default oder admin profile. ```shell -venbdor/bin/behat -venbdor/bin/behat --profile admin +vendor/bin/behat +vendor/bin/behat --profile admin ``` ## Examples diff --git a/behat.yml b/behat.yml index 8d1f976..9d4b6bf 100644 --- a/behat.yml +++ b/behat.yml @@ -6,6 +6,8 @@ default: contexts: - Elbformat\SymfonyBehatBundle\Context\CommandContext: - Elbformat\SymfonyBehatBundle\Context\LoggingContext: + - Elbformat\SymfonyBehatBundle\Context\HtmlContext: + - Elbformat\SymfonyBehatBundle\Context\FormContext: - Elbformat\SuluBehatBundle\Context\BrowserContext: - Elbformat\SuluBehatBundle\Context\DateContext: - Elbformat\SuluBehatBundle\Context\SuluPageContext: diff --git a/composer.json b/composer.json index 0724aa1..2ccf959 100644 --- a/composer.json +++ b/composer.json @@ -20,13 +20,14 @@ } }, "require": { - "php": ">=7.4", + "php": ">=8.1", "ext-dom": "*", "ext-json": "*", "behat/behat": "^3.8", + "elbformat/symfony-behat-bundle": "^1.5", "friends-of-behat/symfony-extension": "^2.2", "sulu/sulu": "^2.4", - "elbformat/symfony-behat-bundle": "^1.0" + "symfony/event-dispatcher": "5.4.*" }, "require-dev": { "dvdoug/behat-code-coverage": "^5.2", @@ -37,8 +38,10 @@ "phpunit/phpunit": "^9.5", "sulu/article-bundle": "^2.3", "sulu/sulu-form-bundle": "^2.4", + "symfony/mailer": "5.4.*", + "symfony/monolog-bridge": "5.4.*", "symfony/monolog-bundle": "^3.8", - "symfony/runtime": "^5.4", + "symfony/runtime": "5.4.*", "vimeo/psalm": "^4.13" }, "config": { diff --git a/config/bundles.php b/config/bundles.php index 7211690..acb3a32 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -4,7 +4,6 @@ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], - Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true], Sulu\Bundle\CoreBundle\SuluCoreBundle::class => ['all' => true], Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true], diff --git a/config/packages/config.yaml b/config/packages/config.yaml index 2838de4..4a33864 100644 --- a/config/packages/config.yaml +++ b/config/packages/config.yaml @@ -38,7 +38,7 @@ sulu_document_manager: workspace: "workspace_live" security: - encoders: + password_hashers: Sulu\Bundle\SecurityBundle\Entity\User: bcrypt providers: sulu: @@ -56,17 +56,14 @@ security: firewalls: admin: pattern: ^/admin(\/|$) - anonymous: true lazy: true provider: sulu entry_point: sulu_security.authentication_entry_point json_login: check_path: sulu_admin.login_check - success_handler: sulu_security.authentication_handler failure_handler: sulu_security.authentication_handler logout: path: sulu_admin.logout - success_handler: sulu_security.logout_success_handler sulu_security: checker: enabled: true @@ -85,6 +82,3 @@ monolog: path: "php://stderr" level: warning channels: ["!event","!console"] - -swiftmailer: - disable_delivery: true diff --git a/doc/development.md b/doc/development.md index 254f2e4..fe7b242 100644 --- a/doc/development.md +++ b/doc/development.md @@ -1,7 +1,7 @@ For local development you can use docker-compose. ```bash docker-compose up -d -docker-compose exec php bash +docker-compose run php sh composer install bin/console sulu:build dev -n bin/console sulu:document:init diff --git a/docker-compose.yml b/docker-compose.yml index ab461e0..8eabf55 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,9 +17,9 @@ services: ES_JAVA_OPTS: "-Xms1g -Xmx1g" php: - image: hgiesenow/php:7.4 + image: ghcr.io/elbformat/sulu-behat-bundle/php environment: - DATABASE_URL: 'mysql://test:test@mysql:3306/test' + DATABASE_URL: 'mysql://test:test@mysql:3306/test?serverVersion=mariadb-10.6.15' ELASTICSEARCH_HOST: 'elasticsearch:9200' depends_on: diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..4960393 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,43 @@ +FROM hgiesenow/php:8.1 +LABEL org.opencontainers.image.source="https://github.com/elbformat/sulu-behat-bundle" + +# For debugging +RUN apk add --no-cache --virtual .build-deps autoconf g++ make linux-headers &&\ +pecl install xdebug-3.2.0 && \ +apk del .build-deps && \ +rm -rf /tmp/* + +# ext-intl +RUN apk add --no-cache icu icu-data-full && \ + apk add --no-cache --virtual .build-deps icu-dev && \ + docker-php-ext-install intl && \ + apk del .build-deps && \ + rm -rf /tmp/* + +# ext-gd +RUN apk add --no-cache libpng libjpeg-turbo freetype && \ + apk add --no-cache --virtual .build-deps libpng-dev libjpeg-turbo-dev freetype-dev && \ + docker-php-ext-configure gd && \ + docker-php-ext-install gd && \ + apk del .build-deps && \ + rm -rf /tmp/* + +# xdebug +RUN apk add --no-cache --virtual .build-deps autoconf g++ make linux-headers && \ +pecl install xdebug-3.2.1 && \ +docker-php-ext-enable xdebug && \ +apk del .build-deps && \ +rm -rf /tmp/* + +# Database connection (for integration tests) +RUN docker-php-ext-install pdo pdo_mysql + +# For codecov upload inside circleci +RUN apk add gpg gpg-agent gpgv + +COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer +ENV COMPOSER_MEMORY_LIMIT=-1 + +COPY php.ini /usr/local/etc/php/conf.d/ + +WORKDIR /var/www \ No newline at end of file diff --git a/docker/php.ini b/docker/php.ini new file mode 100644 index 0000000..a790432 --- /dev/null +++ b/docker/php.ini @@ -0,0 +1,3 @@ +memory_limit = -1 +error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR +display_errors = Off \ No newline at end of file diff --git a/features/logging.feature b/features/logging.feature deleted file mode 100644 index c363d3f..0000000 --- a/features/logging.feature +++ /dev/null @@ -1,6 +0,0 @@ -Feature: Test if logging works as expected - Scenario: Warnings are logged - When I go to "/" - Then the page shows up - And the main logfile contains an info entry "Matched route" - And the main logfile doesn't contain any warning entries \ No newline at end of file diff --git a/src/Context/BrowserContext.php b/src/Context/BrowserContext.php index e6b8ed8..bdaa589 100644 --- a/src/Context/BrowserContext.php +++ b/src/Context/BrowserContext.php @@ -4,13 +4,13 @@ namespace Elbformat\SuluBehatBundle\Context; -use Elbformat\SymfonyBehatBundle\Context\BrowserContext as SymfonyBrowserContext; +use Elbformat\SymfonyBehatBundle\Context\HttpContext; use Symfony\Component\HttpFoundation\Request; /** * @author Hannes Giesenow */ -class BrowserContext extends SymfonyBrowserContext +class BrowserContext extends HttpContext { /** * @Given I am logged in as admin diff --git a/src/Resources/config/services.yml b/src/Resources/config/services.yml index e43718c..352b6f1 100644 --- a/src/Resources/config/services.yml +++ b/src/Resources/config/services.yml @@ -12,7 +12,7 @@ services: - '../../Context/SuluFormContext.php' Elbformat\SuluBehatBundle\Context\BrowserContext: - parent: Elbformat\SymfonyBehatBundle\Context\BrowserContext + parent: Elbformat\SymfonyBehatBundle\Context\HttpContext Elbformat\SuluBehatBundle\Context\SuluMediaContext: arguments: diff --git a/tests/BundleTest.php b/tests/BundleTest.php index 4ef0543..265dd87 100644 --- a/tests/BundleTest.php +++ b/tests/BundleTest.php @@ -18,7 +18,7 @@ public function testBuild(): void { $bundle = new ElbformatSuluBehatBundle(); $container = $this->createMock(ContainerBuilder::class); -// $container->expects($this->once())->method('addCompilerPass')->with($this->isInstanceOf(DynamicServicesPass::class))->willReturn(null); + // $container->expects($this->once())->method('addCompilerPass')->with($this->isInstanceOf(DynamicServicesPass::class))->willReturn(null); $bundle->build($container); } }