mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-26 19:11:07 +00:00
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)
This commit is contained in:
parent
3f7a62908c
commit
af43bd3767
4 changed files with 11 additions and 10 deletions
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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]'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
Loading…
Reference in a new issue