|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GBProd\Tests\Units\ElasticsearchExtraBundle\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use atoum; |
|
6
|
|
|
use Elasticsearch\Client; |
|
7
|
|
|
use GBProd\ElasticsearchExtraBundle\Handler\CreateIndexHandler; |
|
8
|
|
|
use GBProd\ElasticsearchExtraBundle\Handler\DeleteIndexHandler; |
|
9
|
|
|
use GBProd\ElasticsearchExtraBundle\Handler\PutIndexSettingsHandler; |
|
10
|
|
|
use GBProd\ElasticsearchExtraBundle\Handler\PutIndexMappingsHandler; |
|
11
|
|
|
use GBProd\ElasticsearchExtraBundle\Repository\IndexConfigurationRepository; |
|
12
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
13
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Tests for Extension class |
|
17
|
|
|
* |
|
18
|
|
|
* @author gbprod <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class ElasticsearchExtraExtension extends atoum |
|
21
|
|
|
{ |
|
22
|
|
|
public function testLoadCreateServices() |
|
23
|
|
|
{ |
|
24
|
|
|
$container = new ContainerBuilder(); |
|
25
|
|
|
$this |
|
26
|
|
|
->given($extension = $this->newTestedInstance) |
|
27
|
|
|
->if($extension->load([], $container)) |
|
28
|
|
|
->then |
|
29
|
|
|
->object($container->get('gbprod.elasticsearch_extra.create_index_handler')) |
|
30
|
|
|
->isInstanceOf(CreateIndexHandler::class) |
|
31
|
|
|
->then |
|
32
|
|
|
->object($container->get('gbprod.elasticsearch_extra.index_configuration_repository')) |
|
33
|
|
|
->isInstanceOf(IndexConfigurationRepository::class) |
|
34
|
|
|
->then |
|
35
|
|
|
->object($container->get('gbprod.elasticsearch_extra.delete_index_handler')) |
|
36
|
|
|
->isInstanceOf(DeleteIndexHandler::class) |
|
37
|
|
|
->then |
|
38
|
|
|
->object($container->get('gbprod.elasticsearch_extra.put_index_settings_handler')) |
|
39
|
|
|
->isInstanceOf(PutIndexSettingsHandler::class) |
|
40
|
|
|
->then |
|
41
|
|
|
->object($container->get('gbprod.elasticsearch_extra.put_index_mappings_handler')) |
|
42
|
|
|
->isInstanceOf(PutIndexMappingsHandler::class) |
|
43
|
|
|
; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function testLoadSetIndexConfigurations() |
|
47
|
|
|
{ |
|
48
|
|
|
$configs = [ |
|
49
|
|
|
[ |
|
50
|
|
|
'indices' => [ |
|
51
|
|
|
'my_index' => [] |
|
52
|
|
|
] |
|
53
|
|
|
] |
|
54
|
|
|
]; |
|
55
|
|
|
|
|
56
|
|
|
$container = new ContainerBuilder(); |
|
57
|
|
|
$this |
|
58
|
|
|
->given($extension = $this->newTestedInstance) |
|
59
|
|
|
->if($extension->load($configs, $container)) |
|
60
|
|
|
->then |
|
61
|
|
|
->array( |
|
62
|
|
|
$container |
|
63
|
|
|
->getDefinition('gbprod.elasticsearch_extra.index_configuration_repository') |
|
64
|
|
|
->getArgument(0) |
|
65
|
|
|
) |
|
66
|
|
|
->isEqualTo([ |
|
67
|
|
|
'my_index' => [] |
|
68
|
|
|
]) |
|
69
|
|
|
; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|