2015-10-06 06:34:11 +02:00
|
|
|
<?php
|
|
|
|
|
2016-06-01 21:27:35 +02:00
|
|
|
namespace Tests\Wallabag\CoreBundle\Twig;
|
2015-10-06 06:34:11 +02:00
|
|
|
|
|
|
|
use Wallabag\CoreBundle\Twig\WallabagExtension;
|
|
|
|
|
|
|
|
class WallabagExtensionTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
public function testRemoveWww()
|
|
|
|
{
|
2016-10-01 15:58:26 +02: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 06:34:11 +02:00
|
|
|
|
2017-07-01 09:52:38 +02: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 06:34:11 +02:00
|
|
|
}
|
2017-09-09 19:34:41 +02:00
|
|
|
|
|
|
|
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);
|
2017-11-19 15:26:13 +01:00
|
|
|
|
2017-09-09 19:34:41 +02:00
|
|
|
$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 06:34:11 +02:00
|
|
|
}
|