1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-09-15 18:57:05 +00:00

Move resetDatabase() in InstallCommandTest as used only there

This commit is contained in:
Yassine Guedidi 2024-01-21 02:07:13 +01:00
parent 5a5a246ae7
commit f161c4b437
2 changed files with 36 additions and 39 deletions

View file

@ -51,7 +51,7 @@ class InstallCommandTest extends WallabagTestCase
$this->getNewClient();
}
$this->resetDatabase($this->getTestClient());
$this->resetDatabase();
}
protected function tearDown(): void
@ -67,7 +67,7 @@ class InstallCommandTest extends WallabagTestCase
// Create a new client to avoid the error:
// Transaction commit failed because the transaction has been marked for rollback only.
$client = $this->getNewClient();
$this->resetDatabase($client);
$this->resetDatabase();
}
parent::tearDown();
@ -276,4 +276,38 @@ class InstallCommandTest extends WallabagTestCase
return $command;
}
private function resetDatabase()
{
$application = new Application($this->getTestClient()->getKernel());
$application->setAutoExit(false);
$application->run(new ArrayInput([
'command' => 'doctrine:schema:drop',
'--no-interaction' => true,
'--force' => true,
'--full-database' => true,
'--env' => 'test',
]), new NullOutput());
$application->run(new ArrayInput([
'command' => 'doctrine:migrations:migrate',
'--no-interaction' => true,
'--env' => 'test',
]), new NullOutput());
$application->run(new ArrayInput([
'command' => 'doctrine:fixtures:load',
'--no-interaction' => true,
'--env' => 'test',
]), new NullOutput());
/*
* Recreate client to avoid error:
*
* [Doctrine\DBAL\ConnectionException]
* Transaction commit failed because the transaction has been marked for rollback only.
*/
$this->getNewClient();
}
}