Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
/phpunit-9.xml.dist export-ignore
/phpunit-paratest.xml.dist export-ignore
/psalm.xml export-ignore
/src/Test/Behat export-ignore
/stubs export-ignore
/symfony.lock export-ignore
/tests export-ignore
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/bc-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ jobs:
with:
fetch-depth: 0

- name: Install dependencies
uses: ramsey/composer-install@v2
with:
composer-options: --prefer-dist

- name: Install PHP with extensions.
uses: shivammathur/setup-php@v2
with:
php-version: "8.5"

- name: Install dependencies
uses: ramsey/composer-install@v2
with:
composer-options: --prefer-dist

- name: Install roave/backward-compatibility-check.
run: composer bin bc-check require roave/backward-compatibility-check

Expand Down
142 changes: 142 additions & 0 deletions .github/workflows/behat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Behat

on:
push:
paths: &paths
- .github/workflows/behat.yml
- src/Test/Behat/**
pull_request:
paths: *paths
schedule:
- cron: '0 0 1,16 * *'

defaults:
run:
shell: bash
working-directory: ./src/Test/Behat

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
behat:
name: Behat - P:${{ matrix.php }}, S:${{ matrix.symfony }}${{ matrix.deps == 'lowest' && ' (lowest)' || '' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ 8.3, 8.5 ]
symfony: [ 6.4.*, 7.4.* ]
deps: [ highest, lowest ]
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: flex

- name: Add the polyfill compatible with Doctrine ^2.16
if: ${{ matrix.deps == 'lowest' }}
run: composer require --dev symfony/polyfill-php80:^1.16 --no-update

- name: Install dependencies
uses: ramsey/composer-install@v2
with:
working-directory: "src/Test/Behat"
dependency-versions: ${{ matrix.deps }}
composer-options: --prefer-dist
env:
SYMFONY_REQUIRE: ${{ matrix.symfony }}

- name: "Main test suite: reset DB at scenario level, with Dama support"
run: vendor/bin/behat --colors -vvv

- name: "Main test suite: reset DB at scenario level, without Dama support"
run: vendor/bin/behat --colors -vvv --profile=main-no-dama

- name: "Main test suite: reset DB at scenario level, with native Dama extension"
run: vendor/bin/behat --colors -vvv --profile=main-native-dama --tags='~@skip-with-native-dama'

- name: Manual reset DB
run: vendor/bin/behat --colors -vvv --profile=reset-manual

- name: Manual reset DB and Dama support
run: vendor/bin/behat --colors -vvv --profile=reset-manual-dama

- name: Reset DB at feature level
run: vendor/bin/behat --colors -vvv --profile=reset-feature

- name: Reset DB at feature level with Dama support
run: vendor/bin/behat --colors -vvv --profile=reset-feature-dama

- name: Reset DB disabled
run: vendor/bin/behat --colors -vvv --profile=reset-disabled

phpunit:
name: PHPUnit - P:${{ matrix.php }}, S:${{ matrix.symfony }}${{ matrix.deps == 'lowest' && ' (lowest)' || '' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ 8.3, 8.5 ]
symfony: [ 6.4.*, 7.4.* ]
deps: [ highest, lowest ]
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: flex

- name: Add the polyfill compatible with Doctrine ^2.16
if: ${{ matrix.deps == 'lowest' }}
run: composer require --dev symfony/polyfill-php80:^1.16 --no-update

- name: Install dependencies
uses: ramsey/composer-install@v2
with:
working-directory: "src/Test/Behat"
dependency-versions: ${{ matrix.deps }}
composer-options: --prefer-dist
env:
SYMFONY_REQUIRE: ${{ matrix.symfony }}

- name: Run tests
run: vendor/bin/phpunit

phpstan:
name: PhpStan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.5
coverage: none
tools: flex

- name: Install dependencies
uses: ramsey/composer-install@v2
with:
working-directory: "src/Test/Behat"
composer-options: --prefer-dist
env:
SYMFONY_REQUIRE: 7.4.*

- name: Install PHPStan
run: composer bin phpstan install

- name: Run PHPStan
run: ../../../bin/tools/phpstan/vendor/phpstan/phpstan/phpstan
9 changes: 1 addition & 8 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ use Zenstruck\Foundry\Tests\Fixture\TestKernel;

require_once __DIR__ . '/../tests/bootstrap.php';

foreach ($argv ?? [] as $i => $arg) {
if (($arg === '--env' || $arg === '-e') && isset($argv[$i + 1])) {
$_ENV['APP_ENV'] = $argv[$i + 1];
break;
}
}

$application = new Application(new TestKernel($_ENV['APP_ENV'], true));
$application = new Application(new TestKernel('test', true));

$application->run();
6 changes: 2 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
"src/functions.php",
"src/Persistence/functions.php",
"src/symfony_console.php"
]
],
"exclude-from-classmap": ["src/Test/Behat/"]
},
"autoload-dev": {
"psr-4": {
Expand Down Expand Up @@ -101,9 +102,6 @@
"allow-contrib": false
}
},
"scripts": {
"post-install-cmd": ["@composer bin phpstan install", "@composer bin phpbench install"]
},
"minimum-stability": "dev",
"prefer-stable": true
}
11 changes: 10 additions & 1 deletion config/persistence.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Zenstruck\Foundry\Persistence\PersistedObjectsTracker;
use Zenstruck\Foundry\Persistence\PersistenceManager;
use Zenstruck\Foundry\Persistence\ResetDatabase\ResetDatabaseManager;
use Zenstruck\Foundry\Story\FixtureStoryResolver;

return static function(ContainerConfigurator $container): void {
$container->services()
Expand All @@ -34,12 +35,20 @@
])

->set('.zenstruck_foundry.command.load_fixtures', LoadFixturesCommand::class)
->arg('$fixtureStoryResolver', service('.zenstruck_foundry.story.fixture_resolver'))
->arg('$databaseResetters', tagged_iterator('.foundry.persistence.database_resetter'))
->arg('$kernel', service('kernel'))
->tag('console.command', [
'command' => 'foundry:load-fixtures|foundry:load-stories|foundry:load-story',
'description' => 'Load stories which are marked with #[AsFixture] attribute.',
])

->set('.zenstruck_foundry.story.fixture_resolver', FixtureStoryResolver::class)
->args([
abstract_arg('fixtureStories'),
abstract_arg('groupedStories'),
])
->public()
;

if (\PHP_VERSION_ID >= 80400) {
Expand All @@ -48,7 +57,7 @@
->tag('kernel.event_listener', ['event' => TerminateEvent::class, 'method' => 'refresh'])
->tag('kernel.event_listener', ['event' => ConsoleTerminateEvent::class, 'method' => 'refresh'])
->tag('kernel.event_listener', ['event' => WorkerMessageHandledEvent::class, 'method' => 'refresh']) // @phpstan-ignore class.notFound
->tag('foundry.hook', ['class' => null, 'method' => 'afterPersistHook', 'event' => AfterPersist::class])
->tag('kernel.event_listener', ['method' => 'afterPersistHook', 'event' => AfterPersist::class])
Comment thread
nikophil marked this conversation as resolved.
;
}
};
Loading