]> git.immae.eu Git - github/wallabag/wallabag.git/blob - tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php
Merge pull request #3857 from wallabag/php73
[github/wallabag/wallabag.git] / tests / Wallabag / CoreBundle / Twig / WallabagExtensionTest.php
1 <?php
2
3 namespace Tests\Wallabag\CoreBundle\Twig;
4
5 use PHPUnit\Framework\TestCase;
6 use Wallabag\CoreBundle\Twig\WallabagExtension;
7
8 class WallabagExtensionTest extends TestCase
9 {
10 public function testRemoveWww()
11 {
12 $entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
13 ->disableOriginalConstructor()
14 ->getMock();
15
16 $tagRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository')
17 ->disableOriginalConstructor()
18 ->getMock();
19
20 $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')
21 ->disableOriginalConstructor()
22 ->getMock();
23
24 $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')
25 ->disableOriginalConstructor()
26 ->getMock();
27
28 $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator);
29
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'));
33 }
34
35 public function testRemoveSchemeAndWww()
36 {
37 $entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
38 ->disableOriginalConstructor()
39 ->getMock();
40
41 $tagRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository')
42 ->disableOriginalConstructor()
43 ->getMock();
44
45 $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')
46 ->disableOriginalConstructor()
47 ->getMock();
48
49 $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')
50 ->disableOriginalConstructor()
51 ->getMock();
52
53 $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator);
54
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'));
60 }
61 }