Completed
Pull Request — master (#5)
by GBProd
03:43
created

ElasticaSpecificationExtensionTest   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

8 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 7 1
A testLoadHasServices() 0 16 1
A load() 0 5 1
A testLoadQueryBuilder() 0 8 1
A testLoadRegistry() 0 8 1
A testLoadHandler() 0 8 1
A testLoadDsl() 0 8 1
A testLoadCustomizedDsl() 0 10 1
1
<?php
2
3
namespace Tests\GBProd\ElasticaSpecificationBundle\DependencyInjection;
4
5
use Elastica\QueryBuilder;
6
use Elastica\QueryBuilder\Version\Latest;
7
use Elastica\QueryBuilder\Version\Version120;
8
use GBProd\ElasticaSpecificationBundle\DependencyInjection\ElasticaSpecificationExtension;
9
use GBProd\ElasticaSpecification\Handler;
10
use GBProd\ElasticaSpecification\Registry;
11
use Symfony\Component\DependencyInjection\ContainerBuilder;
12
13
/**
14
 * Tests for ElasticaSpecificationExtension
15
 *
16
 * @author gbprod <[email protected]>
17
 */
18
class ElasticaSpecificationExtensionTest extends \PHPUnit_Framework_TestCase
19
{
20
    private $extension;
21
    private $container;
22
23
    protected function setUp()
24
    {
25
        $this->extension = new ElasticaSpecificationExtension();
26
27
        $this->container = new ContainerBuilder();
28
        $this->container->registerExtension($this->extension);
29
    }
30
31
    public function testLoadHasServices()
32
    {
33
        $this->load();
34
35
        $this->assertTrue(
36
            $this->container->has('gbprod.elastica_specification_querybuilder')
37
        );
38
39
        $this->assertTrue(
40
            $this->container->has('gbprod.elastica_specification_registry')
41
        );
42
43
        $this->assertTrue(
44
            $this->container->has('gbprod.elastica_specification_handler')
45
        );
46
    }
47
48
    private function load(array $config = [])
49
    {
50
        $this->container->loadFromExtension($this->extension->getAlias(), $config);
51
        $this->container->compile();
52
    }
53
54
    public function testLoadQueryBuilder()
55
    {
56
        $this->load();
57
58
        $registry = $this->container->get('gbprod.elastica_specification_querybuilder');
59
60
        $this->assertInstanceOf(QueryBuilder::class, $registry);
61
    }
62
63
    public function testLoadRegistry()
64
    {
65
        $this->load();
66
67
        $registry = $this->container->get('gbprod.elastica_specification_registry');
68
69
        $this->assertInstanceOf(Registry::class, $registry);
70
    }
71
72
    public function testLoadHandler()
73
    {
74
        $this->load();
75
76
        $handler = $this->container->get('gbprod.elastica_specification_handler');
77
78
        $this->assertInstanceOf(Handler::class, $handler);
79
    }
80
81
    public function testLoadDsl()
82
    {
83
        $this->load();
84
85
        $dsl = $this->container->get('gbprod.elastica_specification_dsl');
86
87
        $this->assertInstanceOf(Latest::class, $dsl);
88
    }
89
90
    public function testLoadCustomizedDsl()
91
    {
92
        $this->load([
93
            'dsl_version' => 'Version120',
94
        ]);
95
96
        $dsl = $this->container->get('gbprod.elastica_specification_dsl');
97
98
        $this->assertInstanceOf(Version120::class, $dsl);
99
    }
100
}
101