Skip to content

Commit 8d6e5ee

Browse files
committed
do not drop database, only drop schema, and setup:phpunit is uselessm its logic is done in PhpServerExtension
1 parent f9baa0e commit 8d6e5ee

4 files changed

Lines changed: 8 additions & 19 deletions

File tree

composer.json

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,18 @@
6464
"scripts": {
6565
"clean-directories": "bin/console clean-directories cache log",
6666
"database:create": "bin/console dbal:database:create --if-not-exists",
67-
"database:drop": "bin/console dbal:database:drop --if-exists --force",
68-
"database:schema:update": "bin/console orm:schema-tool:update --force --dump-sql",
67+
"database:schema:create": "bin/console orm:schema-tool:create",
68+
"database:schema:drop": "bin/console orm:schema-tool:drop --force",
69+
"database:schema:update": "bin/console orm:schema-tool:update --force",
6970
"database:schema:validate": "bin/console orm:validate-schema",
7071
"fix:cs": "mkdir -p build && vendor/bin/php-cs-fixer fix --cache-file=build/phpcs.cache",
7172
"setup:dev": [
72-
"@database:drop --env=dev",
7373
"@database:create --env=dev",
74-
"@database:schema:update --env=dev",
74+
"@database:schema:drop --env=dev",
75+
"@database:schema:create --env=dev",
7576
"@database:schema:validate --env=dev",
7677
"@clean-directories --env=dev"
7778
],
78-
"setup:phpunit": [
79-
"@database:drop --env=phpunit",
80-
"@database:create --env=phpunit",
81-
"@database:schema:update --env=phpunit",
82-
"@database:schema:validate --env=phpunit",
83-
"@clean-directories --env=phpunit"
84-
],
8579
"test": [
8680
"@test:lint",
8781
"@test:static-analysis",

src/Core/ServiceFactory/Command/CommandsFactory.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use Chubbyphp\CleanDirectories\ServiceFactory\CleanDirectoriesCommandFactory;
88
use Chubbyphp\Laminas\Config\Doctrine\DBAL\Tools\Console\Command\Database\CreateCommand as DatabaseCreateCommand;
9-
use Chubbyphp\Laminas\Config\Doctrine\DBAL\Tools\Console\Command\Database\DropCommand as DatabaseDropCommand;
109
use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand;
1110
use Doctrine\DBAL\Tools\Console\ConnectionProvider;
1211
use Doctrine\ORM\Tools\Console\Command\ClearCache\CollectionRegionCommand;
@@ -43,7 +42,6 @@ public function __invoke(ContainerInterface $container): array
4342
return [
4443
(new CleanDirectoriesCommandFactory())($container),
4544
new DatabaseCreateCommand($connectionProvider),
46-
new DatabaseDropCommand($connectionProvider),
4745
new RunSqlCommand($connectionProvider),
4846
new CollectionRegionCommand($entityManagerProvider),
4947
new EntityRegionCommand($entityManagerProvider),

tests/PhpServerExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ private function initialize(): void
5353

5454
echo 'initialize: start'.PHP_EOL;
5555

56-
passthru($consolePath.' dbal:database:drop --if-exists --force --env=phpunit');
5756
passthru($consolePath.' dbal:database:create --env=phpunit');
58-
passthru($consolePath.' orm:schema-tool:update --dump-sql --force --env=phpunit');
59-
57+
passthru($consolePath.' orm:schema-tool:drop --force --env=phpunit');
58+
passthru($consolePath.' orm:schema-tool:create --env=phpunit');
59+
passthru($consolePath.' orm:validate-schema --env=phpunit');
6060
passthru($consolePath.' clean-directories cache log --env=phpunit');
6161

6262
echo 'initialize: end'.PHP_EOL.PHP_EOL;

tests/Unit/Core/ServiceFactory/Command/CommandsFactoryTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use App\Core\ServiceFactory\Command\CommandsFactory;
88
use Chubbyphp\CleanDirectories\Command\CleanDirectoriesCommand;
99
use Chubbyphp\Laminas\Config\Doctrine\DBAL\Tools\Console\Command\Database\CreateCommand as DatabaseCreateCommand;
10-
use Chubbyphp\Laminas\Config\Doctrine\DBAL\Tools\Console\Command\Database\DropCommand as DatabaseDropCommand;
1110
use Chubbyphp\Mock\MockMethod\WithReturn;
1211
use Chubbyphp\Mock\MockObjectBuilder;
1312
use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand;
@@ -66,7 +65,6 @@ public function testInvoke(): void
6665

6766
$cleanDirectoriesCommand = array_shift($commands);
6867
$databaseCreateCommand = array_shift($commands);
69-
$databaseDropCommand = array_shift($commands);
7068
$runSqlCommand = array_shift($commands);
7169
$collectionRegionCommand = array_shift($commands);
7270
$entityRegionCommand = array_shift($commands);
@@ -87,7 +85,6 @@ public function testInvoke(): void
8785

8886
self::assertInstanceOf(CleanDirectoriesCommand::class, $cleanDirectoriesCommand);
8987
self::assertInstanceOf(DatabaseCreateCommand::class, $databaseCreateCommand);
90-
self::assertInstanceOf(DatabaseDropCommand::class, $databaseDropCommand);
9188
self::assertInstanceOf(RunSqlCommand::class, $runSqlCommand);
9289
self::assertInstanceOf(CollectionRegionCommand::class, $collectionRegionCommand);
9390
self::assertInstanceOf(EntityRegionCommand::class, $entityRegionCommand);

0 commit comments

Comments
 (0)