JqueryExtensionTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 1
cbo 3
dl 0
loc 57
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetName() 0 4 1
A setUp() 0 5 1
A testWithId() 0 12 1
A testWithOutLocal() 0 9 1
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
}