3 namespace Tests\Wallabag\CoreBundle\Twig
;
5 use Wallabag\CoreBundle\Twig\WallabagExtension
;
7 class WallabagExtensionTest
extends \PHPUnit_Framework_TestCase
9 public function testRemoveWww()
11 $entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
12 ->disableOriginalConstructor()
15 $tagRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository')
16 ->disableOriginalConstructor()
19 $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')
20 ->disableOriginalConstructor()
23 $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')
24 ->disableOriginalConstructor()
27 $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator);
29 $this->assertSame('lemonde.fr', $extension->removeWww('www.lemonde.fr'));
30 $this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr'));
31 $this->assertSame('gist.github.com', $extension->removeWww('gist.github.com'));
34 public function testRemoveSchemeAndWww()
36 $entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
37 ->disableOriginalConstructor()
40 $tagRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository')
41 ->disableOriginalConstructor()
44 $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')
45 ->disableOriginalConstructor()
48 $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')
49 ->disableOriginalConstructor()
52 $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator);
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'));