blob: 2d7ba6cd9735d2de5f8a26d552c7d6f57f70d102 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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);
}
}
|