|
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
|
|
|
|