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