Add a real configuration for CS-Fixer

This commit is contained in:
Jeremy Benoist
2017-07-01 09:52:38 +02:00
parent 822c877949
commit f808b01692
170 changed files with 3147 additions and 3120 deletions

View File

@ -4,8 +4,8 @@ namespace Tests\Wallabag\CoreBundle\Command;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use Wallabag\CoreBundle\Command\CleanDuplicatesCommand;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Wallabag\CoreBundle\Command\CleanDuplicatesCommand;
use Wallabag\CoreBundle\Entity\Entry;
class CleanDuplicatesCommandTest extends WallabagCoreTestCase

View File

@ -4,8 +4,8 @@ namespace Tests\Wallabag\CoreBundle\Command;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use Wallabag\CoreBundle\Command\ExportCommand;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Wallabag\CoreBundle\Command\ExportCommand;
class ExportCommandTest extends WallabagCoreTestCase
{

View File

@ -11,9 +11,9 @@ use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Tester\CommandTester;
use Wallabag\CoreBundle\Command\InstallCommand;
use Tests\Wallabag\CoreBundle\Mock\InstallCommandMock;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Wallabag\CoreBundle\Command\InstallCommand;
class InstallCommandTest extends WallabagCoreTestCase
{
@ -86,9 +86,9 @@ class InstallCommandTest extends WallabagCoreTestCase
$tester->setInputs([
'y', // dropping database
'y', // create super admin
'username_'.uniqid('', true), // username
'password_'.uniqid('', true), // password
'email_'.uniqid('', true).'@wallabag.it', // email
'username_' . uniqid('', true), // username
'password_' . uniqid('', true), // password
'email_' . uniqid('', true) . '@wallabag.it', // email
]);
$tester->execute([
'command' => $command->getName(),
@ -111,9 +111,9 @@ class InstallCommandTest extends WallabagCoreTestCase
$tester = new CommandTester($command);
$tester->setInputs([
'y', // create super admin
'username_'.uniqid('', true), // username
'password_'.uniqid('', true), // password
'email_'.uniqid('', true).'@wallabag.it', // email
'username_' . uniqid('', true), // username
'password_' . uniqid('', true), // password
'email_' . uniqid('', true) . '@wallabag.it', // email
]);
$tester->execute([
'command' => $command->getName(),
@ -159,9 +159,9 @@ class InstallCommandTest extends WallabagCoreTestCase
$tester = new CommandTester($command);
$tester->setInputs([
'y', // create super admin
'username_'.uniqid('', true), // username
'password_'.uniqid('', true), // password
'email_'.uniqid('', true).'@wallabag.it', // email
'username_' . uniqid('', true), // username
'password_' . uniqid('', true), // password
'email_' . uniqid('', true) . '@wallabag.it', // email
]);
$tester->execute([
'command' => $command->getName(),

View File

@ -4,8 +4,8 @@ namespace Tests\Wallabag\CoreBundle\Command;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use Wallabag\CoreBundle\Command\TagAllCommand;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Wallabag\CoreBundle\Command\TagAllCommand;
class TagAllCommandTest extends WallabagCoreTestCase
{

View File

@ -3,11 +3,11 @@
namespace tests\Wallabag\CoreBundle\Controller;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Wallabag\AnnotationBundle\Entity\Annotation;
use Wallabag\CoreBundle\Entity\Config;
use Wallabag\UserBundle\Entity\User;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\AnnotationBundle\Entity\Annotation;
use Wallabag\UserBundle\Entity\User;
class ConfigControllerTest extends WallabagCoreTestCase
{
@ -17,7 +17,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$client->request('GET', '/new');
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('login', $client->getResponse()->headers->get('location'));
}
@ -28,7 +28,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/config');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertCount(1, $crawler->filter('button[id=config_save]'));
$this->assertCount(1, $crawler->filter('button[id=change_passwd_save]'));
@ -43,7 +43,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/config');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=config_save]')->form();
@ -57,7 +57,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
@ -131,13 +131,13 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/config');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=config_save]')->form();
$crawler = $client->submit($form, $data);
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
$this->assertContains('This value should not be blank', $alert[0]);
@ -191,13 +191,13 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/config');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=change_passwd_save]')->form();
$crawler = $client->submit($form, $data);
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
$this->assertContains($expectedMessage, $alert[0]);
@ -210,7 +210,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/config');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=change_passwd_save]')->form();
@ -222,7 +222,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
@ -259,13 +259,13 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/config');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=update_user_save]')->form();
$crawler = $client->submit($form, $data);
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
$this->assertContains($expectedMessage, $alert[0]);
@ -278,7 +278,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/config');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=update_user_save]')->form();
@ -289,7 +289,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
@ -319,13 +319,13 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/config');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('config.form_rss.no_token', $body[0]);
$client->request('GET', '/generate-token');
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
@ -346,7 +346,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
['HTTP_X-Requested-With' => 'XMLHttpRequest']
);
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$content = json_decode($client->getResponse()->getContent(), true);
$this->assertArrayHasKey('token', $content);
}
@ -358,7 +358,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/config');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=rss_config_save]')->form();
@ -368,7 +368,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
@ -403,13 +403,13 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/config');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=rss_config_save]')->form();
$crawler = $client->submit($form, $data);
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
$this->assertContains($expectedMessage, $alert[0]);
@ -423,7 +423,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/config');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=tagging_rule_save]')->form();
@ -434,7 +434,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
@ -443,7 +443,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$editLink = $crawler->filter('.mode_edit')->last()->link();
$crawler = $client->click($editLink);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('?tagging-rule=', $client->getResponse()->headers->get('location'));
$crawler = $client->followRedirect();
@ -457,7 +457,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
@ -468,7 +468,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$deleteLink = $crawler->filter('.delete')->last()->link();
$crawler = $client->click($deleteLink);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$this->assertContains('flashes.config.notice.tagging_rules_deleted', $crawler->filter('body')->extract(['_text'])[0]);
@ -510,13 +510,13 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/config');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=tagging_rule_save]')->form();
$crawler = $client->submit($form, $data);
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
@ -532,7 +532,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/config');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=tagging_rule_save]')->form();
@ -541,7 +541,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
'tagging_rule[tags]' => 'cool tag',
]);
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
@ -557,9 +557,9 @@ class ConfigControllerTest extends WallabagCoreTestCase
->getRepository('WallabagCoreBundle:TaggingRule')
->findAll()[0];
$crawler = $client->request('GET', '/tagging-rule/edit/'.$rule->getId());
$crawler = $client->request('GET', '/tagging-rule/edit/' . $rule->getId());
$this->assertEquals(403, $client->getResponse()->getStatusCode());
$this->assertSame(403, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('You can not access this tagging rule', $body[0]);
}
@ -573,9 +573,9 @@ class ConfigControllerTest extends WallabagCoreTestCase
->getRepository('WallabagCoreBundle:TaggingRule')
->findAll()[0];
$crawler = $client->request('GET', '/tagging-rule/edit/'.$rule->getId());
$crawler = $client->request('GET', '/tagging-rule/edit/' . $rule->getId());
$this->assertEquals(403, $client->getResponse()->getStatusCode());
$this->assertSame(403, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('You can not access this tagging rule', $body[0]);
}
@ -591,7 +591,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/config');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=change_passwd_save]')->form();
@ -603,7 +603,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('flashes.config.notice.password_not_updated_demo', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
$config->set('demo_mode_enabled', 0);
@ -642,7 +642,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$this->assertNotContains('config.form_user.delete.button', $body[0]);
$client->request('GET', '/account/delete');
$this->assertEquals(403, $client->getResponse()->getStatusCode());
$this->assertSame(403, $client->getResponse()->getStatusCode());
$user = $em
->getRepository('WallabagUserBundle:User')
@ -692,7 +692,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
// that this entry is also deleted
$crawler = $client->request('GET', '/new');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
$data = [
@ -700,14 +700,14 @@ class ConfigControllerTest extends WallabagCoreTestCase
];
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->request('GET', '/config');
$deleteLink = $crawler->filter('.delete-account')->last()->link();
$client->click($deleteLink);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
$user = $em
@ -767,11 +767,11 @@ class ConfigControllerTest extends WallabagCoreTestCase
// reset annotations
$crawler = $client->request('GET', '/config#set3');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$crawler = $client->click($crawler->selectLink('config.reset.annotations')->link());
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('flashes.config.notice.annotations_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
$annotationsReset = $em
@ -783,34 +783,34 @@ class ConfigControllerTest extends WallabagCoreTestCase
// reset tags
$crawler = $client->request('GET', '/config#set3');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$crawler = $client->click($crawler->selectLink('config.reset.tags')->link());
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('flashes.config.notice.tags_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
$tagReset = $em
->getRepository('WallabagCoreBundle:Tag')
->countAllTags($user->getId());
$this->assertEquals(0, $tagReset, 'Tags were reset');
$this->assertSame(0, $tagReset, 'Tags were reset');
// reset entries
$crawler = $client->request('GET', '/config#set3');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$crawler = $client->click($crawler->selectLink('config.reset.entries')->link());
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('flashes.config.notice.entries_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
$entryReset = $em
->getRepository('WallabagCoreBundle:Entry')
->countAllEntriesByUser($user->getId());
$this->assertEquals(0, $entryReset, 'Entries were reset');
$this->assertSame(0, $entryReset, 'Entries were reset');
}
public function testResetArchivedEntries()
@ -863,24 +863,24 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/config#set3');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$crawler = $client->click($crawler->selectLink('config.reset.archived')->link());
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('flashes.config.notice.archived_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
$entryReset = $em
->getRepository('WallabagCoreBundle:Entry')
->countAllEntriesByUser($user->getId());
$this->assertEquals(1, $entryReset, 'Entries were reset');
$this->assertSame(1, $entryReset, 'Entries were reset');
$tagReset = $em
->getRepository('WallabagCoreBundle:Tag')
->countAllTags($user->getId());
$this->assertEquals(1, $tagReset, 'Tags were reset');
$this->assertSame(1, $tagReset, 'Tags were reset');
$annotationsReset = $em
->getRepository('WallabagAnnotationBundle:Annotation')
@ -920,24 +920,24 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/config#set3');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$crawler = $client->click($crawler->selectLink('config.reset.entries')->link());
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('flashes.config.notice.entries_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
$entryReset = $em
->getRepository('WallabagCoreBundle:Entry')
->countAllEntriesByUser($user->getId());
$this->assertEquals(0, $entryReset, 'Entries were reset');
$this->assertSame(0, $entryReset, 'Entries were reset');
$tagReset = $em
->getRepository('WallabagCoreBundle:Tag')
->countAllTags($user->getId());
$this->assertEquals(0, $tagReset, 'Tags were reset');
$this->assertSame(0, $tagReset, 'Tags were reset');
$annotationsReset = $em
->getRepository('WallabagAnnotationBundle:Annotation')

View File

@ -33,7 +33,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$client->request('GET', '/new');
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('login', $client->getResponse()->headers->get('location'));
}
@ -45,14 +45,14 @@ class EntryControllerTest extends WallabagCoreTestCase
$client->request('GET', '/unread/list');
$crawler = $client->followRedirect();
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('quickstart.intro.title', $body[0]);
// Test if quickstart is disabled when user has 1 entry
$crawler = $client->request('GET', '/new');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
@ -61,7 +61,7 @@ class EntryControllerTest extends WallabagCoreTestCase
];
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$client->followRedirect();
$crawler = $client->request('GET', '/unread/list');
@ -77,7 +77,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/new');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertCount(1, $crawler->filter('input[type=url]'));
$this->assertCount(1, $crawler->filter('form[name=entry]'));
@ -95,7 +95,7 @@ class EntryControllerTest extends WallabagCoreTestCase
// Good URL
$client->request('GET', '/bookmarklet', ['url' => $this->url]);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$client->followRedirect();
$crawler = $client->request('GET', '/');
$this->assertCount(5, $crawler->filter('div[class=entry]'));
@ -116,15 +116,15 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/new');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
$crawler = $client->submit($form);
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertCount(1, $alert = $crawler->filter('form ul li')->extract(['_text']));
$this->assertEquals('This value should not be blank.', $alert[0]);
$this->assertSame('This value should not be blank.', $alert[0]);
}
/**
@ -137,7 +137,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/new');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
@ -147,7 +147,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
@ -157,11 +157,11 @@ class EntryControllerTest extends WallabagCoreTestCase
$author = $content->getPublishedBy();
$this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
$this->assertEquals($this->url, $content->getUrl());
$this->assertSame($this->url, $content->getUrl());
$this->assertContains('Google', $content->getTitle());
$this->assertEquals('fr', $content->getLanguage());
$this->assertEquals('2015-03-28 15:37:39', $content->getPublishedAt()->format('Y-m-d H:i:s'));
$this->assertEquals('Morgane Tual', $author[0]);
$this->assertSame('fr', $content->getLanguage());
$this->assertSame('2015-03-28 15:37:39', $content->getPublishedAt()->format('Y-m-d H:i:s'));
$this->assertSame('Morgane Tual', $author[0]);
$this->assertArrayHasKey('x-varnish1', $content->getHeaders());
}
@ -173,7 +173,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/new');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
@ -183,7 +183,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
@ -191,10 +191,10 @@ class EntryControllerTest extends WallabagCoreTestCase
->findByUrlAndUserId($url, $this->getLoggedInUserId());
$authors = $content->getPublishedBy();
$this->assertEquals('2017-04-05 19:26:13', $content->getPublishedAt()->format('Y-m-d H:i:s'));
$this->assertEquals('fr', $content->getLanguage());
$this->assertEquals('Raphaël Balenieri, correspondant à Pékin', $authors[0]);
$this->assertEquals('Frédéric Autran, correspondant à New York', $authors[1]);
$this->assertSame('2017-04-05 19:26:13', $content->getPublishedAt()->format('Y-m-d H:i:s'));
$this->assertSame('fr', $content->getLanguage());
$this->assertSame('Raphaël Balenieri, correspondant à Pékin', $authors[0]);
$this->assertSame('Frédéric Autran, correspondant à New York', $authors[1]);
}
public function testPostNewOkUrlExist()
@ -210,7 +210,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/new');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
@ -220,7 +220,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('/view/', $client->getResponse()->getTargetUrl());
}
@ -233,7 +233,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/new');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
@ -245,7 +245,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/new');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
@ -255,7 +255,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('/view/', $client->getResponse()->getTargetUrl());
}
@ -269,7 +269,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/new');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
@ -279,7 +279,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('/', $client->getResponse()->getTargetUrl());
$em = $client->getContainer()
@ -291,7 +291,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->assertCount(2, $tags);
$this->assertContains('wallabag', $tags);
$this->assertEquals('en', $entry->getLanguage());
$this->assertSame('en', $entry->getLanguage());
$em->remove($entry);
$em->flush();
@ -300,7 +300,7 @@ class EntryControllerTest extends WallabagCoreTestCase
// related https://github.com/wallabag/wallabag/issues/2121
$crawler = $client->request('GET', '/new');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
@ -310,7 +310,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('/', $client->getResponse()->getTargetUrl());
$entry = $em
@ -333,7 +333,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$client->request('GET', '/archive/list');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testUntagged()
@ -343,7 +343,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$client->request('GET', '/untagged/list');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testStarred()
@ -353,7 +353,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$client->request('GET', '/starred/list');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testRangeException()
@ -363,8 +363,8 @@ class EntryControllerTest extends WallabagCoreTestCase
$client->request('GET', '/all/list/900');
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertEquals('/all/list', $client->getResponse()->getTargetUrl());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertSame('/all/list', $client->getResponse()->getTargetUrl());
}
public function testView()
@ -379,9 +379,9 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->getEntityManager()->persist($entry);
$this->getEntityManager()->flush();
$crawler = $client->request('GET', '/view/'.$entry->getId());
$crawler = $client->request('GET', '/view/' . $entry->getId());
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains($entry->getTitle(), $body[0]);
}
@ -402,9 +402,9 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->getEntityManager()->flush();
$this->getEntityManager()->clear();
$client->request('GET', '/reload/'.$entry->getId());
$client->request('GET', '/reload/' . $entry->getId());
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$entry = $this->getEntityManager()
->getRepository('WallabagCoreBundle:Entry')
@ -423,9 +423,9 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->getEntityManager()->persist($entry);
$this->getEntityManager()->flush();
$client->request('GET', '/reload/'.$entry->getId());
$client->request('GET', '/reload/' . $entry->getId());
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
// force EntityManager to clear previous entity
// otherwise, retrieve the same entity will retrieve change from the previous request :0
@ -434,7 +434,7 @@ class EntryControllerTest extends WallabagCoreTestCase
->getRepository('WallabagCoreBundle:Entry')
->find($entry->getId());
$this->assertNotEquals($client->getContainer()->getParameter('wallabag_core.fetching_error_message'), $newContent->getContent());
$this->assertNotSame($client->getContainer()->getParameter('wallabag_core.fetching_error_message'), $newContent->getContent());
}
public function testEdit()
@ -447,9 +447,9 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->getEntityManager()->persist($entry);
$this->getEntityManager()->flush();
$crawler = $client->request('GET', '/edit/'.$entry->getId());
$crawler = $client->request('GET', '/edit/' . $entry->getId());
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertCount(1, $crawler->filter('input[id=entry_title]'));
$this->assertCount(1, $crawler->filter('button[id=entry_save]'));
@ -465,9 +465,9 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->getEntityManager()->persist($entry);
$this->getEntityManager()->flush();
$crawler = $client->request('GET', '/edit/'.$entry->getId());
$crawler = $client->request('GET', '/edit/' . $entry->getId());
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[type=submit]')->form();
@ -477,7 +477,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
@ -496,16 +496,16 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->getEntityManager()->flush();
$this->getEntityManager()->clear();
$client->request('GET', '/archive/'.$entry->getId());
$client->request('GET', '/archive/' . $entry->getId());
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$res = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->find($entry->getId());
$this->assertEquals($res->isArchived(), true);
$this->assertSame($res->isArchived(), true);
}
public function testToggleStar()
@ -519,16 +519,16 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->getEntityManager()->flush();
$this->getEntityManager()->clear();
$client->request('GET', '/star/'.$entry->getId());
$client->request('GET', '/star/' . $entry->getId());
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$res = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->findOneById($entry->getId());
$this->assertEquals($res->isStarred(), true);
$this->assertSame($res->isStarred(), true);
}
public function testDelete()
@ -541,13 +541,13 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->getEntityManager()->persist($entry);
$this->getEntityManager()->flush();
$client->request('GET', '/delete/'.$entry->getId());
$client->request('GET', '/delete/' . $entry->getId());
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$client->request('GET', '/delete/'.$entry->getId());
$client->request('GET', '/delete/' . $entry->getId());
$this->assertEquals(404, $client->getResponse()->getStatusCode());
$this->assertSame(404, $client->getResponse()->getStatusCode());
}
/**
@ -583,14 +583,14 @@ class EntryControllerTest extends WallabagCoreTestCase
$em->persist($content);
$em->flush();
$client->request('GET', '/view/'.$content->getId());
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$client->request('GET', '/view/' . $content->getId());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$client->request('GET', '/delete/'.$content->getId());
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$client->request('GET', '/delete/' . $content->getId());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$client->followRedirect();
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testViewOtherUserEntry()
@ -603,9 +603,9 @@ class EntryControllerTest extends WallabagCoreTestCase
->getRepository('WallabagCoreBundle:Entry')
->findOneByUsernameAndNotArchived('bob');
$client->request('GET', '/view/'.$content->getId());
$client->request('GET', '/view/' . $content->getId());
$this->assertEquals(403, $client->getResponse()->getStatusCode());
$this->assertSame(403, $client->getResponse()->getStatusCode());
}
public function testFilterOnReadingTime()
@ -793,7 +793,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$parameters = '?entry_filter%5BreadingTime%5D%5Bleft_number%5D=&entry_filter%5BreadingTime%5D%5Bright_number%5D=';
$client->request('GET', 'unread/list'.$parameters);
$client->request('GET', 'unread/list' . $parameters);
$this->assertContains($parameters, $client->getResponse()->getContent());
@ -934,16 +934,16 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->getEntityManager()->clear();
// no uid
$client->request('GET', '/share/'.$content->getUid());
$this->assertEquals(404, $client->getResponse()->getStatusCode());
$client->request('GET', '/share/' . $content->getUid());
$this->assertSame(404, $client->getResponse()->getStatusCode());
// generating the uid
$client->request('GET', '/share/'.$content->getId());
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$client->request('GET', '/share/' . $content->getId());
$this->assertSame(302, $client->getResponse()->getStatusCode());
// follow link with uid
$crawler = $client->followRedirect();
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertContains('max-age=25200', $client->getResponse()->headers->get('cache-control'));
$this->assertContains('public', $client->getResponse()->headers->get('cache-control'));
$this->assertContains('s-maxage=25200', $client->getResponse()->headers->get('cache-control'));
@ -955,19 +955,19 @@ class EntryControllerTest extends WallabagCoreTestCase
// sharing is now disabled
$client->getContainer()->get('craue_config')->set('share_public', 0);
$client->request('GET', '/share/'.$content->getUid());
$this->assertEquals(404, $client->getResponse()->getStatusCode());
$client->request('GET', '/share/' . $content->getUid());
$this->assertSame(404, $client->getResponse()->getStatusCode());
$client->request('GET', '/view/'.$content->getId());
$client->request('GET', '/view/' . $content->getId());
$this->assertContains('no-cache', $client->getResponse()->headers->get('cache-control'));
// removing the share
$client->request('GET', '/share/delete/'.$content->getId());
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$client->request('GET', '/share/delete/' . $content->getId());
$this->assertSame(302, $client->getResponse()->getStatusCode());
// share is now disable
$client->request('GET', '/share/'.$content->getUid());
$this->assertEquals(404, $client->getResponse()->getStatusCode());
$client->request('GET', '/share/' . $content->getUid());
$this->assertSame(404, $client->getResponse()->getStatusCode());
}
public function testNewEntryWithDownloadImagesEnabled()
@ -981,7 +981,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/new');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
@ -991,7 +991,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$em = $client->getContainer()
->get('doctrine.orm.entity_manager');
@ -1001,7 +1001,7 @@ class EntryControllerTest extends WallabagCoreTestCase
->findByUrlAndUserId($url, $this->getLoggedInUserId());
$this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $entry);
$this->assertEquals($url, $entry->getUrl());
$this->assertSame($url, $entry->getUrl());
$this->assertContains('Perpignan', $entry->getTitle());
// instead of checking for the filename (which might change) check that the image is now local
$this->assertContains('https://your-wallabag-url-instance.com/assets/images/', $entry->getContent());
@ -1023,7 +1023,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/new');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
@ -1033,16 +1033,16 @@ class EntryControllerTest extends WallabagCoreTestCase
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->findByUrlAndUserId($url, $this->getLoggedInUserId());
$client->request('GET', '/delete/'.$content->getId());
$client->request('GET', '/delete/' . $content->getId());
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$client->getContainer()->get('craue_config')->set('download_images_enabled', 0);
}
@ -1063,11 +1063,11 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->getEntityManager()->flush();
$client->request('GET', '/view/'.$entry->getId());
$client->request('GET', '/archive/'.$entry->getId());
$client->request('GET', '/view/' . $entry->getId());
$client->request('GET', '/archive/' . $entry->getId());
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertEquals('/', $client->getResponse()->headers->get('location'));
$this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertSame('/', $client->getResponse()->headers->get('location'));
}
public function testRedirectToCurrentPage()
@ -1086,11 +1086,11 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->getEntityManager()->flush();
$client->request('GET', '/view/'.$entry->getId());
$client->request('GET', '/archive/'.$entry->getId());
$client->request('GET', '/view/' . $entry->getId());
$client->request('GET', '/archive/' . $entry->getId());
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertContains('/view/'.$entry->getId(), $client->getResponse()->headers->get('location'));
$this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('/view/' . $entry->getId(), $client->getResponse()->headers->get('location'));
}
public function testFilterOnHttpStatus()
@ -1213,7 +1213,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->submit($form, $data);
$this->assertCount(1, $crawler->filter('div[class=entry]'));
$client->request('GET', '/delete/'.$entry->getId());
$client->request('GET', '/delete/' . $entry->getId());
// test on list of all articles
$crawler = $client->request('GET', '/all/list');
@ -1315,7 +1315,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/new');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
@ -1325,7 +1325,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
@ -1333,8 +1333,8 @@ class EntryControllerTest extends WallabagCoreTestCase
->findByUrlAndUserId($url, $this->getLoggedInUserId());
$this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
$this->assertEquals($url, $content->getUrl());
$this->assertEquals($expectedLanguage, $content->getLanguage());
$this->assertSame($url, $content->getUrl());
$this->assertSame($expectedLanguage, $content->getLanguage());
}
/**
@ -1362,7 +1362,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/new');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
@ -1372,11 +1372,11 @@ class EntryControllerTest extends WallabagCoreTestCase
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertContains('flashes.entry.notice.entry_saved', $crawler->filter('body')->extract(['_text'])[0]);
$content = $em

View File

@ -12,7 +12,7 @@ class ExportControllerTest extends WallabagCoreTestCase
$client->request('GET', '/export/unread.csv');
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('login', $client->getResponse()->headers->get('location'));
}
@ -23,7 +23,7 @@ class ExportControllerTest extends WallabagCoreTestCase
$client->request('GET', '/export/awesomeness.epub');
$this->assertEquals(404, $client->getResponse()->getStatusCode());
$this->assertSame(404, $client->getResponse()->getStatusCode());
}
public function testUnknownFormatExport()
@ -33,7 +33,7 @@ class ExportControllerTest extends WallabagCoreTestCase
$client->request('GET', '/export/unread.xslx');
$this->assertEquals(404, $client->getResponse()->getStatusCode());
$this->assertSame(404, $client->getResponse()->getStatusCode());
}
public function testUnsupportedFormatExport()
@ -42,15 +42,15 @@ class ExportControllerTest extends WallabagCoreTestCase
$client = $this->getClient();
$client->request('GET', '/export/unread.doc');
$this->assertEquals(404, $client->getResponse()->getStatusCode());
$this->assertSame(404, $client->getResponse()->getStatusCode());
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->findOneByUsernameAndNotArchived('admin');
$client->request('GET', '/export/'.$content->getId().'.doc');
$this->assertEquals(404, $client->getResponse()->getStatusCode());
$client->request('GET', '/export/' . $content->getId() . '.doc');
$this->assertSame(404, $client->getResponse()->getStatusCode());
}
public function testBadEntryId()
@ -60,7 +60,7 @@ class ExportControllerTest extends WallabagCoreTestCase
$client->request('GET', '/export/0.mobi');
$this->assertEquals(404, $client->getResponse()->getStatusCode());
$this->assertSame(404, $client->getResponse()->getStatusCode());
}
public function testEpubExport()
@ -72,12 +72,12 @@ class ExportControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/export/archive.epub');
ob_end_clean();
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$headers = $client->getResponse()->headers;
$this->assertEquals('application/epub+zip', $headers->get('content-type'));
$this->assertEquals('attachment; filename="Archive articles.epub"', $headers->get('content-disposition'));
$this->assertEquals('binary', $headers->get('content-transfer-encoding'));
$this->assertSame('application/epub+zip', $headers->get('content-type'));
$this->assertSame('attachment; filename="Archive articles.epub"', $headers->get('content-disposition'));
$this->assertSame('binary', $headers->get('content-transfer-encoding'));
}
public function testMobiExport()
@ -91,15 +91,15 @@ class ExportControllerTest extends WallabagCoreTestCase
->findOneByUsernameAndNotArchived('admin');
ob_start();
$crawler = $client->request('GET', '/export/'.$content->getId().'.mobi');
$crawler = $client->request('GET', '/export/' . $content->getId() . '.mobi');
ob_end_clean();
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$headers = $client->getResponse()->headers;
$this->assertEquals('application/x-mobipocket-ebook', $headers->get('content-type'));
$this->assertEquals('attachment; filename="'.preg_replace('/[^A-Za-z0-9\-]/', '', $content->getTitle()).'.mobi"', $headers->get('content-disposition'));
$this->assertEquals('binary', $headers->get('content-transfer-encoding'));
$this->assertSame('application/x-mobipocket-ebook', $headers->get('content-type'));
$this->assertSame('attachment; filename="' . preg_replace('/[^A-Za-z0-9\-]/', '', $content->getTitle()) . '.mobi"', $headers->get('content-disposition'));
$this->assertSame('binary', $headers->get('content-transfer-encoding'));
}
public function testPdfExport()
@ -111,23 +111,23 @@ class ExportControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/export/all.pdf');
ob_end_clean();
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$headers = $client->getResponse()->headers;
$this->assertEquals('application/pdf', $headers->get('content-type'));
$this->assertEquals('attachment; filename="All articles.pdf"', $headers->get('content-disposition'));
$this->assertEquals('binary', $headers->get('content-transfer-encoding'));
$this->assertSame('application/pdf', $headers->get('content-type'));
$this->assertSame('attachment; filename="All articles.pdf"', $headers->get('content-disposition'));
$this->assertSame('binary', $headers->get('content-transfer-encoding'));
ob_start();
$crawler = $client->request('GET', '/export/tag_entries.pdf?tag=foo-bar');
ob_end_clean();
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$headers = $client->getResponse()->headers;
$this->assertEquals('application/pdf', $headers->get('content-type'));
$this->assertEquals('attachment; filename="Tag_entries articles.pdf"', $headers->get('content-disposition'));
$this->assertEquals('binary', $headers->get('content-transfer-encoding'));
$this->assertSame('application/pdf', $headers->get('content-type'));
$this->assertSame('attachment; filename="Tag_entries articles.pdf"', $headers->get('content-disposition'));
$this->assertSame('binary', $headers->get('content-transfer-encoding'));
}
public function testTxtExport()
@ -139,12 +139,12 @@ class ExportControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/export/all.txt');
ob_end_clean();
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$headers = $client->getResponse()->headers;
$this->assertEquals('text/plain; charset=UTF-8', $headers->get('content-type'));
$this->assertEquals('attachment; filename="All articles.txt"', $headers->get('content-disposition'));
$this->assertEquals('UTF-8', $headers->get('content-transfer-encoding'));
$this->assertSame('text/plain; charset=UTF-8', $headers->get('content-type'));
$this->assertSame('attachment; filename="All articles.txt"', $headers->get('content-disposition'));
$this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
}
public function testCsvExport()
@ -169,19 +169,19 @@ class ExportControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/export/archive.csv');
ob_end_clean();
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$headers = $client->getResponse()->headers;
$this->assertEquals('application/csv', $headers->get('content-type'));
$this->assertEquals('attachment; filename="Archive articles.csv"', $headers->get('content-disposition'));
$this->assertEquals('UTF-8', $headers->get('content-transfer-encoding'));
$this->assertSame('application/csv', $headers->get('content-type'));
$this->assertSame('attachment; filename="Archive articles.csv"', $headers->get('content-disposition'));
$this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
$csv = str_getcsv($client->getResponse()->getContent(), "\n");
$this->assertGreaterThan(1, $csv);
// +1 for title line
$this->assertEquals(count($contentInDB) + 1, count($csv));
$this->assertEquals('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]);
$this->assertSame(count($contentInDB) + 1, count($csv));
$this->assertSame('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]);
$this->assertContains($contentInDB[0]['title'], $csv[1]);
$this->assertContains($contentInDB[0]['url'], $csv[1]);
$this->assertContains($contentInDB[0]['content'], $csv[1]);
@ -205,15 +205,15 @@ class ExportControllerTest extends WallabagCoreTestCase
->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId());
ob_start();
$crawler = $client->request('GET', '/export/'.$contentInDB->getId().'.json');
$crawler = $client->request('GET', '/export/' . $contentInDB->getId() . '.json');
ob_end_clean();
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$headers = $client->getResponse()->headers;
$this->assertEquals('application/json', $headers->get('content-type'));
$this->assertEquals('attachment; filename="'.$contentInDB->getTitle().'.json"', $headers->get('content-disposition'));
$this->assertEquals('UTF-8', $headers->get('content-transfer-encoding'));
$this->assertSame('application/json', $headers->get('content-type'));
$this->assertSame('attachment; filename="' . $contentInDB->getTitle() . '.json"', $headers->get('content-disposition'));
$this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
$content = json_decode($client->getResponse()->getContent(), true);
$this->assertArrayHasKey('id', $content[0]);
@ -230,16 +230,16 @@ class ExportControllerTest extends WallabagCoreTestCase
$this->assertArrayHasKey('created_at', $content[0]);
$this->assertArrayHasKey('updated_at', $content[0]);
$this->assertEquals($contentInDB->isArchived(), $content[0]['is_archived']);
$this->assertEquals($contentInDB->isStarred(), $content[0]['is_starred']);
$this->assertEquals($contentInDB->getTitle(), $content[0]['title']);
$this->assertEquals($contentInDB->getUrl(), $content[0]['url']);
$this->assertEquals([['text' => 'This is my annotation /o/', 'quote' => 'content']], $content[0]['annotations']);
$this->assertEquals($contentInDB->getMimetype(), $content[0]['mimetype']);
$this->assertEquals($contentInDB->getLanguage(), $content[0]['language']);
$this->assertEquals($contentInDB->getReadingtime(), $content[0]['reading_time']);
$this->assertEquals($contentInDB->getDomainname(), $content[0]['domain_name']);
$this->assertEquals(['foo bar', 'baz'], $content[0]['tags']);
$this->assertSame($contentInDB->isArchived(), $content[0]['is_archived']);
$this->assertSame($contentInDB->isStarred(), $content[0]['is_starred']);
$this->assertSame($contentInDB->getTitle(), $content[0]['title']);
$this->assertSame($contentInDB->getUrl(), $content[0]['url']);
$this->assertSame([['text' => 'This is my annotation /o/', 'quote' => 'content']], $content[0]['annotations']);
$this->assertSame($contentInDB->getMimetype(), $content[0]['mimetype']);
$this->assertSame($contentInDB->getLanguage(), $content[0]['language']);
$this->assertSame($contentInDB->getReadingtime(), $content[0]['reading_time']);
$this->assertSame($contentInDB->getDomainname(), $content[0]['domain_name']);
$this->assertSame(['foo bar', 'baz'], $content[0]['tags']);
}
public function testXmlExport()
@ -262,16 +262,16 @@ class ExportControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/export/unread.xml');
ob_end_clean();
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$headers = $client->getResponse()->headers;
$this->assertEquals('application/xml', $headers->get('content-type'));
$this->assertEquals('attachment; filename="Unread articles.xml"', $headers->get('content-disposition'));
$this->assertEquals('UTF-8', $headers->get('content-transfer-encoding'));
$this->assertSame('application/xml', $headers->get('content-type'));
$this->assertSame('attachment; filename="Unread articles.xml"', $headers->get('content-disposition'));
$this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
$content = new \SimpleXMLElement($client->getResponse()->getContent());
$this->assertGreaterThan(0, $content->count());
$this->assertEquals(count($contentInDB), $content->count());
$this->assertSame(count($contentInDB), $content->count());
$this->assertNotEmpty('id', (string) $content->entry[0]->id);
$this->assertNotEmpty('title', (string) $content->entry[0]->title);
$this->assertNotEmpty('url', (string) $content->entry[0]->url);

View File

@ -16,36 +16,36 @@ class RssControllerTest extends WallabagCoreTestCase
if (null === $nb) {
$this->assertGreaterThan(0, $xpath->query('//item')->length);
} else {
$this->assertEquals($nb, $xpath->query('//item')->length);
$this->assertSame($nb, $xpath->query('//item')->length);
}
$this->assertEquals(1, $xpath->query('/rss')->length);
$this->assertEquals(1, $xpath->query('/rss/channel')->length);
$this->assertSame(1, $xpath->query('/rss')->length);
$this->assertSame(1, $xpath->query('/rss/channel')->length);
$this->assertEquals(1, $xpath->query('/rss/channel/title')->length);
$this->assertEquals('wallabag - '.$type.' feed', $xpath->query('/rss/channel/title')->item(0)->nodeValue);
$this->assertSame(1, $xpath->query('/rss/channel/title')->length);
$this->assertSame('wallabag - ' . $type . ' feed', $xpath->query('/rss/channel/title')->item(0)->nodeValue);
$this->assertEquals(1, $xpath->query('/rss/channel/pubDate')->length);
$this->assertSame(1, $xpath->query('/rss/channel/pubDate')->length);
$this->assertEquals(1, $xpath->query('/rss/channel/generator')->length);
$this->assertEquals('wallabag', $xpath->query('/rss/channel/generator')->item(0)->nodeValue);
$this->assertSame(1, $xpath->query('/rss/channel/generator')->length);
$this->assertSame('wallabag', $xpath->query('/rss/channel/generator')->item(0)->nodeValue);
$this->assertEquals(1, $xpath->query('/rss/channel/description')->length);
$this->assertEquals('wallabag '.$type.' elements', $xpath->query('/rss/channel/description')->item(0)->nodeValue);
$this->assertSame(1, $xpath->query('/rss/channel/description')->length);
$this->assertSame('wallabag ' . $type . ' elements', $xpath->query('/rss/channel/description')->item(0)->nodeValue);
$this->assertEquals(1, $xpath->query('/rss/channel/link[@rel="self"]')->length);
$this->assertContains($urlPagination.'.xml', $xpath->query('/rss/channel/link[@rel="self"]')->item(0)->getAttribute('href'));
$this->assertSame(1, $xpath->query('/rss/channel/link[@rel="self"]')->length);
$this->assertContains($urlPagination . '.xml', $xpath->query('/rss/channel/link[@rel="self"]')->item(0)->getAttribute('href'));
$this->assertEquals(1, $xpath->query('/rss/channel/link[@rel="last"]')->length);
$this->assertContains($urlPagination.'.xml?page=', $xpath->query('/rss/channel/link[@rel="last"]')->item(0)->getAttribute('href'));
$this->assertSame(1, $xpath->query('/rss/channel/link[@rel="last"]')->length);
$this->assertContains($urlPagination . '.xml?page=', $xpath->query('/rss/channel/link[@rel="last"]')->item(0)->getAttribute('href'));
foreach ($xpath->query('//item') as $item) {
$this->assertEquals(1, $xpath->query('title', $item)->length);
$this->assertEquals(1, $xpath->query('source', $item)->length);
$this->assertEquals(1, $xpath->query('link', $item)->length);
$this->assertEquals(1, $xpath->query('guid', $item)->length);
$this->assertEquals(1, $xpath->query('pubDate', $item)->length);
$this->assertEquals(1, $xpath->query('description', $item)->length);
$this->assertSame(1, $xpath->query('title', $item)->length);
$this->assertSame(1, $xpath->query('source', $item)->length);
$this->assertSame(1, $xpath->query('link', $item)->length);
$this->assertSame(1, $xpath->query('guid', $item)->length);
$this->assertSame(1, $xpath->query('pubDate', $item)->length);
$this->assertSame(1, $xpath->query('description', $item)->length);
}
}
@ -73,7 +73,7 @@ class RssControllerTest extends WallabagCoreTestCase
$client->request('GET', $url);
$this->assertEquals(404, $client->getResponse()->getStatusCode());
$this->assertSame(404, $client->getResponse()->getStatusCode());
}
public function testUnread()
@ -92,7 +92,7 @@ class RssControllerTest extends WallabagCoreTestCase
$client->request('GET', '/admin/SUPERTOKEN/unread.xml');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->validateDom($client->getResponse()->getContent(), 'unread', 'unread', 2);
}
@ -114,7 +114,7 @@ class RssControllerTest extends WallabagCoreTestCase
$client = $this->getClient();
$client->request('GET', '/admin/SUPERTOKEN/starred.xml');
$this->assertEquals(200, $client->getResponse()->getStatusCode(), 1);
$this->assertSame(200, $client->getResponse()->getStatusCode(), 1);
$this->validateDom($client->getResponse()->getContent(), 'starred', 'starred');
}
@ -136,7 +136,7 @@ class RssControllerTest extends WallabagCoreTestCase
$client = $this->getClient();
$client->request('GET', '/admin/SUPERTOKEN/archive.xml');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->validateDom($client->getResponse()->getContent(), 'archive', 'archive');
}
@ -158,15 +158,15 @@ class RssControllerTest extends WallabagCoreTestCase
$client = $this->getClient();
$client->request('GET', '/admin/SUPERTOKEN/unread.xml');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->validateDom($client->getResponse()->getContent(), 'unread', 'unread');
$client->request('GET', '/admin/SUPERTOKEN/unread.xml?page=2');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->validateDom($client->getResponse()->getContent(), 'unread', 'unread');
$client->request('GET', '/admin/SUPERTOKEN/unread.xml?page=3000');
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
}
public function testTags()
@ -186,11 +186,11 @@ class RssControllerTest extends WallabagCoreTestCase
$client = $this->getClient();
$client->request('GET', '/admin/SUPERTOKEN/tags/foo-bar.xml');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->validateDom($client->getResponse()->getContent(), 'tag (foo bar)', 'tags/foo-bar');
$client->request('GET', '/admin/SUPERTOKEN/tags/foo-bar.xml?page=3000');
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
}
}

View File

@ -17,7 +17,7 @@ class SettingsControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/settings');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testSettingsWithNormalUser()
@ -27,6 +27,6 @@ class SettingsControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/settings');
$this->assertEquals(403, $client->getResponse()->getStatusCode());
$this->assertSame(403, $client->getResponse()->getStatusCode());
}
}

View File

@ -15,7 +15,7 @@ class SiteCredentialControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/site-credentials/');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$body = $crawler->filter('body')->extract(['_text'])[0];
@ -30,7 +30,7 @@ class SiteCredentialControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/site-credentials/new');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$body = $crawler->filter('body')->extract(['_text'])[0];
@ -47,7 +47,7 @@ class SiteCredentialControllerTest extends WallabagCoreTestCase
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
@ -61,9 +61,9 @@ class SiteCredentialControllerTest extends WallabagCoreTestCase
$credential = $this->createSiteCredential($client);
$crawler = $client->request('GET', '/site-credentials/'.$credential->getId().'/edit');
$crawler = $client->request('GET', '/site-credentials/' . $credential->getId() . '/edit');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$body = $crawler->filter('body')->extract(['_text'])[0];
@ -80,7 +80,7 @@ class SiteCredentialControllerTest extends WallabagCoreTestCase
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
@ -96,9 +96,9 @@ class SiteCredentialControllerTest extends WallabagCoreTestCase
$this->logInAs('bob');
$client->request('GET', '/site-credentials/'.$credential->getId().'/edit');
$client->request('GET', '/site-credentials/' . $credential->getId() . '/edit');
$this->assertEquals(403, $client->getResponse()->getStatusCode());
$this->assertSame(403, $client->getResponse()->getStatusCode());
}
public function testDeleteSiteCredential()
@ -108,15 +108,15 @@ class SiteCredentialControllerTest extends WallabagCoreTestCase
$credential = $this->createSiteCredential($client);
$crawler = $client->request('GET', '/site-credentials/'.$credential->getId().'/edit');
$crawler = $client->request('GET', '/site-credentials/' . $credential->getId() . '/edit');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$deleteForm = $crawler->filter('body')->selectButton('site_credential.form.delete')->form();
$client->submit($deleteForm, []);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();

View File

@ -13,7 +13,7 @@ class StaticControllerTest extends WallabagCoreTestCase
$client->request('GET', '/about');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testHowto()
@ -23,6 +23,6 @@ class StaticControllerTest extends WallabagCoreTestCase
$client->request('GET', '/howto');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
}
}

View File

@ -17,7 +17,7 @@ class TagControllerTest extends WallabagCoreTestCase
$client->request('GET', '/tag/list');
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testAddTagToEntry()
@ -31,7 +31,7 @@ class TagControllerTest extends WallabagCoreTestCase
$this->getEntityManager()->flush();
$this->getEntityManager()->clear();
$crawler = $client->request('GET', '/view/'.$entry->getId());
$crawler = $client->request('GET', '/view/' . $entry->getId());
$form = $crawler->filter('form[name=tag]')->form();
@ -40,7 +40,7 @@ class TagControllerTest extends WallabagCoreTestCase
];
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
// be sure to reload the entry
$entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId());
@ -48,7 +48,7 @@ class TagControllerTest extends WallabagCoreTestCase
// tag already exists and already assigned
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId());
$this->assertCount(1, $entry->getTags());
@ -59,7 +59,7 @@ class TagControllerTest extends WallabagCoreTestCase
];
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId());
$this->assertCount(2, $entry->getTags());
@ -75,7 +75,7 @@ class TagControllerTest extends WallabagCoreTestCase
->getRepository('WallabagCoreBundle:Entry')
->findByUrlAndUserId('http://0.0.0.0/entry2', $this->getLoggedInUserId());
$crawler = $client->request('GET', '/view/'.$entry->getId());
$crawler = $client->request('GET', '/view/' . $entry->getId());
$form = $crawler->filter('form[name=tag]')->form();
@ -84,7 +84,7 @@ class TagControllerTest extends WallabagCoreTestCase
];
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$newEntry = $client->getContainer()
->get('doctrine.orm.entity_manager')
@ -97,8 +97,8 @@ class TagControllerTest extends WallabagCoreTestCase
}
$this->assertGreaterThanOrEqual(2, count($tags));
$this->assertNotFalse(array_search('foo2', $tags), 'Tag foo2 is assigned to the entry');
$this->assertNotFalse(array_search('bar2', $tags), 'Tag bar2 is assigned to the entry');
$this->assertNotFalse(array_search('foo2', $tags, true), 'Tag foo2 is assigned to the entry');
$this->assertNotFalse(array_search('bar2', $tags, true), 'Tag bar2 is assigned to the entry');
}
public function testRemoveTagFromEntry()
@ -116,27 +116,27 @@ class TagControllerTest extends WallabagCoreTestCase
$this->getEntityManager()->clear();
// We make a first request to set an history and test redirection after tag deletion
$client->request('GET', '/view/'.$entry->getId());
$client->request('GET', '/view/' . $entry->getId());
$entryUri = $client->getRequest()->getUri();
$client->request('GET', '/remove-tag/'.$entry->getId().'/'.$tag->getId());
$client->request('GET', '/remove-tag/' . $entry->getId() . '/' . $tag->getId());
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertEquals($entryUri, $client->getResponse()->getTargetUrl());
$this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertSame($entryUri, $client->getResponse()->getTargetUrl());
// re-retrieve the entry to be sure to get fresh data from database (mostly for tags)
$entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId());
$this->assertNotContains($this->tagName, $entry->getTags());
$client->request('GET', '/remove-tag/'.$entry->getId().'/'.$tag->getId());
$client->request('GET', '/remove-tag/' . $entry->getId() . '/' . $tag->getId());
$this->assertEquals(404, $client->getResponse()->getStatusCode());
$this->assertSame(404, $client->getResponse()->getStatusCode());
$tag = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Tag')
->findOneByLabel($this->tagName);
$this->assertNull($tag, $this->tagName.' was removed because it begun an orphan tag');
$this->assertNull($tag, $this->tagName . ' was removed because it begun an orphan tag');
}
public function testShowEntriesForTagAction()
@ -165,9 +165,9 @@ class TagControllerTest extends WallabagCoreTestCase
->getRepository('WallabagCoreBundle:Tag')
->findOneByEntryAndTagLabel($entry, $this->tagName);
$crawler = $client->request('GET', '/tag/list/'.$tag->getSlug());
$crawler = $client->request('GET', '/tag/list/' . $tag->getSlug());
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertCount(1, $crawler->filter('[id*="entry-"]'));
$entry->removeTag($tag);

View File

@ -13,15 +13,6 @@ use Wallabag\CoreBundle\Event\Listener\LocaleListener;
class LocaleListenerTest extends \PHPUnit_Framework_TestCase
{
private function getEvent(Request $request)
{
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')
->disableOriginalConstructor()
->getMock();
return new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
}
public function testWithoutSession()
{
$request = Request::create('/');
@ -30,7 +21,7 @@ class LocaleListenerTest extends \PHPUnit_Framework_TestCase
$event = $this->getEvent($request);
$listener->onKernelRequest($event);
$this->assertEquals('en', $request->getLocale());
$this->assertSame('en', $request->getLocale());
}
public function testWithPreviousSession()
@ -44,7 +35,7 @@ class LocaleListenerTest extends \PHPUnit_Framework_TestCase
$event = $this->getEvent($request);
$listener->onKernelRequest($event);
$this->assertEquals('fr', $request->getLocale());
$this->assertSame('fr', $request->getLocale());
}
public function testLocaleFromRequestAttribute()
@ -59,8 +50,8 @@ class LocaleListenerTest extends \PHPUnit_Framework_TestCase
$event = $this->getEvent($request);
$listener->onKernelRequest($event);
$this->assertEquals('en', $request->getLocale());
$this->assertEquals('es', $request->getSession()->get('_locale'));
$this->assertSame('en', $request->getLocale());
$this->assertSame('es', $request->getSession()->get('_locale'));
}
public function testSubscribedEvents()
@ -81,6 +72,15 @@ class LocaleListenerTest extends \PHPUnit_Framework_TestCase
$event
);
$this->assertEquals('fr', $request->getLocale());
$this->assertSame('fr', $request->getLocale());
}
private function getEvent(Request $request)
{
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')
->disableOriginalConstructor()
->getMock();
return new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
}
}

View File

@ -32,7 +32,7 @@ class UserLocaleListenerTest extends \PHPUnit_Framework_TestCase
$listener->onInteractiveLogin($event);
$this->assertEquals('fr', $session->get('_locale'));
$this->assertSame('fr', $session->get('_locale'));
}
public function testWithoutLanguage()
@ -53,6 +53,6 @@ class UserLocaleListenerTest extends \PHPUnit_Framework_TestCase
$listener->onInteractiveLogin($event);
$this->assertEquals('', $session->get('_locale'));
$this->assertSame('', $session->get('_locale'));
}
}

View File

@ -46,12 +46,12 @@ class TablePrefixSubscriberTest extends \PHPUnit_Framework_TestCase
$metaDataEvent = new LoadClassMetadataEventArgs($metaClass, $em);
$this->assertEquals($tableNameExpected, $metaDataEvent->getClassMetadata()->getTableName());
$this->assertSame($tableNameExpected, $metaDataEvent->getClassMetadata()->getTableName());
$subscriber->loadClassMetadata($metaDataEvent);
$this->assertEquals($finalTableName, $metaDataEvent->getClassMetadata()->getTableName());
$this->assertEquals($finalTableNameQuoted, $metaDataEvent->getClassMetadata()->getQuotedTableName($platform));
$this->assertSame($finalTableName, $metaDataEvent->getClassMetadata()->getTableName());
$this->assertSame($finalTableNameQuoted, $metaDataEvent->getClassMetadata()->getQuotedTableName($platform));
}
/**
@ -75,8 +75,8 @@ class TablePrefixSubscriberTest extends \PHPUnit_Framework_TestCase
$evm->dispatchEvent('loadClassMetadata', $metaDataEvent);
$this->assertEquals($finalTableName, $metaDataEvent->getClassMetadata()->getTableName());
$this->assertEquals($finalTableNameQuoted, $metaDataEvent->getClassMetadata()->getQuotedTableName($platform));
$this->assertSame($finalTableName, $metaDataEvent->getClassMetadata()->getTableName());
$this->assertSame($finalTableNameQuoted, $metaDataEvent->getClassMetadata()->getQuotedTableName($platform));
}
public function testPrefixManyToMany()
@ -103,12 +103,12 @@ class TablePrefixSubscriberTest extends \PHPUnit_Framework_TestCase
$metaDataEvent = new LoadClassMetadataEventArgs($metaClass, $em);
$this->assertEquals('entry', $metaDataEvent->getClassMetadata()->getTableName());
$this->assertSame('entry', $metaDataEvent->getClassMetadata()->getTableName());
$subscriber->loadClassMetadata($metaDataEvent);
$this->assertEquals('yo_entry', $metaDataEvent->getClassMetadata()->getTableName());
$this->assertEquals('yo_entry_tag', $metaDataEvent->getClassMetadata()->associationMappings['tags']['joinTable']['name']);
$this->assertEquals('yo_entry', $metaDataEvent->getClassMetadata()->getQuotedTableName(new \Doctrine\DBAL\Platforms\MySqlPlatform()));
$this->assertSame('yo_entry', $metaDataEvent->getClassMetadata()->getTableName());
$this->assertSame('yo_entry_tag', $metaDataEvent->getClassMetadata()->associationMappings['tags']['joinTable']['name']);
$this->assertSame('yo_entry', $metaDataEvent->getClassMetadata()->getQuotedTableName(new \Doctrine\DBAL\Platforms\MySqlPlatform()));
}
}

View File

@ -2,13 +2,13 @@
namespace Tests\Wallabag\CoreBundle\GuzzleSiteAuthenticator;
use Monolog\Handler\TestHandler;
use Monolog\Logger;
use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig;
use Graby\SiteConfig\SiteConfig as GrabySiteConfig;
use Wallabag\CoreBundle\GuzzleSiteAuthenticator\GrabySiteConfigBuilder;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Monolog\Handler\TestHandler;
use Monolog\Logger;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Wallabag\CoreBundle\GuzzleSiteAuthenticator\GrabySiteConfigBuilder;
class GrabySiteConfigBuilderTest extends \PHPUnit_Framework_TestCase
{
@ -68,7 +68,7 @@ class GrabySiteConfigBuilderTest extends \PHPUnit_Framework_TestCase
$config = $this->builder->buildForHost('www.example.com');
$this->assertEquals(
$this->assertSame(
new SiteConfig([
'host' => 'example.com',
'requiresLogin' => true,

View File

@ -2,18 +2,18 @@
namespace Tests\Wallabag\CoreBundle\Helper;
use Psr\Log\NullLogger;
use Monolog\Logger;
use Graby\Graby;
use Monolog\Handler\TestHandler;
use Wallabag\CoreBundle\Helper\ContentProxy;
use Monolog\Logger;
use Psr\Log\NullLogger;
use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Component\Validator\Validator\RecursiveValidator;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\UserBundle\Entity\User;
use Wallabag\CoreBundle\Helper\ContentProxy;
use Wallabag\CoreBundle\Helper\RuleBasedTagger;
use Graby\Graby;
use Symfony\Component\Validator\Validator\RecursiveValidator;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Component\Validator\ConstraintViolation;
use Wallabag\UserBundle\Entity\User;
class ContentProxyTest extends \PHPUnit_Framework_TestCase
{
@ -44,14 +44,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
$entry = new Entry(new User());
$proxy->updateEntry($entry, 'http://user@:80');
$this->assertEquals('http://user@:80', $entry->getUrl());
$this->assertSame('http://user@:80', $entry->getUrl());
$this->assertEmpty($entry->getTitle());
$this->assertEquals($this->fetchingErrorMessage, $entry->getContent());
$this->assertSame($this->fetchingErrorMessage, $entry->getContent());
$this->assertEmpty($entry->getPreviewPicture());
$this->assertEmpty($entry->getMimetype());
$this->assertEmpty($entry->getLanguage());
$this->assertEquals(0.0, $entry->getReadingTime());
$this->assertEquals(false, $entry->getDomainName());
$this->assertSame(0.0, $entry->getReadingTime());
$this->assertSame(false, $entry->getDomainName());
}
public function testWithEmptyContent()
@ -79,14 +79,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
$entry = new Entry(new User());
$proxy->updateEntry($entry, 'http://0.0.0.0');
$this->assertEquals('http://0.0.0.0', $entry->getUrl());
$this->assertSame('http://0.0.0.0', $entry->getUrl());
$this->assertEmpty($entry->getTitle());
$this->assertEquals($this->fetchingErrorMessage, $entry->getContent());
$this->assertSame($this->fetchingErrorMessage, $entry->getContent());
$this->assertEmpty($entry->getPreviewPicture());
$this->assertEmpty($entry->getMimetype());
$this->assertEmpty($entry->getLanguage());
$this->assertEquals(0.0, $entry->getReadingTime());
$this->assertEquals('0.0.0.0', $entry->getDomainName());
$this->assertSame(0.0, $entry->getReadingTime());
$this->assertSame('0.0.0.0', $entry->getDomainName());
}
public function testWithEmptyContentButOG()
@ -119,15 +119,15 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
$entry = new Entry(new User());
$proxy->updateEntry($entry, 'http://domain.io');
$this->assertEquals('http://domain.io', $entry->getUrl());
$this->assertEquals('my title', $entry->getTitle());
$this->assertEquals($this->fetchingErrorMessage.'<p><i>But we found a short description: </i></p>desc', $entry->getContent());
$this->assertSame('http://domain.io', $entry->getUrl());
$this->assertSame('my title', $entry->getTitle());
$this->assertSame($this->fetchingErrorMessage . '<p><i>But we found a short description: </i></p>desc', $entry->getContent());
$this->assertEmpty($entry->getPreviewPicture());
$this->assertEmpty($entry->getLanguage());
$this->assertEmpty($entry->getHttpStatus());
$this->assertEmpty($entry->getMimetype());
$this->assertEquals(0.0, $entry->getReadingTime());
$this->assertEquals('domain.io', $entry->getDomainName());
$this->assertSame(0.0, $entry->getReadingTime());
$this->assertSame('domain.io', $entry->getDomainName());
}
public function testWithContent()
@ -161,15 +161,15 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
$entry = new Entry(new User());
$proxy->updateEntry($entry, 'http://0.0.0.0');
$this->assertEquals('http://1.1.1.1', $entry->getUrl());
$this->assertEquals('this is my title', $entry->getTitle());
$this->assertSame('http://1.1.1.1', $entry->getUrl());
$this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('this is my content', $entry->getContent());
$this->assertEquals('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture());
$this->assertEquals('text/html', $entry->getMimetype());
$this->assertEquals('fr', $entry->getLanguage());
$this->assertEquals('200', $entry->getHttpStatus());
$this->assertEquals(4.0, $entry->getReadingTime());
$this->assertEquals('1.1.1.1', $entry->getDomainName());
$this->assertSame('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture());
$this->assertSame('text/html', $entry->getMimetype());
$this->assertSame('fr', $entry->getLanguage());
$this->assertSame('200', $entry->getHttpStatus());
$this->assertSame(4.0, $entry->getReadingTime());
$this->assertSame('1.1.1.1', $entry->getDomainName());
}
public function testWithContentAndNoOgImage()
@ -203,15 +203,15 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
$entry = new Entry(new User());
$proxy->updateEntry($entry, 'http://0.0.0.0');
$this->assertEquals('http://1.1.1.1', $entry->getUrl());
$this->assertEquals('this is my title', $entry->getTitle());
$this->assertSame('http://1.1.1.1', $entry->getUrl());
$this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('this is my content', $entry->getContent());
$this->assertNull($entry->getPreviewPicture());
$this->assertEquals('text/html', $entry->getMimetype());
$this->assertEquals('fr', $entry->getLanguage());
$this->assertEquals('200', $entry->getHttpStatus());
$this->assertEquals(4.0, $entry->getReadingTime());
$this->assertEquals('1.1.1.1', $entry->getDomainName());
$this->assertSame('text/html', $entry->getMimetype());
$this->assertSame('fr', $entry->getLanguage());
$this->assertSame('200', $entry->getHttpStatus());
$this->assertSame(4.0, $entry->getReadingTime());
$this->assertSame('1.1.1.1', $entry->getDomainName());
}
public function testWithContentAndBadLanguage()
@ -248,14 +248,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
$entry = new Entry(new User());
$proxy->updateEntry($entry, 'http://0.0.0.0');
$this->assertEquals('http://1.1.1.1', $entry->getUrl());
$this->assertEquals('this is my title', $entry->getTitle());
$this->assertSame('http://1.1.1.1', $entry->getUrl());
$this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('this is my content', $entry->getContent());
$this->assertEquals('text/html', $entry->getMimetype());
$this->assertSame('text/html', $entry->getMimetype());
$this->assertNull($entry->getLanguage());
$this->assertEquals('200', $entry->getHttpStatus());
$this->assertEquals(4.0, $entry->getReadingTime());
$this->assertEquals('1.1.1.1', $entry->getDomainName());
$this->assertSame('200', $entry->getHttpStatus());
$this->assertSame(4.0, $entry->getReadingTime());
$this->assertSame('1.1.1.1', $entry->getDomainName());
}
public function testWithContentAndBadOgImage()
@ -297,15 +297,15 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
$entry = new Entry(new User());
$proxy->updateEntry($entry, 'http://0.0.0.0');
$this->assertEquals('http://1.1.1.1', $entry->getUrl());
$this->assertEquals('this is my title', $entry->getTitle());
$this->assertSame('http://1.1.1.1', $entry->getUrl());
$this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('this is my content', $entry->getContent());
$this->assertNull($entry->getPreviewPicture());
$this->assertEquals('text/html', $entry->getMimetype());
$this->assertEquals('fr', $entry->getLanguage());
$this->assertEquals('200', $entry->getHttpStatus());
$this->assertEquals(4.0, $entry->getReadingTime());
$this->assertEquals('1.1.1.1', $entry->getDomainName());
$this->assertSame('text/html', $entry->getMimetype());
$this->assertSame('fr', $entry->getLanguage());
$this->assertSame('200', $entry->getHttpStatus());
$this->assertSame(4.0, $entry->getReadingTime());
$this->assertSame('1.1.1.1', $entry->getDomainName());
}
public function testWithForcedContent()
@ -333,14 +333,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
]
);
$this->assertEquals('http://1.1.1.1', $entry->getUrl());
$this->assertEquals('this is my title', $entry->getTitle());
$this->assertSame('http://1.1.1.1', $entry->getUrl());
$this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('this is my content', $entry->getContent());
$this->assertEquals('text/html', $entry->getMimetype());
$this->assertEquals('fr', $entry->getLanguage());
$this->assertEquals(4.0, $entry->getReadingTime());
$this->assertEquals('1.1.1.1', $entry->getDomainName());
$this->assertEquals('24/03/2014', $entry->getPublishedAt()->format('d/m/Y'));
$this->assertSame('text/html', $entry->getMimetype());
$this->assertSame('fr', $entry->getLanguage());
$this->assertSame(4.0, $entry->getReadingTime());
$this->assertSame('1.1.1.1', $entry->getDomainName());
$this->assertSame('24/03/2014', $entry->getPublishedAt()->format('d/m/Y'));
$this->assertContains('Jeremy', $entry->getPublishedBy());
$this->assertContains('Nico', $entry->getPublishedBy());
$this->assertContains('Thomas', $entry->getPublishedBy());
@ -371,14 +371,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
]
);
$this->assertEquals('http://1.1.1.1', $entry->getUrl());
$this->assertEquals('this is my title', $entry->getTitle());
$this->assertSame('http://1.1.1.1', $entry->getUrl());
$this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('this is my content', $entry->getContent());
$this->assertEquals('text/html', $entry->getMimetype());
$this->assertEquals('fr', $entry->getLanguage());
$this->assertEquals(4.0, $entry->getReadingTime());
$this->assertEquals('1.1.1.1', $entry->getDomainName());
$this->assertEquals('08/09/2016', $entry->getPublishedAt()->format('d/m/Y'));
$this->assertSame('text/html', $entry->getMimetype());
$this->assertSame('fr', $entry->getLanguage());
$this->assertSame(4.0, $entry->getReadingTime());
$this->assertSame('1.1.1.1', $entry->getDomainName());
$this->assertSame('08/09/2016', $entry->getPublishedAt()->format('d/m/Y'));
}
public function testWithForcedContentAndBadDate()
@ -406,13 +406,13 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
]
);
$this->assertEquals('http://1.1.1.1', $entry->getUrl());
$this->assertEquals('this is my title', $entry->getTitle());
$this->assertSame('http://1.1.1.1', $entry->getUrl());
$this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('this is my content', $entry->getContent());
$this->assertEquals('text/html', $entry->getMimetype());
$this->assertEquals('fr', $entry->getLanguage());
$this->assertEquals(4.0, $entry->getReadingTime());
$this->assertEquals('1.1.1.1', $entry->getDomainName());
$this->assertSame('text/html', $entry->getMimetype());
$this->assertSame('fr', $entry->getLanguage());
$this->assertSame(4.0, $entry->getReadingTime());
$this->assertSame('1.1.1.1', $entry->getDomainName());
$this->assertNull($entry->getPublishedAt());
$records = $handler->getRecords();
@ -488,14 +488,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
]
);
$this->assertEquals('http://1.1.1.1', $entry->getUrl());
$this->assertEquals('this is my title', $entry->getTitle());
$this->assertSame('http://1.1.1.1', $entry->getUrl());
$this->assertSame('this is my title', $entry->getTitle());
$this->assertNotContains($escapedString, $entry->getContent());
$this->assertEquals('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture());
$this->assertEquals('text/html', $entry->getMimetype());
$this->assertEquals('fr', $entry->getLanguage());
$this->assertEquals('200', $entry->getHttpStatus());
$this->assertEquals('1.1.1.1', $entry->getDomainName());
$this->assertSame('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture());
$this->assertSame('text/html', $entry->getMimetype());
$this->assertSame('fr', $entry->getLanguage());
$this->assertSame('200', $entry->getHttpStatus());
$this->assertSame('1.1.1.1', $entry->getDomainName());
}
private function getTaggerMock()

View File

@ -2,9 +2,9 @@
namespace Tests\Wallabag\CoreBundle\Helper;
use Psr\Log\NullLogger;
use Monolog\Logger;
use Monolog\Handler\TestHandler;
use Monolog\Logger;
use Psr\Log\NullLogger;
use Wallabag\CoreBundle\Helper\CryptoProxy;
class CryptoProxyTest extends \PHPUnit_Framework_TestCase
@ -14,7 +14,7 @@ class CryptoProxyTest extends \PHPUnit_Framework_TestCase
$logHandler = new TestHandler();
$logger = new Logger('test', [$logHandler]);
$crypto = new CryptoProxy(sys_get_temp_dir().'/'.uniqid('', true).'.txt', $logger);
$crypto = new CryptoProxy(sys_get_temp_dir() . '/' . uniqid('', true) . '.txt', $logger);
$crypted = $crypto->crypt('test');
$decrypted = $crypto->decrypt($crypted);
@ -27,14 +27,14 @@ class CryptoProxyTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException RuntimeException
* @expectedException \RuntimeException
* @expectedExceptionMessage Decrypt fail
*
* @return [type] [description]
*/
public function testDecryptBadValue()
{
$crypto = new CryptoProxy(sys_get_temp_dir().'/'.uniqid('', true).'.txt', new NullLogger());
$crypto = new CryptoProxy(sys_get_temp_dir() . '/' . uniqid('', true) . '.txt', new NullLogger());
$crypto->decrypt('badvalue');
}
}

View File

@ -2,13 +2,13 @@
namespace Tests\Wallabag\CoreBundle\Helper;
use Wallabag\CoreBundle\Helper\DownloadImages;
use Monolog\Logger;
use Monolog\Handler\TestHandler;
use GuzzleHttp\Client;
use GuzzleHttp\Subscriber\Mock;
use GuzzleHttp\Message\Response;
use GuzzleHttp\Stream\Stream;
use GuzzleHttp\Subscriber\Mock;
use Monolog\Handler\TestHandler;
use Monolog\Logger;
use Wallabag\CoreBundle\Helper\DownloadImages;
class DownloadImagesTest extends \PHPUnit_Framework_TestCase
{
@ -34,15 +34,15 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase
$client = new Client();
$mock = new Mock([
new Response(200, ['content-type' => 'image/png'], Stream::factory(file_get_contents(__DIR__.'/../fixtures/unnamed.png'))),
new Response(200, ['content-type' => 'image/png'], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/unnamed.png'))),
]);
$client->getEmitter()->attach($mock);
$logHandler = new TestHandler();
$logger = new Logger('test', array($logHandler));
$logger = new Logger('test', [$logHandler]);
$download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
$download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
$res = $download->processHtml(123, $html, $url);
@ -61,9 +61,9 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase
$client->getEmitter()->attach($mock);
$logHandler = new TestHandler();
$logger = new Logger('test', array($logHandler));
$logger = new Logger('test', [$logHandler]);
$download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
$download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
$res = $download->processHtml(123, '<div><img src="http://i.imgur.com/T9qgcHc.jpg" /></div>', 'http://imgur.com/gallery/WxtWY');
$this->assertContains('http://i.imgur.com/T9qgcHc.jpg', $res, 'Image were not replace because of content-type');
@ -87,18 +87,18 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase
$client = new Client();
$mock = new Mock([
new Response(200, ['content-type' => $header], Stream::factory(file_get_contents(__DIR__.'/../fixtures/unnamed.png'))),
new Response(200, ['content-type' => $header], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/unnamed.png'))),
]);
$client->getEmitter()->attach($mock);
$logHandler = new TestHandler();
$logger = new Logger('test', array($logHandler));
$logger = new Logger('test', [$logHandler]);
$download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
$download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
$res = $download->processSingleImage(123, 'T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY');
$this->assertContains('/assets/images/9/b/9b0ead26/ebe60399.'.$extension, $res);
$this->assertContains('/assets/images/9/b/9b0ead26/ebe60399.' . $extension, $res);
}
public function testProcessSingleImageWithBadUrl()
@ -112,9 +112,9 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase
$client->getEmitter()->attach($mock);
$logHandler = new TestHandler();
$logger = new Logger('test', array($logHandler));
$logger = new Logger('test', [$logHandler]);
$download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
$download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
$res = $download->processSingleImage(123, 'T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY');
$this->assertFalse($res, 'Image can not be found, so it will not be replaced');
@ -131,9 +131,9 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase
$client->getEmitter()->attach($mock);
$logHandler = new TestHandler();
$logger = new Logger('test', array($logHandler));
$logger = new Logger('test', [$logHandler]);
$download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
$download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
$res = $download->processSingleImage(123, 'http://i.imgur.com/T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY');
$this->assertFalse($res, 'Image can not be loaded, so it will not be replaced');
@ -144,15 +144,15 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase
$client = new Client();
$mock = new Mock([
new Response(200, ['content-type' => 'image/png'], Stream::factory(file_get_contents(__DIR__.'/../fixtures/unnamed.png'))),
new Response(200, ['content-type' => 'image/png'], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/unnamed.png'))),
]);
$client->getEmitter()->attach($mock);
$logHandler = new TestHandler();
$logger = new Logger('test', array($logHandler));
$logger = new Logger('test', [$logHandler]);
$download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
$download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
$res = $download->processSingleImage(123, '/i.imgur.com/T9qgcHc.jpg', 'imgur.com/gallery/WxtWY');
$this->assertFalse($res, 'Absolute image can not be determined, so it will not be replaced');
@ -163,15 +163,15 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase
$client = new Client();
$mock = new Mock([
new Response(200, ['content-type' => null], Stream::factory(file_get_contents(__DIR__.'/../fixtures/image-no-content-type.jpg'))),
new Response(200, ['content-type' => null], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))),
]);
$client->getEmitter()->attach($mock);
$logHandler = new TestHandler();
$logger = new Logger('test', array($logHandler));
$logger = new Logger('test', [$logHandler]);
$download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
$download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
$res = $download->processSingleImage(
123,

View File

@ -2,11 +2,11 @@
namespace Tests\Wallabag\CoreBundle\Helper;
use Wallabag\CoreBundle\Entity\Config;
use Wallabag\UserBundle\Entity\User;
use Wallabag\CoreBundle\Helper\Redirect;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Wallabag\CoreBundle\Entity\Config;
use Wallabag\CoreBundle\Helper\Redirect;
use Wallabag\UserBundle\Entity\User;
class RedirectTest extends \PHPUnit_Framework_TestCase
{
@ -56,21 +56,21 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
{
$redirectUrl = $this->redirect->to(null, 'fallback');
$this->assertEquals('fallback', $redirectUrl);
$this->assertSame('fallback', $redirectUrl);
}
public function testRedirectToNullWithoutFallback()
{
$redirectUrl = $this->redirect->to(null);
$this->assertEquals($this->routerMock->generate('homepage'), $redirectUrl);
$this->assertSame($this->routerMock->generate('homepage'), $redirectUrl);
}
public function testRedirectToValidUrl()
{
$redirectUrl = $this->redirect->to('/unread/list');
$this->assertEquals('/unread/list', $redirectUrl);
$this->assertSame('/unread/list', $redirectUrl);
}
public function testWithNotLoggedUser()
@ -78,7 +78,7 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
$redirect = new Redirect($this->routerMock, new TokenStorage());
$redirectUrl = $redirect->to('/unread/list');
$this->assertEquals('/unread/list', $redirectUrl);
$this->assertSame('/unread/list', $redirectUrl);
}
public function testUserForRedirectToHomepage()
@ -87,7 +87,7 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
$redirectUrl = $this->redirect->to('/unread/list');
$this->assertEquals($this->routerMock->generate('homepage'), $redirectUrl);
$this->assertSame($this->routerMock->generate('homepage'), $redirectUrl);
}
public function testUserForRedirectWithIgnoreActionMarkAsRead()
@ -96,7 +96,7 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
$redirectUrl = $this->redirect->to('/unread/list', '', true);
$this->assertEquals('/unread/list', $redirectUrl);
$this->assertSame('/unread/list', $redirectUrl);
}
public function testUserForRedirectNullWithFallbackWithIgnoreActionMarkAsRead()
@ -105,6 +105,6 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
$redirectUrl = $this->redirect->to(null, 'fallback', true);
$this->assertEquals('fallback', $redirectUrl);
$this->assertSame('fallback', $redirectUrl);
}
}

