|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the core-bundle package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) 2018 WEBEWEB |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace WBW\Bundle\CoreBundle\Tests\Twig\Extension; |
|
13
|
|
|
|
|
14
|
|
|
use Twig\Extension\ExtensionInterface; |
|
15
|
|
|
use WBW\Bundle\CoreBundle\Tests\AbstractTestCase; |
|
16
|
|
|
use WBW\Bundle\CoreBundle\Tests\Fixtures\Twig\Extension\TestTwigExtension; |
|
17
|
|
|
use WBW\Bundle\CoreBundle\Twig\Extension\AbstractTwigExtension; |
|
18
|
|
|
use WBW\Library\Symfony\Assets\NavigationNodeInterface; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Abstract Twig extension test. |
|
22
|
|
|
* |
|
23
|
|
|
* @author webeweb <https://github.com/webeweb> |
|
24
|
|
|
* @package WBW\Bundle\CoreBundle\Tests\Twig\Extension |
|
25
|
|
|
*/ |
|
26
|
|
|
class AbstractTwigExtensionTest extends AbstractTestCase { |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Test coreHtmlElement() |
|
30
|
|
|
* |
|
31
|
|
|
* @return void |
|
32
|
|
|
*/ |
|
33
|
|
|
public function testCoreHtmlElement(): void { |
|
34
|
|
|
|
|
35
|
|
|
$arg = [ |
|
36
|
|
|
"type" => "text/javascript", |
|
37
|
|
|
]; |
|
38
|
|
|
$exp = file_get_contents(__DIR__ . "/AbstractTwigExtensionTest.testCoreHtmlElement.html.txt"); |
|
39
|
|
|
|
|
40
|
|
|
$this->assertEquals($exp, TestTwigExtension::coreHtmlElement("script", "\n $(document).ready(function() {});\n", $arg) . "\n"); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Test getFilters() |
|
45
|
|
|
* |
|
46
|
|
|
* @return void |
|
47
|
|
|
*/ |
|
48
|
|
|
public function testGetFilters(): void { |
|
49
|
|
|
|
|
50
|
|
|
$obj = new TestTwigExtension($this->twigEnvironment); |
|
51
|
|
|
|
|
52
|
|
|
$res = $obj->getFilters(); |
|
53
|
|
|
$this->assertCount(0, $res); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Test __construct() |
|
58
|
|
|
* |
|
59
|
|
|
* @return void |
|
60
|
|
|
*/ |
|
61
|
|
|
public function test__constructor(): void { |
|
62
|
|
|
|
|
63
|
|
|
$obj = new TestTwigExtension($this->twigEnvironment); |
|
64
|
|
|
|
|
65
|
|
|
$this->assertInstanceOf(ExtensionInterface::class, $obj); |
|
66
|
|
|
|
|
67
|
|
|
$this->assertEquals(" ", AbstractTwigExtension::DEFAULT_CONTENT); |
|
68
|
|
|
$this->assertEquals(NavigationNodeInterface::DEFAULT_HREF, AbstractTwigExtension::DEFAULT_HREF); |
|
69
|
|
|
$this->assertSame($this->twigEnvironment, $obj->getTwigEnvironment()); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|