1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Evheniy\TwitterBootstrap\Tests\Twig; |
4
|
|
|
|
5
|
|
|
use Evheniy\TwitterBootstrapBundle\Twig\TwitterBootstrapExtension; |
6
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class TwitterBootstrapExtensionTest |
10
|
|
|
* |
11
|
|
|
* @package Evheniy\TwitterBootstrapBundle\Tests\Twig |
12
|
|
|
*/ |
13
|
|
|
class TwitterBootstrapExtensionTest extends \PHPUnit_Framework_TestCase |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var TwitterBootstrapExtension |
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 TwitterBootstrapExtension($this->container); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Test normal config |
35
|
|
|
*/ |
36
|
|
|
public function testWithId() |
37
|
|
|
{ |
38
|
|
|
$this->container->setParameter('twitter_bootstrap', array('local_js' => 'test')); |
39
|
|
|
$this->assertTrue($this->container->hasParameter('twitter_bootstrap')); |
40
|
|
|
$twitterBootstrap = $this->container->getParameter('twitter_bootstrap'); |
41
|
|
|
$this->assertNotEmpty($twitterBootstrap); |
42
|
|
|
$this->assertTrue(is_array($twitterBootstrap)); |
43
|
|
|
$this->assertNotEmpty($twitterBootstrap['local_js']); |
44
|
|
|
$this->assertEquals($twitterBootstrap['local_js'], 'test'); |
45
|
|
|
$globals = $this->extension->getGlobals(); |
46
|
|
|
$this->assertNotEmpty($globals); |
47
|
|
|
$this->assertTrue(is_array($globals)); |
48
|
|
|
$this->assertNotEmpty($globals['twitter_bootstrap']); |
49
|
|
|
$this->assertTrue(is_array($globals['twitter_bootstrap'])); |
50
|
|
|
$this->assertNotEmpty($globals['twitter_bootstrap']['local_js']); |
51
|
|
|
$this->assertEquals($globals['twitter_bootstrap']['local_js'], 'test'); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Test empty config |
56
|
|
|
*/ |
57
|
|
|
public function testWithOutLocal() |
58
|
|
|
{ |
59
|
|
|
$this->assertFalse($this->container->hasParameter('twitter_bootstrap')); |
60
|
|
|
$this->setExpectedException( |
61
|
|
|
'Exception', |
62
|
|
|
'You have requested a non-existent parameter "twitter_bootstrap".' |
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(), 'twitter_bootstrap'); |
73
|
|
|
} |
74
|
|
|
} |