|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Evheniy\TwitterBootstrapBundle\Tests\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
6
|
|
|
use Symfony\Component\Config\FileLocator; |
|
7
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
|
8
|
|
|
use Evheniy\TwitterBootstrapBundle\DependencyInjection\TwitterBootstrapExtension; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class TwitterBootstrapExtensionTest |
|
12
|
|
|
* |
|
13
|
|
|
* @package Evheniy\TwitterBootstrapBundle\Tests\DependencyInjection |
|
14
|
|
|
*/ |
|
15
|
|
|
class TwitterBootstrapExtensionTest extends \PHPUnit_Framework_TestCase |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @var TwitterBootstrapExtension |
|
19
|
|
|
*/ |
|
20
|
|
|
private $extension; |
|
21
|
|
|
/** |
|
22
|
|
|
* @var ContainerBuilder |
|
23
|
|
|
*/ |
|
24
|
|
|
private $container; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* |
|
28
|
|
|
*/ |
|
29
|
|
|
protected function setUp() |
|
30
|
|
|
{ |
|
31
|
|
|
$this->extension = new TwitterBootstrapExtension(); |
|
32
|
|
|
|
|
33
|
|
|
$this->container = new ContainerBuilder(); |
|
34
|
|
|
$this->container->registerExtension($this->extension); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param ContainerBuilder $container |
|
39
|
|
|
* @param string $resource |
|
40
|
|
|
* |
|
41
|
|
|
* @return ContainerBuilder |
|
42
|
|
|
*/ |
|
43
|
|
|
protected function loadConfiguration(ContainerBuilder $container, $resource) |
|
44
|
|
|
{ |
|
45
|
|
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/Fixtures/')); |
|
46
|
|
|
$loader->load($resource . '.yml'); |
|
47
|
|
|
|
|
48
|
|
|
return $container; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Test empty config |
|
53
|
|
|
*/ |
|
54
|
|
|
public function testWithoutConfiguration() |
|
55
|
|
|
{ |
|
56
|
|
|
$this->container->loadFromExtension($this->extension->getAlias())->compile(); |
|
57
|
|
|
|
|
58
|
|
|
$twitterBootstrap = $this->container->getParameter('twitter_bootstrap'); |
|
59
|
|
|
$this->assertEquals($twitterBootstrap['local_js'], '@TwitterBootstrapBundle/Resources/public/js/bootstrap.min.js'); |
|
60
|
|
|
$this->assertEquals($this->container->getParameter('twitter_bootstrap.local_js'), '@TwitterBootstrapBundle/Resources/public/js/bootstrap.min.js'); |
|
61
|
|
|
$this->assertEquals($twitterBootstrap['local_fonts_dir'], '@TwitterBootstrapBundle/Resources/public/fonts/'); |
|
62
|
|
|
$this->assertEquals($this->container->getParameter('twitter_bootstrap.local_fonts_dir'), '@TwitterBootstrapBundle/Resources/public/fonts/'); |
|
63
|
|
|
$this->assertEquals($twitterBootstrap['local_css'], '@TwitterBootstrapBundle/Resources/public/css/bootstrap.min.css'); |
|
64
|
|
|
$this->assertEquals($this->container->getParameter('twitter_bootstrap.local_css'), '@TwitterBootstrapBundle/Resources/public/css/bootstrap.min.css'); |
|
65
|
|
|
$this->assertEquals($twitterBootstrap['local_theme'], '@TwitterBootstrapBundle/Resources/public/css/bootstrap-theme.min.css'); |
|
66
|
|
|
$this->assertEquals($this->container->getParameter('twitter_bootstrap.local_theme'), '@TwitterBootstrapBundle/Resources/public/css/bootstrap-theme.min.css'); |
|
67
|
|
|
$this->assertEmpty($twitterBootstrap['local_cdn']); |
|
68
|
|
|
$this->assertEquals($twitterBootstrap['local_cdn'], ''); |
|
69
|
|
|
$this->assertEquals($twitterBootstrap['version'], '3.3.4'); |
|
70
|
|
|
$this->assertNotEmpty($twitterBootstrap['html5']); |
|
71
|
|
|
$this->assertTrue($twitterBootstrap['html5']); |
|
72
|
|
|
$this->assertEmpty($twitterBootstrap['async']); |
|
73
|
|
|
$this->assertFalse($twitterBootstrap['async']); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Test normal config |
|
78
|
|
|
*/ |
|
79
|
|
|
public function testTest() |
|
80
|
|
|
{ |
|
81
|
|
|
$this->loadConfiguration($this->container, 'test')->compile(); |
|
82
|
|
|
$this->assertTrue($this->container->hasParameter('twitter_bootstrap')); |
|
83
|
|
|
$this->assertTrue($this->container->hasParameter('twitter_bootstrap.local_js')); |
|
84
|
|
|
$twitterBootstrap = $this->container->getParameter('twitter_bootstrap'); |
|
85
|
|
|
$this->assertEquals($twitterBootstrap['local_js'], $this->container->getParameter('twitter_bootstrap.local_js')); |
|
86
|
|
|
$this->assertEquals($this->container->getParameter('twitter_bootstrap.local_js'), 'bootstrap.min.js'); |
|
87
|
|
|
$this->assertEquals($twitterBootstrap['local_fonts_dir'], $this->container->getParameter('twitter_bootstrap.local_fonts_dir')); |
|
88
|
|
|
$this->assertEquals($this->container->getParameter('twitter_bootstrap.local_fonts_dir'), 'fonts/'); |
|
89
|
|
|
$this->assertEquals($twitterBootstrap['local_css'], $this->container->getParameter('twitter_bootstrap.local_css')); |
|
90
|
|
|
$this->assertEquals($this->container->getParameter('twitter_bootstrap.local_css'), 'bootstrap.min.css'); |
|
91
|
|
|
$this->assertEquals($twitterBootstrap['local_theme'], $this->container->getParameter('twitter_bootstrap.local_theme')); |
|
92
|
|
|
$this->assertEquals($this->container->getParameter('twitter_bootstrap.local_theme'), 'bootstrap-theme.min.css'); |
|
93
|
|
|
$this->assertNotEmpty($twitterBootstrap['local_cdn']); |
|
94
|
|
|
$this->assertEquals($twitterBootstrap['local_cdn'], '//cdn.site.com'); |
|
95
|
|
|
$this->assertEquals($twitterBootstrap['version'], '3.3.0'); |
|
96
|
|
|
$this->assertEmpty($twitterBootstrap['html5']); |
|
97
|
|
|
$this->assertFalse($twitterBootstrap['html5']); |
|
98
|
|
|
$this->assertNotEmpty($twitterBootstrap['async']); |
|
99
|
|
|
$this->assertTrue($twitterBootstrap['async']); |
|
100
|
|
|
} |
|
101
|
|
|
} |