forked from wallabag/wallabag
Update test
If the database isn't found when checking for the connection it means, we can connect to the server. The InstallCommand will create the database later. Also, when checking for the SQLite connection, Doctrine creates the file (so the database). That's why the test is skipped for SQLite.
This commit is contained in:
@ -96,9 +96,11 @@ class InstallCommand extends ContainerAwareCommand
|
|||||||
try {
|
try {
|
||||||
$this->getContainer()->get('doctrine')->getManager()->getConnection()->connect();
|
$this->getContainer()->get('doctrine')->getManager()->getConnection()->connect();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$fulfilled = false;
|
if (false === strpos($e->getMessage(), "Unknown database")) {
|
||||||
$status = '<error>ERROR!</error>';
|
$fulfilled = false;
|
||||||
$help = 'Can\'t connect to the database: '.$e->getMessage();
|
$status = '<error>ERROR!</error>';
|
||||||
|
$help = 'Can\'t connect to the database: '.$e->getMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows[] = [$label, $status, $help];
|
$rows[] = [$label, $status, $help];
|
||||||
@ -472,7 +474,7 @@ class InstallCommand extends ContainerAwareCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
// custom verification for sqlite, since `getListDatabasesSQL` doesn't work for sqlite
|
// custom verification for sqlite, since `getListDatabasesSQL` doesn't work for sqlite
|
||||||
if ('sqlite' == $schemaManager->getDatabasePlatform()->getName()) {
|
if ('sqlite' === $schemaManager->getDatabasePlatform()->getName()) {
|
||||||
$params = $this->getContainer()->get('doctrine.dbal.default_connection')->getParams();
|
$params = $this->getContainer()->get('doctrine.dbal.default_connection')->getParams();
|
||||||
|
|
||||||
if (isset($params['path']) && file_exists($params['path'])) {
|
if (isset($params['path']) && file_exists($params['path'])) {
|
||||||
|
|||||||
@ -127,6 +127,12 @@ class InstallCommandTest extends WallabagCoreTestCase
|
|||||||
|
|
||||||
public function testRunInstallCommandWithDatabaseRemoved()
|
public function testRunInstallCommandWithDatabaseRemoved()
|
||||||
{
|
{
|
||||||
|
// skipped SQLite check when database is removed because while testing for the connection,
|
||||||
|
// the driver will create the file (so the database) before testing if database exist
|
||||||
|
if ($this->getClient()->getContainer()->get('doctrine')->getConnection()->getDriver() instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver) {
|
||||||
|
$this->markTestSkipped('SQLite spotted: can\'t test with database removed.');
|
||||||
|
}
|
||||||
|
|
||||||
$application = new Application($this->getClient()->getKernel());
|
$application = new Application($this->getClient()->getKernel());
|
||||||
$application->add(new DropDatabaseDoctrineCommand());
|
$application->add(new DropDatabaseDoctrineCommand());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user