Skip to content

Commit 54545ef

Browse files
committed
chore(behat): make tests phpunit pass
1 parent 1cab1af commit 54545ef

18 files changed

+102
-88
lines changed

src/Test/Behat/.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
2+
MONGO_URL=""
3+
USE_DAMA_DOCTRINE_TEST_BUNDLE="1"
4+
USE_PHP_84_LAZY_OBJECTS="1"

src/Test/Behat/.env.test

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/Test/Behat/.gitignore

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,5 @@
22
/vendor/
33
/var/
44
/.env.local
5-
6-
###> symfony/framework-bundle ###
7-
/.env.local
8-
/.env.local.php
9-
/.env.*.local
10-
/config/secrets/prod/prod.decrypt.private.php
11-
/public/bundles/
12-
/var/
13-
/vendor/
14-
###< symfony/framework-bundle ###
15-
16-
###> phpunit/phpunit ###
17-
/phpunit.xml
185
/.phpunit.cache/
19-
###< phpunit/phpunit ###
6+
/config/reference.php

src/Test/Behat/behat.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ default:
2121

2222
suites:
2323
main:
24-
paths: [tests/behatFeatures/main]
24+
paths: [features/main]
2525
contexts: &common_contexts
2626
- Behat\MinkExtension\Context\MinkContext
27-
- Zenstruck\Foundry\Tests\Fixture\Behat\TestFoundryContext
27+
- Zenstruck\Foundry\Test\Behat\Tests\Fixture\TestFoundryContext
2828

2929
main-no-dama:
3030
extensions:
@@ -35,7 +35,7 @@ main-no-dama:
3535
suites:
3636
main: false
3737
main-no-dama:
38-
paths: [tests/behatFeatures/main]
38+
paths: [features/main]
3939
contexts: *common_contexts
4040

4141
main-native-dama:
@@ -48,7 +48,7 @@ main-native-dama:
4848
suites:
4949
main: false
5050
main-native-dama:
51-
paths: [tests/behatFeatures/main]
51+
paths: [features/main]
5252
contexts: *common_contexts
5353

5454
reset-manual:
@@ -60,7 +60,7 @@ reset-manual:
6060
suites:
6161
main: false
6262
reset-manual:
63-
paths: [tests/behatFeatures/reset-manual]
63+
paths: [features/reset-manual]
6464
contexts: *common_contexts
6565

6666
reset-manual-dama:
@@ -72,7 +72,7 @@ reset-manual-dama:
7272
suites:
7373
main: false
7474
reset-manual-dama:
75-
paths: [tests/behatFeatures/reset-manual]
75+
paths: [features/reset-manual]
7676
contexts: *common_contexts
7777

7878
reset-feature:
@@ -84,7 +84,7 @@ reset-feature:
8484
suites:
8585
main: false
8686
reset-feature:
87-
paths: [tests/behatFeatures/reset-feature]
87+
paths: [features/reset-feature]
8888
contexts: *common_contexts
8989

9090

@@ -97,7 +97,7 @@ reset-feature-dama:
9797
suites:
9898
main: false
9999
reset-feature-dama:
100-
paths: [tests/behatFeatures/reset-feature]
100+
paths: [features/reset-feature]
101101
contexts: *common_contexts
102102

103103
reset-disabled:
@@ -109,8 +109,8 @@ reset-disabled:
109109
suites:
110110
main: false
111111
reset-disabled:
112-
paths: [tests/behatFeatures/reset-disabled]
112+
paths: [features/reset-disabled]
113113
contexts:
114114
- Behat\MinkExtension\Context\MinkContext
115-
- Zenstruck\Foundry\Tests\Fixture\Behat\TestFoundryContext
116-
- Zenstruck\Foundry\Tests\Fixture\Behat\ResetDisabledTestContext
115+
- Zenstruck\Foundry\Test\Behat\Tests\Fixture\TestFoundryContext
116+
- Zenstruck\Foundry\Test\Behat\Tests\Fixture\ResetDisabledTestContext

