mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-22 09:01:01 +00:00
Move resetDatabase() in InstallCommandTest as used only there
This commit is contained in:
parent
5a5a246ae7
commit
f161c4b437
2 changed files with 36 additions and 39 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,8 @@
|
|||
namespace Tests\Wallabag;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\NullOutput;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Wallabag\Entity\User;
|
||||
|
||||
|
@ -39,40 +36,6 @@ abstract class WallabagTestCase extends WebTestCase
|
|||
return $this->client;
|
||||
}
|
||||
|
||||
public function resetDatabase(KernelBrowser $client)
|
||||
{
|
||||
$application = new Application($client->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->client = $this->getNewClient();
|
||||
}
|
||||
|
||||
public function getEntityManager()
|
||||
{
|
||||
return $this->client->getContainer()->get(EntityManagerInterface::class);
|
||||
|
|
Loading…
Reference in a new issue