View File

@ -182,7 +182,7 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase
$tags = $entry->getTags();
$this->assertCount(1, $tags);
$this->assertEquals('hey', $tags[0]->getLabel());
$this->assertSame('hey', $tags[0]->getLabel());
}
}

View File

@ -5,8 +5,8 @@ namespace Tests\Wallabag\CoreBundle\Helper;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Helper\TagsAssigner;
use Wallabag\UserBundle\Entity\User;
use Wallabag\CoreBundle\Repository\TagRepository;
use Wallabag\UserBundle\Entity\User;
class TagsAssignerTest extends \PHPUnit_Framework_TestCase
{
@ -20,8 +20,8 @@ class TagsAssignerTest extends \PHPUnit_Framework_TestCase
$tagsAssigner->assignTagsToEntry($entry, [' tag1', 'tag2 ']);
$this->assertCount(2, $entry->getTags());
$this->assertEquals('tag1', $entry->getTags()[0]->getLabel());
$this->assertEquals('tag2', $entry->getTags()[1]->getLabel());
$this->assertSame('tag1', $entry->getTags()[0]->getLabel());
$this->assertSame('tag2', $entry->getTags()[1]->getLabel());
}
public function testAssignTagsWithString()
@ -34,8 +34,8 @@ class TagsAssignerTest extends \PHPUnit_Framework_TestCase
$tagsAssigner->assignTagsToEntry($entry, 'tag1, tag2');
$this->assertCount(2, $entry->getTags());
$this->assertEquals('tag1', $entry->getTags()[0]->getLabel());
$this->assertEquals('tag2', $entry->getTags()[1]->getLabel());
$this->assertSame('tag1', $entry->getTags()[0]->getLabel());
$this->assertSame('tag2', $entry->getTags()[1]->getLabel());
}
public function testAssignTagsWithEmptyArray()
@ -76,8 +76,8 @@ class TagsAssignerTest extends \PHPUnit_Framework_TestCase
$tagsAssigner->assignTagsToEntry($entry, 'tag1, tag2');
$this->assertCount(2, $entry->getTags());
$this->assertEquals('tag1', $entry->getTags()[0]->getLabel());
$this->assertEquals('tag2', $entry->getTags()[1]->getLabel());
$this->assertSame('tag1', $entry->getTags()[0]->getLabel());
$this->assertSame('tag2', $entry->getTags()[1]->getLabel());
}
public function testAssignTagsNotFlushed()
@ -96,7 +96,7 @@ class TagsAssignerTest extends \PHPUnit_Framework_TestCase
$tagsAssigner->assignTagsToEntry($entry, 'tag1', [$tagEntity]);
$this->assertCount(1, $entry->getTags());
$this->assertEquals('tag1', $entry->getTags()[0]->getLabel());
$this->assertSame('tag1', $entry->getTags()[0]->getLabel());
}
private function getTagRepositoryMock()

