|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Evheniy\MaterializeBundle\Tests\Twig; |
|
4
|
|
|
|
|
5
|
|
|
use Evheniy\MaterializeBundle\Twig\MaterializeExtension; |
|
6
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class MaterializeExtensionTest |
|
10
|
|
|
* |
|
11
|
|
|
* @package Evheniy\MaterializeBundle\Tests\Twig |
|
12
|
|
|
*/ |
|
13
|
|
|
class MaterializeExtensionTest extends \PHPUnit_Framework_TestCase |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* @var MaterializeExtension |
|
17
|
|
|
*/ |
|
18
|
|
|
private $extension; |
|
19
|
|
|
/** |
|
20
|
|
|
* @var ContainerBuilder |
|
21
|
|
|
*/ |
|
22
|
|
|
private $container; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* |
|
26
|
|
|
*/ |
|
27
|
|
|
protected function setUp() |
|
28
|
|
|
{ |
|
29
|
|
|
$this->container = new ContainerBuilder(); |
|
30
|
|
|
$this->extension = new MaterializeExtension($this->container); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Test normal config |
|
35
|
|
|
*/ |
|
36
|
|
|
public function testWithId() |
|
37
|
|
|
{ |
|
38
|
|
|
$this->container->setParameter('materialize', array('local_js' => 'test')); |
|
39
|
|
|
$this->assertTrue($this->container->hasParameter('materialize')); |
|
40
|
|
|
$materialize = $this->container->getParameter('materialize'); |
|
41
|
|
|
$this->assertNotEmpty($materialize); |
|
42
|
|
|
$this->assertTrue(is_array($materialize)); |
|
43
|
|
|
$this->assertNotEmpty($materialize['local_js']); |
|
44
|
|
|
$this->assertEquals($materialize['local_js'], 'test'); |
|
45
|
|
|
$globals = $this->extension->getGlobals(); |
|
46
|
|
|
$this->assertNotEmpty($globals); |
|
47
|
|
|
$this->assertTrue(is_array($globals)); |
|
48
|
|
|
$this->assertNotEmpty($globals['materialize']); |
|
49
|
|
|
$this->assertTrue(is_array($globals['materialize'])); |
|
50
|
|
|
$this->assertNotEmpty($globals['materialize']['local_js']); |
|
51
|
|
|
$this->assertEquals($globals['materialize']['local_js'], 'test'); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Test empty config |
|
56
|
|
|
*/ |
|
57
|
|
|
public function testWithOutLocal() |
|
58
|
|
|
{ |
|
59
|
|
|
$this->assertFalse($this->container->hasParameter('materialize')); |
|
60
|
|
|
$this->setExpectedException( |
|
61
|
|
|
'Exception', |
|
62
|
|
|
'You have requested a non-existent parameter "materialize".' |
|
63
|
|
|
); |
|
64
|
|
|
$this->assertNotEmpty($this->extension->getGlobals()); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Test getName() |
|
69
|
|
|
*/ |
|
70
|
|
|
public function testGetName() |
|
71
|
|
|
{ |
|
72
|
|
|
$this->assertEquals($this->extension->getName(), 'materialize'); |
|
73
|
|
|
} |
|
74
|
|
|
} |