]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Update test
authorJeremy Benoist <jeremy.benoist@gmail.com>
Sat, 3 Sep 2016 08:34:27 +0000 (10:34 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Sat, 3 Sep 2016 08:34:27 +0000 (10:34 +0200)
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.

src/Wallabag/CoreBundle/Command/InstallCommand.php
tests/Wallabag/CoreBundle/Command/InstallCommandTest.php

index 50d0dfff49b56adefe139d929d90fb709712f8f2..cd81614905307c16658a71a8948ae05c437de342 100644 (file)
@@ -96,9 +96,11 @@ class InstallCommand extends ContainerAwareCommand
         try {
             $this->getContainer()->get('doctrine')->getManager()->getConnection()->connect();
         } catch (\Exception $e) {
-            $fulfilled = false;
-            $status = '<error>ERROR!</error>';
-            $help = 'Can\'t connect to the database: '.$e->getMessage();
+            if (false === strpos($e->getMessage(), "Unknown database")) {
+                $fulfilled = false;
+                $status = '<error>ERROR!</error>';
+                $help = 'Can\'t connect to the database: '.$e->getMessage();
+            }
         }
 
         $rows[] = [$label, $status, $help];
@@ -472,7 +474,7 @@ class InstallCommand extends ContainerAwareCommand
         }
 
         // 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();
 
             if (isset($params['path']) && file_exists($params['path'])) {
index 089a1c5fee9a36a2ec6d093d66373581648859d8..83f5bf2461cbb16d69f3cc90426602801f7782bb 100644 (file)
@@ -127,6 +127,12 @@ class InstallCommandTest extends WallabagCoreTestCase
 
     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->add(new DropDatabaseDoctrineCommand());