src/Test/Behat/bin/phpunit

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/Test/Behat/composer.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@
2929
"symfony/polyfill-php84": "^1.33",
3030
"symfony/polyfill-php85": "^1.33",
3131
"symfony/string": "^6.4|^7.0",
32-
"zenstruck/foundry": "^2.9"
32+
"zenstruck/foundry": "dev-behat-extension"
3333
},
3434
"require-dev": {
3535
"behat/mink-browserkit-driver": "^2.0",
3636
"doctrine/orm": "^2.16|^3.0",
3737
"doctrine/common": "^3.2.2",
3838
"doctrine/doctrine-bundle": "^2.10|^3.0",
3939
"friends-of-behat/mink-extension": "^2.0",
40+
"symfony/dotenv": "^6.4|^7.0",
4041
"symfony/flex": "^2.10",
4142
"symfony/framework-bundle": "^6.4|^7.0",
4243
"symfony/uid": "^6.4|^7.0",
@@ -57,9 +58,7 @@
5758
}
5859
},
5960
"scripts": {
60-
"auto-scripts": {
61-
"cache:clear": "symfony-cmd",
62-
"assets:install %PUBLIC_DIR%": "symfony-cmd"
63-
}
61+
"post-install-cmd": ["./symlink-vendor.sh"],
62+
"post-update-cmd": ["./symlink-vendor.sh"]
6463
}
6564
}

src/Test/Behat/phpunit.dist.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
<server name="APP_ENV" value="test" force="true" />
1717
<server name="SHELL_VERBOSITY" value="-1" />
1818
<server name="KERNEL_CLASS" value="Zenstruck\Foundry\Test\Behat\Tests\Fixture\BehatTestKernel"/>
19-
<env name="DATABASE_URL" value="sqlite:///%kernel.project_dir%/var/data.db"/>
20-
<env name="USE_DAMA_DOCTRINE_TEST_BUNDLE" value="1"/>
21-
<env name="USE_PHP_84_LAZY_OBJECTS" value="1"/>
22-
<env name="MONGO_URL" value=""/>
2319
</php>
2420

2521
<testsuites>
@@ -45,6 +41,7 @@
4541
</source>
4642

4743
<extensions>
44+
<bootstrap class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension"/>
4845
<bootstrap class="Zenstruck\Foundry\PHPUnit\FoundryExtension">
4946
<parameter name="enabled-auto-reset" value="true"/>
5047
</bootstrap>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the zenstruck/foundry package.
5+
*
6+
* (c) Kevin Bond <kevinbond@gmail.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Zenstruck\Foundry\Test\Behat\DependencyInjection;
13+
14+
use Symfony\Component\Config\FileLocator;
15+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16+
use Symfony\Component\DependencyInjection\ContainerBuilder;
17+
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
18+
19+
/**
20+
* @internal
21+
* @author Nicolas PHILIPPE <nikophil@gmail.com>
22+
*/
23+
final class BehatServicesCompilerPass implements CompilerPassInterface
24+
{
25+
public function process(ContainerBuilder $container): void
26+
{
27+
if (!$container->has('behat.service_container')) {
28+
// we're not in a Behat context
29+
return;
30+
}
31+
32+
$loader = new PhpFileLoader($container, new FileLocator(dirname(__DIR__, 2).'/config'));
33+
$loader->load('behat.php');
34+
}
35+
}

src/Test/Behat/src/Listener/DatabaseResetListener.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ public function resetBeforeSuite(): void
8282
}
8383

8484
ResetDatabaseManager::resetBeforeFirstTest($this->symfonyKernel);
85+
86+
// if ($this->damaSupportEnabled) {
87+
// StaticDriver::beginTransaction();
88+
// }
8589
}
8690

8791
public function disableStaticConnection(): void

0 commit comments

Comments
 (0)