mirror of https://github.com/wallabag/wallabag.git
Move resetDatabase() in InstallCommandTest as used only there
This commit is contained in:
parent
5a5a246ae7
commit
f161c4b437
|
@ -51,7 +51,7 @@ class InstallCommandTest extends WallabagTestCase
|
||||||
$this->getNewClient();
|
$this->getNewClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->resetDatabase($this->getTestClient());
|
$this->resetDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown(): void
|
protected function tearDown(): void
|
||||||
|
@ -67,7 +67,7 @@ class InstallCommandTest extends WallabagTestCase
|
||||||
// Create a new client to avoid the error:
|
// Create a new client to avoid the error:
|
||||||
// Transaction commit failed because the transaction has been marked for rollback only.
|
// Transaction commit failed because the transaction has been marked for rollback only.
|
||||||
$client = $this->getNewClient();
|
$client = $this->getNewClient();
|
||||||
$this->resetDatabase($client);
|
$this->resetDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
|
@ -276,4 +276,38 @@ class InstallCommandTest extends WallabagTestCase
|
||||||
|
|
||||||
return $command;
|
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;
|
namespace Tests\Wallabag;
|
||||||
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
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 Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
use Wallabag\Entity\User;
|
use Wallabag\Entity\User;
|
||||||
|
|
||||||
|
@ -39,40 +36,6 @@ abstract class WallabagTestCase extends WebTestCase
|
||||||
return $this->client;
|
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()
|
public function getEntityManager()
|
||||||
{
|
{
|
||||||
return $this->client->getContainer()->get(EntityManagerInterface::class);
|
return $this->client->getContainer()->get(EntityManagerInterface::class);
|
||||||
|
|
Loading…
Reference in New Issue