forked from wallabag/wallabag
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>
This commit is contained in:
@ -30,4 +30,31 @@ class WallabagExtensionTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr'));
|
||||
$this->assertSame('gist.github.com', $extension->removeWww('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'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user