-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: extract reset:migration tests in another testsuite
- Loading branch information
Showing
22 changed files
with
507 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
# DBMS can be changed by adding the following in .env.local: | ||
#DATABASE_URL="postgresql://zenstruck:[email protected]:5433/zenstruck_foundry?serverVersion=15" | ||
#DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" | ||
DATABASE_URL="mysql://root:[email protected]:3307/foundry_test?serverVersion=5.7.42" | ||
|
||
# Mongo ca be disabled with the following in .env.local: | ||
# MONGO_URL="" | ||
MONGO_URL="mongodb://127.0.0.1:27018/dbName?compressors=disabled&gssapiServiceName=mongodb" | ||
DATABASE_RESET_MODE="schema" | ||
|
||
USE_DAMA_DOCTRINE_TEST_BUNDLE="0" | ||
PHPUNIT_VERSION="9" | ||
PHPUNIT_VERSION="9" # allowed values: 9, 10, 11, 11.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,20 +47,15 @@ $ docker compose up --detach | |
# install dependencies | ||
$ composer update | ||
|
||
# run test suite with all available permutations | ||
$ composer test | ||
|
||
# run only one permutation | ||
# run main testsuite (with "schema" reset database strategy) | ||
$ composer test-schema | ||
# or | ||
$ ./phpunit | ||
|
||
# run test suite with dama/doctrine-test-bundle | ||
$ USE_DAMA_DOCTRINE_TEST_BUNDLE=1 vendor/bin/phpunit | ||
|
||
# run test suite with postgreSQL instead of MySQL | ||
$ DATABASE_URL="postgresql://zenstruck:[email protected]:5433/zenstruck_foundry?serverVersion=15" vendor/bin/phpunit | ||
|
||
# run test suite with another PHPUnit version | ||
$ PHPUNIT_VERSION=10 vendor/bin/phpunit | ||
# run "migrate" testsuite (with "migrate" reset database strategy) | ||
$ composer test-migrate | ||
# or | ||
$ ./phpunit --testsuite migrate --bootstrap tests/bootstrap-migrate.php | ||
``` | ||
|
||
### Overriding the default configuration | ||
|
@@ -69,11 +64,20 @@ You can override default environment variables by creating a `.env.local` file, | |
|
||
```bash | ||
# .env.local | ||
DATABASE_URL="postgresql://zenstruck:[email protected]:5433/zenstruck_foundry?serverVersion=15" # enables postgreSQL instead of MySQL | ||
|
||
# change the database to postgreSQL... | ||
DATABASE_URL="postgresql://zenstruck:[email protected]:5433/zenstruck_foundry?serverVersion=15" | ||
# ...or to SQLite | ||
DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" | ||
|
||
MONGO_URL="" # disables Mongo | ||
USE_DAMA_DOCTRINE_TEST_BUNDLE="1" # enables dama/doctrine-test-bundle | ||
PHPUNIT_VERSION="11" # possible values: 9, 10, 11, 11.4 | ||
|
||
# test reset database with configuration migration, | ||
# only relevant for "migrate" testsuite | ||
WITH_MIGRATION_CONFIGURATION_FILE="tests/Fixture/MigrationTests/configs/migration-configuration.php" | ||
|
||
# run test suite with postgreSQL | ||
$ vendor/bin/phpunit | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,16 +5,16 @@ | |
namespace Zenstruck\Foundry\Mongo; | ||
|
||
use Symfony\Component\HttpKernel\KernelInterface; | ||
use Zenstruck\Foundry\Persistence\SymfonyCommandRunner; | ||
|
||
use function Zenstruck\Foundry\application; | ||
use function Zenstruck\Foundry\runCommand; | ||
|
||
/** | ||
* @internal | ||
* @author Nicolas PHILIPPE <[email protected]> | ||
*/ | ||
final class MongoSchemaResetter implements MongoResetter | ||
{ | ||
use SymfonyCommandRunner; | ||
|
||
/** | ||
* @param list<string> $managers | ||
*/ | ||
|
@@ -24,15 +24,15 @@ public function __construct(private array $managers) | |
|
||
public function resetBeforeEachTest(KernelInterface $kernel): void | ||
{ | ||
$application = self::application($kernel); | ||
$application = application($kernel); | ||
|
||
foreach ($this->managers as $manager) { | ||
try { | ||
self::runCommand($application, 'doctrine:mongodb:schema:drop', ['--dm' => $manager]); | ||
runCommand($application, "doctrine:mongodb:schema:drop --dm={$manager}"); | ||
} catch (\Exception) { | ||
} | ||
|
||
self::runCommand($application, 'doctrine:mongodb:schema:create', ['--dm' => $manager]); | ||
runCommand($application, "doctrine:mongodb:schema:create --dm={$manager}"); | ||
} | ||
} | ||
} |
Oops, something went wrong.