]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Fix tests 1362/head
authorJeremy Benoist <jeremy.benoist@gmail.com>
Fri, 11 Sep 2015 14:13:59 +0000 (16:13 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Sat, 12 Sep 2015 09:36:16 +0000 (11:36 +0200)
Ensure that created use during install command will always be unique.
We assume that the install command must be run to initialize a wallabag instance. NEVER to add more user.

Also, use a better way to retrieve the real name of the database and not the one defined in parameters.yml (which isn't the same for test envi because the dbname isn't defined in parameters.yml but directly in config_test.yml)

src/Wallabag/CoreBundle/Command/InstallCommand.php
src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php
src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php

index 29d91109e48d6608c15bae42a0f84149318cc09a..1bd76ae36ec9db535b68ce33926d09228a886eec 100644 (file)
@@ -273,10 +273,11 @@ class InstallCommand extends ContainerAwareCommand
      */
     private function isDatabasePresent()
     {
-        $databaseName = $this->getContainer()->getParameter('database_name');
+        $connection = $this->getContainer()->get('doctrine')->getManager()->getConnection();
+        $databaseName = $connection->getDatabase();
 
         try {
-            $schemaManager = $this->getContainer()->get('doctrine')->getManager()->getConnection()->getSchemaManager();
+            $schemaManager = $connection->getSchemaManager();
         } catch (\Exception $exception) {
             if (false !== strpos($exception->getMessage(), sprintf("Unknown database '%s'", $databaseName))) {
                 return false;
index 3067e5a4dcb951bdab3e03e2a787f361942b5cbe..24910e605d603f36b0dc4e432aec9eb8c18e50bd 100644 (file)
@@ -41,7 +41,7 @@ class InstallCommandTest extends WallabagCoreTestCase
             ->getMock();
         $dialog->expects($this->any())
             ->method('ask')
-            ->will($this->returnValue('test'));
+            ->will($this->returnValue('test_'.uniqid('', true)));
         $dialog->expects($this->any())
             ->method('askConfirmation')
             ->will($this->returnValue(true));
@@ -75,7 +75,7 @@ class InstallCommandTest extends WallabagCoreTestCase
             ->getMock();
         $dialog->expects($this->any())
             ->method('ask')
-            ->will($this->returnValue('test2'));
+            ->will($this->returnValue('test_'.uniqid('', true)));
         $dialog->expects($this->any())
             ->method('askConfirmation')
             ->will($this->returnValue(true));
@@ -125,7 +125,7 @@ class InstallCommandTest extends WallabagCoreTestCase
             ->getMock();
         $dialog->expects($this->any())
             ->method('ask')
-            ->will($this->returnValue('test'));
+            ->will($this->returnValue('test_'.uniqid('', true)));
         $dialog->expects($this->any())
             ->method('askConfirmation')
             ->will($this->returnValue(true));
@@ -259,7 +259,7 @@ class InstallCommandTest extends WallabagCoreTestCase
             ->getMock();
         $dialog->expects($this->any())
             ->method('ask')
-            ->will($this->returnValue('test'));
+            ->will($this->returnValue('test_'.uniqid('', true)));
         $dialog->expects($this->any())
             ->method('askConfirmation')
             ->will($this->returnValue(true));
index a096628582cc4a6209e48ecc3f1f7e5a2dc57775..a92835b3162b6072014e08e15a123227e376f64f 100644 (file)
@@ -209,7 +209,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $content = $client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagCoreBundle:Entry')
-            ->findOneById(1);
+            ->findOneByIsStarred(false);
 
         $client->request('GET', '/delete/'.$content->getId());
 
@@ -360,13 +360,13 @@ class EntryControllerTest extends WallabagCoreTestCase
         $form['entry_filter[isStarred]']->untick();
 
         $crawler = $client->submit($form);
-        $this->assertCount(1, $crawler->filter('div[class=entry]'));
+        $this->assertCount(2, $crawler->filter('div[class=entry]'));
 
         $form = $crawler->filter('button[id=submit-filter]')->form();
         $form['entry_filter[isArchived]']->untick();
         $form['entry_filter[isStarred]']->tick();
 
         $crawler = $client->submit($form);
-        $this->assertCount(1, $crawler->filter('div[class=entry]'));
+        $this->assertCount(2, $crawler->filter('div[class=entry]'));
     }
 }
index af39d6ce11ea28386cc00bef3a121c2fbaaa49ca..d25b2db5fbeb4bd0432d323661a93e4cfd7eb3aa 100644 (file)
@@ -24,7 +24,7 @@ class TagControllerTest extends WallabagCoreTestCase
         $entry = $client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagCoreBundle:Entry')
-            ->findOneByIsArchived(false);
+            ->findOneBy(array());
 
         $crawler = $client->request('GET', '/view/'.$entry->getId());