3 namespace Tests\Wallabag\CoreBundle\Twig
;
5 use PHPUnit\Framework\TestCase
;
6 use Wallabag\CoreBundle\Twig\WallabagExtension
;
8 class WallabagExtensionTest
extends TestCase
10 public function testRemoveWww()
12 $entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
13 ->disableOriginalConstructor()
16 $tagRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository')
17 ->disableOriginalConstructor()
20 $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')
21 ->disableOriginalConstructor()
24 $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')
25 ->disableOriginalConstructor()
28 $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator);
30 $this->assertSame('lemonde.fr', $extension->removeWww('www.lemonde.fr'));
31 $this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr'));
32 $this->assertSame('gist.github.com', $extension->removeWww('gist.github.com'));
35 public function testRemoveSchemeAndWww()
37 $entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
38 ->disableOriginalConstructor()
41 $tagRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository')
42 ->disableOriginalConstructor()
45 $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')
46 ->disableOriginalConstructor()
49 $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')
50 ->disableOriginalConstructor()
53 $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator);
55 $this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('www.lemonde.fr'));
56 $this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('http://lemonde.fr'));
57 $this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('https://www.lemonde.fr'));
58 $this->assertSame('gist.github.com', $extension->removeSchemeAndWww('https://gist.github.com'));
59 $this->assertSame('ftp://gist.github.com', $extension->removeSchemeAndWww('ftp://gist.github.com'));