ExtjsTWigTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B getExtensions() 0 34 2
A getFixturesDir() 0 4 1
1
<?php
2
namespace Tpg\ExtjsBundle\Tests\Twig;
3
4
use Symfony\Component\DependencyInjection\Container;
5
use Tpg\ExtjsBundle\Twig\ExtjsExtension;
6
7
class ExtjsTWigTest extends \Twig_Test_IntegrationTestCase {
8
9
    protected function getExtensions()
10
    {
11
        $generator = $this->getMock(
12
            'Tpg\ExtjsBundle\Service\GeneratorService',
13
            array('generateMarkupForEntity')
14
        );
15
        $generator->expects($this->any())
16
            ->method('generateMarkupForEntity')
17
            ->will($this->returnCallback(function($entity) {
18
                return $entity;
19
            }));
20
        $router = $this->getMock(
21
            'Symfony\Bundle\FrameworkBundle\Routing\Router',
22
            array('generate'),
23
            array(new Container(), null)
24
        );
25
        $router->expects($this->any())
26
            ->method('generate')
27
            ->will($this->returnCallback(function($url, $parameters) {
28
                $this->assertEquals('extjs_generate_model', $url);
29
                $this->assertEquals(count($parameters['model']), 2);
30
                $url = '/generateModel.js?';
31
                foreach ($parameters['model'] as $model) {
32
                    $url .= 'model[]='.$model.'&';
33
                }
34
                return substr($url, 0, -1);
35
            }));
36
        $ext = new ExtjsExtension();
37
        $ext->setGenerator($generator);
38
        $ext->setRouter($router);
39
        return array(
40
            $ext
41
        );
42
    }
43
44
    protected function getFixturesDir()
45
    {
46
        return __DIR__.'/tests/';
47
    }
48
}