wallabag/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php

87 lines
3.7 KiB
PHP
Raw Normal View History

2015-10-06 04:34:11 +00:00
<?php
2016-06-01 19:27:35 +00:00
namespace Tests\Wallabag\CoreBundle\Twig;
2015-10-06 04:34:11 +00:00
2017-12-16 21:17:42 +00:00
use PHPUnit\Framework\TestCase;
2015-10-06 04:34:11 +00:00
use Wallabag\CoreBundle\Twig\WallabagExtension;
2017-12-16 21:17:42 +00:00
class WallabagExtensionTest extends TestCase
2015-10-06 04:34:11 +00:00
{
public function testRemoveWww()
{
2016-10-01 13:58:26 +00:00
$entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
->getMock();
$tagRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository')
->disableOriginalConstructor()
->getMock();
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')
->disableOriginalConstructor()
->getMock();
$translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')
->disableOriginalConstructor()
->getMock();
$extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator);
2015-10-06 04:34:11 +00:00
2017-07-01 07:52:38 +00:00
$this->assertSame('lemonde.fr', $extension->removeWww('www.lemonde.fr'));
$this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr'));
$this->assertSame('gist.github.com', $extension->removeWww('gist.github.com'));
2015-10-06 04:34:11 +00:00
}
public function testRemoveScheme()
{
$entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
->getMock();
$tagRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository')
->disableOriginalConstructor()
->getMock();
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')
->disableOriginalConstructor()
->getMock();
$translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')
->disableOriginalConstructor()
->getMock();
$extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator);
$this->assertEquals('lemonde.fr', $extension->removeScheme('lemonde.fr'));
$this->assertEquals('gist.github.com', $extension->removeScheme('gist.github.com'));
$this->assertEquals('gist.github.com', $extension->removeScheme('https://gist.github.com'));
}
public function testRemoveSchemeAndWww()
{
$entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
->getMock();
$tagRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository')
->disableOriginalConstructor()
->getMock();
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')
->disableOriginalConstructor()
->getMock();
$translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')
->disableOriginalConstructor()
->getMock();
$extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator);
$this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('www.lemonde.fr'));
$this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('http://lemonde.fr'));
$this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('https://www.lemonde.fr'));
$this->assertSame('gist.github.com', $extension->removeSchemeAndWww('https://gist.github.com'));
$this->assertSame('ftp://gist.github.com', $extension->removeSchemeAndWww('ftp://gist.github.com'));
}
2015-10-06 04:34:11 +00:00
}