2015-10-06 04:34:11 +00:00
|
|
|
<?php
|
|
|
|
|
2024-02-19 00:30:12 +00:00
|
|
|
namespace Tests\Wallabag\Twig;
|
2015-10-06 04:34:11 +00:00
|
|
|
|
2017-12-16 21:17:42 +00:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2022-09-01 18:54:56 +00:00
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
2022-12-19 09:37:22 +00:00
|
|
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
2024-02-19 00:30:12 +00:00
|
|
|
use Wallabag\Repository\EntryRepository;
|
|
|
|
use Wallabag\Repository\TagRepository;
|
|
|
|
use Wallabag\Twig\WallabagExtension;
|
2015-10-06 04:34:11 +00:00
|
|
|
|
2017-12-16 21:17:42 +00:00
|
|
|
class WallabagExtensionTest extends TestCase
|
2015-10-06 04:34:11 +00:00
|
|
|
{
|
|
|
|
public function testRemoveWww()
|
|
|
|
{
|
2022-09-01 18:54:56 +00:00
|
|
|
$entryRepository = $this->getMockBuilder(EntryRepository::class)
|
2016-10-01 13:58:26 +00:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
|
2022-09-01 18:54:56 +00:00
|
|
|
$tagRepository = $this->getMockBuilder(TagRepository::class)
|
2016-10-01 13:58:26 +00:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
|
2022-09-01 18:54:56 +00:00
|
|
|
$tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)
|
2016-10-01 13:58:26 +00:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
|
2022-09-01 18:54:56 +00:00
|
|
|
$translator = $this->getMockBuilder(TranslatorInterface::class)
|
2016-10-01 13:58:26 +00:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
|
2020-01-29 21:26:00 +00:00
|
|
|
$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
|
|
|
}
|
2017-09-09 17:34:41 +00:00
|
|
|
|
2017-06-13 16:48:10 +00:00
|
|
|
public function testRemoveScheme()
|
|
|
|
{
|
2022-09-01 18:54:56 +00:00
|
|
|
$entryRepository = $this->getMockBuilder(EntryRepository::class)
|
2017-06-13 16:48:10 +00:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
|
2022-09-01 18:54:56 +00:00
|
|
|
$tagRepository = $this->getMockBuilder(TagRepository::class)
|
2017-06-13 16:48:10 +00:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
|
2022-09-01 18:54:56 +00:00
|
|
|
$tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)
|
2017-06-13 16:48:10 +00:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
|
2022-09-01 18:54:56 +00:00
|
|
|
$translator = $this->getMockBuilder(TranslatorInterface::class)
|
2017-06-13 16:48:10 +00:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
|
2020-01-29 21:26:00 +00:00
|
|
|
$extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator, '');
|
2017-06-13 16:48:10 +00:00
|
|
|
|
2019-04-25 12:12:56 +00:00
|
|
|
$this->assertSame('lemonde.fr', $extension->removeScheme('lemonde.fr'));
|
|
|
|
$this->assertSame('gist.github.com', $extension->removeScheme('gist.github.com'));
|
|
|
|
$this->assertSame('gist.github.com', $extension->removeScheme('https://gist.github.com'));
|
2023-08-09 23:37:25 +00:00
|
|
|
$this->assertSame('gist.github.com', $extension->removeScheme('http://gist.github.com'));
|
2017-06-13 16:48:10 +00:00
|
|
|
}
|
|
|
|
|
2017-09-09 17:34:41 +00:00
|
|
|
public function testRemoveSchemeAndWww()
|
|
|
|
{
|
2022-09-01 18:54:56 +00:00
|
|
|
$entryRepository = $this->getMockBuilder(EntryRepository::class)
|
2017-09-09 17:34:41 +00:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
|
2022-09-01 18:54:56 +00:00
|
|
|
$tagRepository = $this->getMockBuilder(TagRepository::class)
|
2017-09-09 17:34:41 +00:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
|
2022-09-01 18:54:56 +00:00
|
|
|
$tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)
|
2017-09-09 17:34:41 +00:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
|
2022-09-01 18:54:56 +00:00
|
|
|
$translator = $this->getMockBuilder(TranslatorInterface::class)
|
2017-09-09 17:34:41 +00:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
|
2020-01-29 21:26:00 +00:00
|
|
|
$extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator, '');
|
2017-11-19 14:26:13 +00:00
|
|
|
|
2017-09-09 17:34:41 +00:00
|
|
|
$this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('www.lemonde.fr'));
|
2023-08-09 23:37:25 +00:00
|
|
|
$this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('http://www.lemonde.fr'));
|
2017-09-09 17:34:41 +00:00
|
|
|
$this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('http://lemonde.fr'));
|
|
|
|
$this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('https://www.lemonde.fr'));
|
2023-08-09 23:37:25 +00:00
|
|
|
$this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('https://lemonde.fr'));
|
2017-09-09 17:34:41 +00:00
|
|
|
$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
|
|
|
}
|