aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorKevin Decherf <kevin@kdecherf.com>2017-09-09 19:34:41 +0200
committerKevin Decherf <kevin@kdecherf.com>2017-11-19 15:02:11 +0100
commite50e45d6fa64aea8b6b96f60073fb36960322aa8 (patch)
tree5f80e99f7e5e34e8ac8f00510a55b7e59f1cf23e /tests
parent03b020eb205a052b3a09f94e316c3b6b48607103 (diff)
downloadwallabag-e50e45d6fa64aea8b6b96f60073fb36960322aa8.tar.gz
wallabag-e50e45d6fa64aea8b6b96f60073fb36960322aa8.tar.zst
wallabag-e50e45d6fa64aea8b6b96f60073fb36960322aa8.zip
Twig: add removeSchemeAndWww filter
This twig filter removes scheme (only http and https are supported) and pass the result to removeWww filter to also remove 'www.' at the beginning of an url. Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php
index ceec4b37..27989346 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}