diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2015-09-11 16:13:59 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2015-09-12 11:36:16 +0200 |
commit | af43bd37675954f937720f7b6fbcf78d85928bc5 (patch) | |
tree | dfcb9a7cd9a1eeac200852ef74f6fc9329e3337c /src | |
parent | 3f7a62908cc34b9d575bea5629dc0bb94e521e71 (diff) | |
download | wallabag-af43bd37675954f937720f7b6fbcf78d85928bc5.tar.gz wallabag-af43bd37675954f937720f7b6fbcf78d85928bc5.tar.zst wallabag-af43bd37675954f937720f7b6fbcf78d85928bc5.zip |
Fix tests
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)
Diffstat (limited to 'src')
4 files changed, 11 insertions, 10 deletions
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index 29d91109..1bd76ae3 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php | |||
@@ -273,10 +273,11 @@ class InstallCommand extends ContainerAwareCommand | |||
273 | */ | 273 | */ |
274 | private function isDatabasePresent() | 274 | private function isDatabasePresent() |
275 | { | 275 | { |
276 | $databaseName = $this->getContainer()->getParameter('database_name'); | 276 | $connection = $this->getContainer()->get('doctrine')->getManager()->getConnection(); |
277 | $databaseName = $connection->getDatabase(); | ||
277 | 278 | ||
278 | try { | 279 | try { |
279 | $schemaManager = $this->getContainer()->get('doctrine')->getManager()->getConnection()->getSchemaManager(); | 280 | $schemaManager = $connection->getSchemaManager(); |
280 | } catch (\Exception $exception) { | 281 | } catch (\Exception $exception) { |
281 | if (false !== strpos($exception->getMessage(), sprintf("Unknown database '%s'", $databaseName))) { | 282 | if (false !== strpos($exception->getMessage(), sprintf("Unknown database '%s'", $databaseName))) { |
282 | return false; | 283 | return false; |
diff --git a/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php b/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php index 3067e5a4..24910e60 100644 --- a/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php +++ b/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php | |||
@@ -41,7 +41,7 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
41 | ->getMock(); | 41 | ->getMock(); |
42 | $dialog->expects($this->any()) | 42 | $dialog->expects($this->any()) |
43 | ->method('ask') | 43 | ->method('ask') |
44 | ->will($this->returnValue('test')); | 44 | ->will($this->returnValue('test_'.uniqid('', true))); |
45 | $dialog->expects($this->any()) | 45 | $dialog->expects($this->any()) |
46 | ->method('askConfirmation') | 46 | ->method('askConfirmation') |
47 | ->will($this->returnValue(true)); | 47 | ->will($this->returnValue(true)); |
@@ -75,7 +75,7 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
75 | ->getMock(); | 75 | ->getMock(); |
76 | $dialog->expects($this->any()) | 76 | $dialog->expects($this->any()) |
77 | ->method('ask') | 77 | ->method('ask') |
78 | ->will($this->returnValue('test2')); | 78 | ->will($this->returnValue('test_'.uniqid('', true))); |
79 | $dialog->expects($this->any()) | 79 | $dialog->expects($this->any()) |
80 | ->method('askConfirmation') | 80 | ->method('askConfirmation') |
81 | ->will($this->returnValue(true)); | 81 | ->will($this->returnValue(true)); |
@@ -125,7 +125,7 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
125 | ->getMock(); | 125 | ->getMock(); |
126 | $dialog->expects($this->any()) | 126 | $dialog->expects($this->any()) |
127 | ->method('ask') | 127 | ->method('ask') |
128 | ->will($this->returnValue('test')); | 128 | ->will($this->returnValue('test_'.uniqid('', true))); |
129 | $dialog->expects($this->any()) | 129 | $dialog->expects($this->any()) |
130 | ->method('askConfirmation') | 130 | ->method('askConfirmation') |
131 | ->will($this->returnValue(true)); | 131 | ->will($this->returnValue(true)); |
@@ -259,7 +259,7 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
259 | ->getMock(); | 259 | ->getMock(); |
260 | $dialog->expects($this->any()) | 260 | $dialog->expects($this->any()) |
261 | ->method('ask') | 261 | ->method('ask') |
262 | ->will($this->returnValue('test')); | 262 | ->will($this->returnValue('test_'.uniqid('', true))); |
263 | $dialog->expects($this->any()) | 263 | $dialog->expects($this->any()) |
264 | ->method('askConfirmation') | 264 | ->method('askConfirmation') |
265 | ->will($this->returnValue(true)); | 265 | ->will($this->returnValue(true)); |
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index a0966285..a92835b3 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | |||
@@ -209,7 +209,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
209 | $content = $client->getContainer() | 209 | $content = $client->getContainer() |
210 | ->get('doctrine.orm.entity_manager') | 210 | ->get('doctrine.orm.entity_manager') |
211 | ->getRepository('WallabagCoreBundle:Entry') | 211 | ->getRepository('WallabagCoreBundle:Entry') |
212 | ->findOneById(1); | 212 | ->findOneByIsStarred(false); |
213 | 213 | ||
214 | $client->request('GET', '/delete/'.$content->getId()); | 214 | $client->request('GET', '/delete/'.$content->getId()); |
215 | 215 | ||
@@ -360,13 +360,13 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
360 | $form['entry_filter[isStarred]']->untick(); | 360 | $form['entry_filter[isStarred]']->untick(); |
361 | 361 | ||
362 | $crawler = $client->submit($form); | 362 | $crawler = $client->submit($form); |
363 | $this->assertCount(1, $crawler->filter('div[class=entry]')); | 363 | $this->assertCount(2, $crawler->filter('div[class=entry]')); |
364 | 364 | ||
365 | $form = $crawler->filter('button[id=submit-filter]')->form(); | 365 | $form = $crawler->filter('button[id=submit-filter]')->form(); |
366 | $form['entry_filter[isArchived]']->untick(); | 366 | $form['entry_filter[isArchived]']->untick(); |
367 | $form['entry_filter[isStarred]']->tick(); | 367 | $form['entry_filter[isStarred]']->tick(); |
368 | 368 | ||
369 | $crawler = $client->submit($form); | 369 | $crawler = $client->submit($form); |
370 | $this->assertCount(1, $crawler->filter('div[class=entry]')); | 370 | $this->assertCount(2, $crawler->filter('div[class=entry]')); |
371 | } | 371 | } |
372 | } | 372 | } |
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php index af39d6ce..d25b2db5 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php | |||
@@ -24,7 +24,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
24 | $entry = $client->getContainer() | 24 | $entry = $client->getContainer() |
25 | ->get('doctrine.orm.entity_manager') | 25 | ->get('doctrine.orm.entity_manager') |
26 | ->getRepository('WallabagCoreBundle:Entry') | 26 | ->getRepository('WallabagCoreBundle:Entry') |
27 | ->findOneByIsArchived(false); | 27 | ->findOneBy(array()); |
28 | 28 | ||
29 | $crawler = $client->request('GET', '/view/'.$entry->getId()); | 29 | $crawler = $client->request('GET', '/view/'.$entry->getId()); |
30 | 30 | ||