diff --git a/composer.json b/composer.json index aa13a847..0ce15c6e 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "akrabat/ip-address-middleware": "^2.0", "cakephp/chronos": "^2.2", "cocur/slugify": "^4.0", - "doctrine/migrations": "^3.2 <3.3", + "doctrine/migrations": "^3.3", "doctrine/orm": "^2.9", "endroid/qr-code": "^4.2", "geoip2/geoip2": "^2.11", @@ -73,7 +73,7 @@ "phpunit/phpunit": "^9.5", "roave/security-advisories": "dev-master", "shlinkio/php-coding-standard": "~2.2.0", - "shlinkio/shlink-test-utils": "^2.2", + "shlinkio/shlink-test-utils": "^2.3", "symfony/var-dumper": "^5.3", "veewee/composer-run-parallel": "^1.0" }, diff --git a/config/test/bootstrap_api_tests.php b/config/test/bootstrap_api_tests.php index 7bda8c10..8d22d029 100644 --- a/config/test/bootstrap_api_tests.php +++ b/config/test/bootstrap_api_tests.php @@ -29,6 +29,6 @@ register_shutdown_function(function () use ($httpClient): void { ); }); -$testHelper->createTestDb(); +$testHelper->createTestDb(['bin/cli', 'db:create'], ['bin/cli', 'db:migrate']); ApiTest\ApiTestCase::setApiClient($httpClient); ApiTest\ApiTestCase::setSeedFixturesCallback(fn () => $testHelper->seedFixtures($em, $config['data_fixtures'] ?? [])); diff --git a/config/test/bootstrap_db_tests.php b/config/test/bootstrap_db_tests.php index 9f14c38d..0237d741 100644 --- a/config/test/bootstrap_db_tests.php +++ b/config/test/bootstrap_db_tests.php @@ -8,5 +8,5 @@ use Psr\Container\ContainerInterface; /** @var ContainerInterface $container */ $container = require __DIR__ . '/../container.php'; -$container->get(Helper\TestHelper::class)->createTestDb(); +$container->get(Helper\TestHelper::class)->createTestDb(['bin/cli', 'db:create'], ['bin/cli', 'db:migrate']); DbTest\DatabaseTestCase::setEntityManager($container->get('em')); diff --git a/module/CLI/src/Command/Db/CreateDatabaseCommand.php b/module/CLI/src/Command/Db/CreateDatabaseCommand.php index 428140e5..a294da9e 100644 --- a/module/CLI/src/Command/Db/CreateDatabaseCommand.php +++ b/module/CLI/src/Command/Db/CreateDatabaseCommand.php @@ -67,7 +67,7 @@ class CreateDatabaseCommand extends AbstractDatabaseCommand // In order to create the new database, we have to use a connection where the dbname was not set. // Otherwise, it will fail to connect and will not be able to create the new database - $schemaManager = $this->noDbNameConn->getSchemaManager(); + $schemaManager = $this->noDbNameConn->createSchemaManager(); $databases = $schemaManager->listDatabases(); $shlinkDatabase = $this->regularConn->getDatabase(); @@ -80,7 +80,7 @@ class CreateDatabaseCommand extends AbstractDatabaseCommand { // If at least one of the shlink tables exist, we will consider the database exists somehow. // Any inconsistency should be taken care by the migrations - $schemaManager = $this->regularConn->getSchemaManager(); + $schemaManager = $this->regularConn->createSchemaManager(); return ! empty($schemaManager->listTableNames()); } } diff --git a/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php b/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php index 70d4d5eb..f77f6b79 100644 --- a/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php +++ b/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php @@ -46,10 +46,10 @@ class CreateDatabaseCommandTest extends TestCase $this->databasePlatform = $this->prophesize(AbstractPlatform::class); $this->regularConn = $this->prophesize(Connection::class); - $this->regularConn->getSchemaManager()->willReturn($this->schemaManager->reveal()); + $this->regularConn->createSchemaManager()->willReturn($this->schemaManager->reveal()); $this->regularConn->getDatabasePlatform()->willReturn($this->databasePlatform->reveal()); $noDbNameConn = $this->prophesize(Connection::class); - $noDbNameConn->getSchemaManager()->willReturn($this->schemaManager->reveal()); + $noDbNameConn->createSchemaManager()->willReturn($this->schemaManager->reveal()); $command = new CreateDatabaseCommand( $locker->reveal(), diff --git a/module/Rest/test/Action/HealthActionTest.php b/module/Rest/test/Action/HealthActionTest.php index 1fbad63d..a233087a 100644 --- a/module/Rest/test/Action/HealthActionTest.php +++ b/module/Rest/test/Action/HealthActionTest.php @@ -6,6 +6,7 @@ namespace ShlinkioTest\Shlink\Rest\Action; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Result; use Doctrine\ORM\EntityManagerInterface; use Exception; use Laminas\Diactoros\Response\JsonResponse; @@ -27,8 +28,7 @@ class HealthActionTest extends TestCase public function setUp(): void { $this->conn = $this->prophesize(Connection::class); - $this->conn->executeQuery(Argument::cetera())->will(function (): void { - }); + $this->conn->executeQuery(Argument::cetera())->willReturn($this->prophesize(Result::class)->reveal()); $dbPlatform = $this->prophesize(AbstractPlatform::class); $dbPlatform->getDummySelectSQL()->willReturn(''); $this->conn->getDatabasePlatform()->willReturn($dbPlatform->reveal());