Skip to content

Commit 43468b3

Browse files
committed
Automatically inject bootstrap into winter:test command
This commit also enforces some testing environment variables at the process level.
1 parent 583f1f4 commit 43468b3

File tree

6 files changed

+35
-83
lines changed

6 files changed

+35
-83
lines changed

modules/backend/phpunit.xml

+9-14
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
4-
bootstrap="../system/tests/bootstrap/app.php"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false"
2+
<phpunit
3+
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
1111
>
1212
<testsuites>
1313
<testsuite name="Winter Backend Module">
1414
<directory>./tests</directory>
1515
</testsuite>
1616
</testsuites>
17-
<php>
18-
<env name="APP_ENV" value="testing" />
19-
<env name="CACHE_DRIVER" value="array" />
20-
<env name="SESSION_DRIVER" value="array" />
21-
</php>
2217
</phpunit>

modules/cms/phpunit.xml

+9-14
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
4-
bootstrap="../system/tests/bootstrap/app.php"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false"
2+
<phpunit
3+
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
1111
>
1212
<testsuites>
1313
<testsuite name="Winter CMS Module">
1414
<directory>./tests</directory>
1515
</testsuite>
1616
</testsuites>
17-
<php>
18-
<env name="APP_ENV" value="testing" />
19-
<env name="CACHE_DRIVER" value="array" />
20-
<env name="SESSION_DRIVER" value="array" />
21-
</php>
2217
</phpunit>

modules/system/console/WinterTest.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,16 @@ protected function execPhpUnit(string $config, array $args): int
140140

141141
// Resolve the configuration path based on the current working directory
142142
$config = realpath($config);
143+
$bootstrapPath = base_path('modules/system/tests/bootstrap/app.php');
143144

144145
$process = new Process(
145-
array_merge([$this->phpUnitExec, '--configuration=' . $config], $args),
146+
array_merge([$this->phpUnitExec, '--configuration=' . $config, '--bootstrap=' . $bootstrapPath], $args),
146147
base_path(),
147-
null,
148+
[
149+
'APP_ENV' => 'testing',
150+
'CACHE_DRIVER' => 'array',
151+
'SESSION_DRIVER' => 'array',
152+
],
148153
null
149154
);
150155

modules/system/phpunit.xml

+9-14
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
4-
bootstrap="./tests/bootstrap/app.php"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false"
2+
<phpunit
3+
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
1111
>
1212
<testsuites>
1313
<testsuite name="Winter System Module">
1414
<directory>./tests</directory>
1515
</testsuite>
1616
</testsuites>
17-
<php>
18-
<env name="APP_ENV" value="testing" />
19-
<env name="CACHE_DRIVER" value="array" />
20-
<env name="SESSION_DRIVER" value="array" />
21-
</php>
2217
</phpunit>

phpunit.xml

-39
This file was deleted.

plugins/winter/redirect

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 7742fc77d39e3bc56a91a53ff4639920c447ea4e

0 commit comments

Comments
 (0)