diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2018-09-10 14:40:33 +0200 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2018-09-10 14:40:33 +0200 |
commit | 4bf3a68f43e4fcea34fe0a16cb3e1eecb97d332a (patch) | |
tree | 736cdc6a8df17b12d9f18312eaf09637298caabf /tests | |
parent | 222c9fed7d4ca2b3b44c05907fbb7080c1efd342 (diff) |
Fixed assets rendering
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Unit/Renderer/Twig/Extensions/AssetsTest.php | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/Unit/Renderer/Twig/Extensions/AssetsTest.php b/tests/Unit/Renderer/Twig/Extensions/AssetsTest.php new file mode 100644 index 00000000..2d7ba6cd --- /dev/null +++ b/tests/Unit/Renderer/Twig/Extensions/AssetsTest.php @@ -0,0 +1,47 @@ +<?php + +namespace Engelsystem\Test\Unit\Renderer\Twig\Extensions; + +use Engelsystem\Http\UrlGenerator; +use Engelsystem\Renderer\Twig\Extensions\Assets; +use PHPUnit\Framework\MockObject\MockObject; + +class AssetsTest extends ExtensionTest +{ + /** + * @covers \Engelsystem\Renderer\Twig\Extensions\Assets::__construct + * @covers \Engelsystem\Renderer\Twig\Extensions\Assets::getFunctions + */ + public function testGetGlobals() + { + /** @var UrlGenerator|MockObject $urlGenerator */ + $urlGenerator = $this->createMock(UrlGenerator::class); + + $extension = new Assets($urlGenerator); + $functions = $extension->getFunctions(); + + $this->assertExtensionExists('asset', [$extension, 'getAsset'], $functions); + } + + /** + * @covers \Engelsystem\Renderer\Twig\Extensions\Assets::getAsset + */ + public function testGetAsset() + { + /** @var UrlGenerator|MockObject $urlGenerator */ + $urlGenerator = $this->createMock(UrlGenerator::class); + + $urlGenerator->expects($this->exactly(2)) + ->method('to') + ->with('/assets/foo.css') + ->willReturn('https://foo.bar/project/assets/foo.css'); + + $extension = new Assets($urlGenerator); + + $return = $extension->getAsset('assets/foo.css'); + $this->assertEquals('https://foo.bar/project/assets/foo.css', $return); + + $return = $extension->getAsset('/assets/foo.css'); + $this->assertEquals('https://foo.bar/project/assets/foo.css', $return); + } +} |