From 54c4397305399e758b453408a90f3c6081423266 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 +-- composer.json | 7 +++-- config/bundles.php | 1 - config/packages/config.yaml | 8 ------ doc/development.md | 2 +- docker-compose.yml | 4 +-- docker/Dockerfile | 17 +++++++++++ src/Context/BrowserContext.php | 4 +-- tests/BundleTest.php | 2 +- 11 files changed, 83 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/docker-image.yml create mode 100644 docker/Dockerfile 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/composer.json b/composer.json index 0724aa1..af557c5 100644 --- a/composer.json +++ b/composer.json @@ -20,13 +20,13 @@ } }, "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" + "sulu/sulu": "^2.4" }, "require-dev": { "dvdoug/behat-code-coverage": "^5.2", @@ -37,6 +37,7 @@ "phpunit/phpunit": "^9.5", "sulu/article-bundle": "^2.3", "sulu/sulu-form-bundle": "^2.4", + "symfony/mailer": "^5.4|^6.2", "symfony/monolog-bundle": "^3.8", "symfony/runtime": "^5.4", "vimeo/psalm": "^4.13" 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..7735635 100644 --- a/config/packages/config.yaml +++ b/config/packages/config.yaml @@ -38,8 +38,6 @@ sulu_document_manager: workspace: "workspace_live" security: - encoders: - Sulu\Bundle\SecurityBundle\Entity\User: bcrypt providers: sulu: id: sulu_security.user_provider @@ -56,17 +54,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 +80,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..9e26f87 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,17 @@ +FROM hgiesenow/php:8.1 +LABEL org.opencontainers.image.source="https://github.com/elbformat/sulu-behat-bundle" + +# 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/* \ 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/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); } }