Skip to content

Commit

Permalink
Merge pull request #16 from elbformat/fix_non_existent_references
Browse files Browse the repository at this point in the history
[FIX] non-existent references to BrowserContext in symfony behat bund…
  • Loading branch information
rgericke-elb authored Nov 22, 2023
2 parents 10b5b17 + 6f0ff4f commit a486306
Show file tree
Hide file tree
Showing 15 changed files with 135 additions and 36 deletions.
18 changes: 10 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -19,10 +19,11 @@ jobs:
paths: 'vendor'
behat:
docker:
- image: 'hgiesenow/php:7.4'
- image: 'ghcr.io/elbformat/sulu-behat-bundle/php'
environment:
DATABASE_URL: 'mysql://test:[email protected]:3306/test'
DATABASE_URL: 'mysql://test:[email protected]:3306/test?serverVersion=mariadb-10.6.15'
ELASTICSEARCH_HOST: '127.0.0.1:9200'
MAILER_DSN: 'null://localhost'
- image: 'mariadb:10.6'
environment:
MYSQL_ROOT_PASSWORD: 'root'
Expand All @@ -46,10 +47,11 @@ 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:[email protected]:3306/test'
DATABASE_URL: 'mysql://test:[email protected]:3306/test?serverVersion=mariadb-10.6.15'
ELASTICSEARCH_HOST: '127.0.0.1:9200'
MAILER_DSN: 'null://localhost'
- image: 'mariadb:10.6'
environment:
MYSQL_ROOT_PASSWORD: 'root'
Expand All @@ -74,7 +76,7 @@ jobs:
# Unittests are incomplete by now
# phpunit:
# docker:
# - image: 'hgiesenow/php:7.4'
# - image: 'hgiesenow/php:8.1'
# steps:
# - checkout
# - attach_workspace:
Expand All @@ -86,7 +88,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:
Expand All @@ -95,7 +97,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:
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ default:
contexts:
- Elbformat\SymfonyBehatBundle\Context\CommandContext:
- Elbformat\SymfonyBehatBundle\Context\LoggingContext:
- Elbformat\SuluBehatBundle\Context\BrowserContext:
- Elbformat\SymfonyBehatBundle\Context\HtmlContext:
- Elbformat\SymfonyBehatBundle\Context\HttpContext:
- Elbformat\SymfonyBehatBundle\Context\FormContext:
- Elbformat\SuluBehatBundle\Context\DateContext:
- Elbformat\SuluBehatBundle\Context\SuluPageContext:
- Elbformat\SuluBehatBundle\Context\SuluSnippetContext:
Expand Down Expand Up @@ -38,8 +40,10 @@ admin:
filters:
tags: '@admin'
contexts:
- Elbformat\SuluBehatBundle\Context\BrowserContext:
- Elbformat\SymfonyBehatBundle\Context\HttpContext:
- Elbformat\SuluBehatBundle\Context\SuluAdminContext:
- Elbformat\SymfonyBehatBundle\Context\CommandContext:
- Elbformat\SymfonyBehatBundle\Context\JsonContext:
extensions:
FriendsOfBehat\SymfonyExtension:
kernel:
Expand Down
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand Down
1 change: 0 additions & 1 deletion config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
9 changes: 3 additions & 6 deletions config/packages/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ parameters:
framework:
session:
handler_id: null
mailer:
dsn: '%env(MAILER_DSN)%'

doctrine:
dbal:
Expand Down Expand Up @@ -38,7 +40,7 @@ sulu_document_manager:
workspace: "workspace_live"

security:
encoders:
password_hashers:
Sulu\Bundle\SecurityBundle\Entity\User: bcrypt
providers:
sulu:
Expand All @@ -56,7 +58,6 @@ security:
firewalls:
admin:
pattern: ^/admin(\/|$)
anonymous: true
lazy: true
provider: sulu
entry_point: sulu_security.authentication_entry_point
Expand All @@ -66,7 +67,6 @@ security:
failure_handler: sulu_security.authentication_handler
logout:
path: sulu_admin.logout
success_handler: sulu_security.logout_success_handler
sulu_security:
checker:
enabled: true
Expand All @@ -85,6 +85,3 @@ monolog:
path: "php://stderr"
level: warning
channels: ["!event","!console"]

swiftmailer:
disable_delivery: true
2 changes: 1 addition & 1 deletion doc/development.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ 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'
MAILER_DSN: 'null://localhost'

depends_on:
- mysql
Expand Down
37 changes: 37 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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/*

# 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
3 changes: 3 additions & 0 deletions docker/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
memory_limit = -1
error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
display_errors = Off
6 changes: 0 additions & 6 deletions features/logging.feature

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,26 @@

namespace Elbformat\SuluBehatBundle\Context;

use Elbformat\SymfonyBehatBundle\Context\BrowserContext as SymfonyBrowserContext;
use Behat\Behat\Context\Context;
use Elbformat\SymfonyBehatBundle\Browser\State;
use Elbformat\SymfonyBehatBundle\Context\RequestTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\KernelInterface;

/**
* @author Hannes Giesenow <[email protected]>
*/
class BrowserContext extends SymfonyBrowserContext
class SuluAdminContext implements Context
{
use RequestTrait;

public function __construct(
protected State $state,
protected KernelInterface $kernel,
) {

}

/**
* @Given I am logged in as admin
*/
Expand Down
5 changes: 3 additions & 2 deletions src/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ services:
- '../../Context/SuluCommunityContext.php'
- '../../Context/SuluFormContext.php'

Elbformat\SuluBehatBundle\Context\BrowserContext:
parent: Elbformat\SymfonyBehatBundle\Context\BrowserContext
Elbformat\SuluBehatBundle\Context\SuluAdminContext:
arguments:
$state: '@Elbformat\SymfonyBehatBundle\Browser\State'

Elbformat\SuluBehatBundle\Context\SuluMediaContext:
arguments:
Expand Down
2 changes: 1 addition & 1 deletion tests/BundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit a486306

Please sign in to comment.