-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: extract reset:migration tests in another testsuite #692
Open
nikophil
wants to merge
1
commit into
zenstruck:2.x
Choose a base branch
from
nikophil:refactor/remove-migrate-test-permutation
base: 2.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,6 +1,12 @@ | ||
# 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" | ||
USE_FOUNDRY_PHPUNIT_EXTENSION="0" | ||
PHPUNIT_VERSION="9" | ||
PHPUNIT_VERSION="9" # allowed values: 9, 10, 11 |
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 |
---|---|---|
|
@@ -14,16 +14,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 | ||
*/ | ||
|
@@ -33,15 +33,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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also discovered that for an obscure reason, transactional mode + MySQL is buggy - at least in our tests, I'm not using MySQL currently in my day-to-day job, so I can live with this. If a user comes with a problem around it, I'll dig a little bit more!