diff options
Diffstat (limited to 'tests')
3 files changed, 48 insertions, 3 deletions
diff --git a/tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php b/tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php index 9939d43c..1f5921d2 100644 --- a/tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php | |||
@@ -6,10 +6,11 @@ use Symfony\Bundle\FrameworkBundle\Console\Application; | |||
6 | use Symfony\Component\Console\Tester\CommandTester; | 6 | use Symfony\Component\Console\Tester\CommandTester; |
7 | use Wallabag\CoreBundle\Command\CleanDuplicatesCommand; | 7 | use Wallabag\CoreBundle\Command\CleanDuplicatesCommand; |
8 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | 8 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; |
9 | use Wallabag\CoreBundle\Entity\Entry; | ||
9 | 10 | ||
10 | class CleanDuplicatesCommandTest extends WallabagCoreTestCase | 11 | class CleanDuplicatesCommandTest extends WallabagCoreTestCase |
11 | { | 12 | { |
12 | public function testRunTagAllCommandForAll() | 13 | public function testTagAll() |
13 | { | 14 | { |
14 | $application = new Application($this->getClient()->getKernel()); | 15 | $application = new Application($this->getClient()->getKernel()); |
15 | $application->add(new CleanDuplicatesCommand()); | 16 | $application->add(new CleanDuplicatesCommand()); |
@@ -56,4 +57,48 @@ class CleanDuplicatesCommandTest extends WallabagCoreTestCase | |||
56 | 57 | ||
57 | $this->assertContains('Cleaned 0 duplicates for user admin', $tester->getDisplay()); | 58 | $this->assertContains('Cleaned 0 duplicates for user admin', $tester->getDisplay()); |
58 | } | 59 | } |
60 | |||
61 | public function testDuplicate() | ||
62 | { | ||
63 | $url = 'http://www.lemonde.fr/sport/visuel/2017/05/05/rondelle-prison-blanchissage-comprendre-le-hockey-sur-glace_5122587_3242.html'; | ||
64 | $client = $this->getClient(); | ||
65 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | ||
66 | |||
67 | $this->logInAs('admin'); | ||
68 | |||
69 | $nbEntries = $em->getRepository('WallabagCoreBundle:Entry')->findAllByUrlAndUserId($url, $this->getLoggedInUserId()); | ||
70 | $this->assertCount(0, $nbEntries); | ||
71 | |||
72 | $user = $em->getRepository('WallabagUserBundle:User')->findOneById($this->getLoggedInUserId()); | ||
73 | |||
74 | $entry1 = new Entry($user); | ||
75 | $entry1->setUrl($url); | ||
76 | |||
77 | $entry2 = new Entry($user); | ||
78 | $entry2->setUrl($url); | ||
79 | |||
80 | $em->persist($entry1); | ||
81 | $em->persist($entry2); | ||
82 | |||
83 | $em->flush(); | ||
84 | |||
85 | $nbEntries = $em->getRepository('WallabagCoreBundle:Entry')->findAllByUrlAndUserId($url, $this->getLoggedInUserId()); | ||
86 | $this->assertCount(2, $nbEntries); | ||
87 | |||
88 | $application = new Application($this->getClient()->getKernel()); | ||
89 | $application->add(new CleanDuplicatesCommand()); | ||
90 | |||
91 | $command = $application->find('wallabag:clean-duplicates'); | ||
92 | |||
93 | $tester = new CommandTester($command); | ||
94 | $tester->execute([ | ||
95 | 'command' => $command->getName(), | ||
96 | 'username' => 'admin', | ||
97 | ]); | ||
98 | |||
99 | $this->assertContains('Cleaned 1 duplicates for user admin', $tester->getDisplay()); | ||
100 | |||
101 | $nbEntries = $em->getRepository('WallabagCoreBundle:Entry')->findAllByUrlAndUserId($url, $this->getLoggedInUserId()); | ||
102 | $this->assertCount(1, $nbEntries); | ||
103 | } | ||
59 | } | 104 | } |
diff --git a/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php b/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php index 6798c5d7..b21f3318 100644 --- a/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php | |||
@@ -70,7 +70,7 @@ class ExportCommandTest extends WallabagCoreTestCase | |||
70 | $tester->execute([ | 70 | $tester->execute([ |
71 | 'command' => $command->getName(), | 71 | 'command' => $command->getName(), |
72 | 'username' => 'admin', | 72 | 'username' => 'admin', |
73 | 'filepath' => 'specialexport.json' | 73 | 'filepath' => 'specialexport.json', |
74 | ]); | 74 | ]); |
75 | 75 | ||
76 | $this->assertFileExists('specialexport.json'); | 76 | $this->assertFileExists('specialexport.json'); |
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php index 5956b502..8abb1bbb 100644 --- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php +++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php | |||
@@ -111,7 +111,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
111 | 111 | ||
112 | $this->assertEquals('http://domain.io', $entry->getUrl()); | 112 | $this->assertEquals('http://domain.io', $entry->getUrl()); |
113 | $this->assertEquals('my title', $entry->getTitle()); | 113 | $this->assertEquals('my title', $entry->getTitle()); |
114 | $this->assertEquals($this->fetchingErrorMessage . '<p><i>But we found a short description: </i></p>desc', $entry->getContent()); | 114 | $this->assertEquals($this->fetchingErrorMessage.'<p><i>But we found a short description: </i></p>desc', $entry->getContent()); |
115 | $this->assertEmpty($entry->getPreviewPicture()); | 115 | $this->assertEmpty($entry->getPreviewPicture()); |
116 | $this->assertEmpty($entry->getLanguage()); | 116 | $this->assertEmpty($entry->getLanguage()); |
117 | $this->assertEmpty($entry->getHttpStatus()); | 117 | $this->assertEmpty($entry->getHttpStatus()); |