diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2017-11-20 21:10:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-20 21:10:33 +0100 |
commit | f4f7994c40ca57c7e6f8ca0a3d298c50c4e5f813 (patch) | |
tree | 14b2c8f8ea61578a7ca0c5414a85ce29bcf57bd7 /tests/Wallabag/CoreBundle | |
parent | 16b1939827453bc1c8f65c908c45575d27134a53 (diff) | |
parent | eae8138b33e4ed4a5d1a98daf77941ef691629de (diff) | |
download | wallabag-f4f7994c40ca57c7e6f8ca0a3d298c50c4e5f813.tar.gz wallabag-f4f7994c40ca57c7e6f8ca0a3d298c50c4e5f813.tar.zst wallabag-f4f7994c40ca57c7e6f8ca0a3d298c50c4e5f813.zip |
Merge pull request #3346 from Kdecherf/origin-property
Add originUrl property to Entry
Diffstat (limited to 'tests/Wallabag/CoreBundle')
-rw-r--r-- | tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | 40 | ||||
-rw-r--r-- | tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php | 27 |
2 files changed, 65 insertions, 2 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 6e806553..c6a523e3 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | |||
@@ -475,6 +475,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
475 | 475 | ||
476 | $data = [ | 476 | $data = [ |
477 | 'entry[title]' => 'My updated title hehe :)', | 477 | 'entry[title]' => 'My updated title hehe :)', |
478 | 'entry[origin_url]' => 'https://example.io', | ||
478 | ]; | 479 | ]; |
479 | 480 | ||
480 | $client->submit($form, $data); | 481 | $client->submit($form, $data); |
@@ -483,8 +484,43 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
483 | 484 | ||
484 | $crawler = $client->followRedirect(); | 485 | $crawler = $client->followRedirect(); |
485 | 486 | ||
486 | $this->assertGreaterThan(1, $alert = $crawler->filter('div[id=article] h1')->extract(['_text'])); | 487 | $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text'])); |
487 | $this->assertContains('My updated title hehe :)', $alert[0]); | 488 | $this->assertContains('My updated title hehe :)', $title[0]); |
489 | $this->assertGreaterThan(1, $stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text'])); | ||
490 | $this->assertContains('example.io', trim($stats[1])); | ||
491 | } | ||
492 | |||
493 | public function testEditRemoveOriginUrl() | ||
494 | { | ||
495 | $this->logInAs('admin'); | ||
496 | $client = $this->getClient(); | ||
497 | |||
498 | $entry = new Entry($this->getLoggedInUser()); | ||
499 | $entry->setUrl($this->url); | ||
500 | $this->getEntityManager()->persist($entry); | ||
501 | $this->getEntityManager()->flush(); | ||
502 | |||
503 | $crawler = $client->request('GET', '/edit/' . $entry->getId()); | ||
504 | |||
505 | $this->assertSame(200, $client->getResponse()->getStatusCode()); | ||
506 | |||
507 | $form = $crawler->filter('button[type=submit]')->form(); | ||
508 | |||
509 | $data = [ | ||
510 | 'entry[title]' => 'My updated title hehe :)', | ||
511 | 'entry[origin_url]' => '', | ||
512 | ]; | ||
513 | |||
514 | $client->submit($form, $data); | ||
515 | |||
516 | $this->assertSame(302, $client->getResponse()->getStatusCode()); | ||
517 | |||
518 | $crawler = $client->followRedirect(); | ||
519 | |||
520 | $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text'])); | ||
521 | $this->assertContains('My updated title hehe :)', $title[0]); | ||
522 | $this->assertSame(1, count($stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text']))); | ||
523 | $this->assertNotContains('example.io', trim($stats[0])); | ||
488 | } | 524 | } |
489 | 525 | ||
490 | public function testToggleArchive() | 526 | public function testToggleArchive() |
diff --git a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php index ceec4b37..82336060 100644 --- a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php +++ b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php | |||
@@ -30,4 +30,31 @@ class WallabagExtensionTest extends \PHPUnit_Framework_TestCase | |||
30 | $this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr')); | 30 | $this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr')); |
31 | $this->assertSame('gist.github.com', $extension->removeWww('gist.github.com')); | 31 | $this->assertSame('gist.github.com', $extension->removeWww('gist.github.com')); |
32 | } | 32 | } |
33 | |||
34 | public function testRemoveSchemeAndWww() | ||
35 | { | ||
36 | $entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') | ||
37 | ->disableOriginalConstructor() | ||
38 | ->getMock(); | ||
39 | |||
40 | $tagRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository') | ||
41 | ->disableOriginalConstructor() | ||
42 | ->getMock(); | ||
43 | |||
44 | $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface') | ||
45 | ->disableOriginalConstructor() | ||
46 | ->getMock(); | ||
47 | |||
48 | $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface') | ||
49 | ->disableOriginalConstructor() | ||
50 | ->getMock(); | ||
51 | |||
52 | $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator); | ||
53 | |||
54 | $this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('www.lemonde.fr')); | ||
55 | $this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('http://lemonde.fr')); | ||
56 | $this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('https://www.lemonde.fr')); | ||
57 | $this->assertSame('gist.github.com', $extension->removeSchemeAndWww('https://gist.github.com')); | ||
58 | $this->assertSame('ftp://gist.github.com', $extension->removeSchemeAndWww('ftp://gist.github.com')); | ||
59 | } | ||
33 | } | 60 | } |