View File

@ -212,6 +212,6 @@ class UsernameRssTokenConverterTest extends \PHPUnit_Framework_TestCase
$converter->apply($request, $params);
$this->assertEquals($user, $request->attributes->get('user'));
$this->assertSame($user, $request->attributes->get('user'));
}
}

View File

@ -18,7 +18,7 @@ class UtilsTest extends \PHPUnit_Framework_TestCase
public function examples()
{
$examples = [];
$finder = (new Finder())->in(__DIR__.'/samples');
$finder = (new Finder())->in(__DIR__ . '/samples');
foreach ($finder->getIterator() as $file) {
$examples[] = [$file->getContents(), 1];
}

View File

@ -26,8 +26,8 @@ class WallabagExtensionTest extends \PHPUnit_Framework_TestCase
$extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator);
$this->assertEquals('lemonde.fr', $extension->removeWww('www.lemonde.fr'));
$this->assertEquals('lemonde.fr', $extension->removeWww('lemonde.fr'));
$this->assertEquals('gist.github.com', $extension->removeWww('gist.github.com'));
$this->assertSame('lemonde.fr', $extension->removeWww('www.lemonde.fr'));
$this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr'));
$this->assertSame('gist.github.com', $extension->removeWww('gist.github.com'));
}
}

View File

@ -18,11 +18,6 @@ abstract class WallabagCoreTestCase extends WebTestCase
*/
private $client = null;
public function getClient()
{
return $this->client;
}
public function setUp()
{
parent::setUp();
@ -30,6 +25,11 @@ abstract class WallabagCoreTestCase extends WebTestCase
$this->client = static::createClient();
}
public function getClient()
{
return $this->client;
}
public function resetDatabase(Client $client)
{
$application = new Application($client->getKernel());
@ -83,10 +83,10 @@ abstract class WallabagCoreTestCase extends WebTestCase
$loginManager = $container->get('fos_user.security.login_manager');
$firewallName = $container->getParameter('fos_user.firewall_name');
$user = $userManager->findUserBy(array('username' => $username));
$user = $userManager->findUserBy(['username' => $username]);
$loginManager->logInUser($firewallName, $user);
$session->set('_security_'.$firewallName, serialize($container->get('security.token_storage')->getToken()));
$session->set('_security_' . $firewallName, serialize($container->get('security.token_storage')->getToken()));
$session->save();
$cookie = new Cookie($session->getName(), $session->getId());