Skip to content

Commit

Permalink
Merge pull request shlinkio#18 from acelaya-forks/feature/improve-tes…
Browse files Browse the repository at this point in the history
…t-db-creation

Feature/improve test db creation
  • Loading branch information
acelaya authored Mar 12, 2021
2 parents 2d113b3 + 0c2ffab commit c7acac7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).

## [2.1.0] - 2021-03-12
### Added
* Improved `TestHelper::createTestDb` method, so that it tries to run the migrations too, which helps spot issues on them.

### Changed
* *Nothing*

### Deprecated
* *Nothing*

### Removed
* Dropped support for guzzle 6.*

### Fixed
* *Nothing*


## [2.0.0] - 2021-01-13
### Added
* [#17](https://github.com/shlinkio/shlink-test-utils/issues/17) Update `DatabaseTestCase` so that it wraps every test in a transaction that is then rolled back.
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"require": {
"php": "^7.4 || ^8.0",
"ext-json": "*",
"doctrine/data-fixtures": "^1.4",
"doctrine/orm": "^2.7",
"doctrine/data-fixtures": "^1.5",
"doctrine/orm": "^2.8",
"fig/http-message-util": "^1.1",
"guzzlehttp/guzzle": "^7.0 || ^6.5.1",
"phpunit/phpunit": "^9.4",
"symfony/process": "^5.0"
"guzzlehttp/guzzle": "^7.0",
"phpunit/phpunit": "^9.5",
"symfony/process": "^5.2"
},
"require-dev": {
"phpstan/phpstan": "^0.12.52",
Expand Down
8 changes: 8 additions & 0 deletions src/Helper/TestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ public function createTestDb(): void
$process = new Process(['vendor/bin/doctrine', 'orm:schema-tool:drop', '--force', '--no-interaction', '-q']);
$process->mustRun();

$process = new Process(
['vendor/bin/doctrine', 'dbal:run-sql', 'DROP TABLE migrations', '--no-interaction', '-q'],
);
$process->run(); // The table may not exist, so let's not enforce the successful run

$process = new Process(['vendor/bin/doctrine', 'orm:schema-tool:create', '--no-interaction', '-q']);
$process->mustRun();

$process = new Process(['vendor/bin/doctrine-migrations', 'migrations:migrate', '--no-interaction', '-q']);
$process->mustRun();
}

public function seedFixtures(EntityManagerInterface $em, array $config): void
Expand Down

0 comments on commit c7acac7

Please sign in to comment.