|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GBProd\Tests\Units\ElasticsearchExtraBundle\Command; |
|
4
|
|
|
|
|
5
|
|
|
use atoum; |
|
6
|
|
|
use mock\GBProd\ElasticsearchExtraBundle\Handler\CreateIndexHandler; |
|
7
|
|
|
use Symfony\Component\Console\Input\ArrayInput; |
|
8
|
|
|
use mock\Symfony\Component\Console\Output\OutputInterface; |
|
9
|
|
|
use Symfony\Component\DependencyInjection\Container; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Tests for CreateIndexCommand |
|
13
|
|
|
* |
|
14
|
|
|
* @author gbprod <[email protected]> |
|
15
|
|
|
*/ |
|
16
|
|
|
class CreateIndexCommand extends atoum |
|
17
|
|
|
{ |
|
18
|
|
|
public function testCreateIndexCallsHandler() |
|
19
|
|
|
{ |
|
20
|
|
|
$this |
|
21
|
|
|
->given($this->newTestedInstance) |
|
22
|
|
|
->and($handler = $this->newCreateIndexHandler()) |
|
23
|
|
|
->and($container = $this->createContainer($handler)) |
|
24
|
|
|
->and($this->testedInstance->setContainer($container)) |
|
25
|
|
|
->and($input = new ArrayInput([ |
|
26
|
|
|
'client_id' => 'my_client', |
|
27
|
|
|
'index_id' => 'my_index', |
|
28
|
|
|
])) |
|
29
|
|
|
->and($output = new OutputInterface()) |
|
30
|
|
|
->if($this->testedInstance->run($input, $output)) |
|
31
|
|
|
->then |
|
32
|
|
|
->mock($handler) |
|
33
|
|
|
->call('handle') |
|
34
|
|
|
->withArguments('my_client', 'my_index') |
|
35
|
|
|
->once() |
|
36
|
|
|
; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
private function newCreateIndexHandler() |
|
40
|
|
|
{ |
|
41
|
|
|
$this->mockGenerator->shuntParentClassCalls(); |
|
42
|
|
|
$this->mockGenerator->orphanize('__construct'); |
|
43
|
|
|
|
|
44
|
|
|
$handler = new CreateIndexHandler(); |
|
45
|
|
|
|
|
46
|
|
|
return $handler; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function createContainer($handler) |
|
50
|
|
|
{ |
|
51
|
|
|
$container = new Container(); |
|
52
|
|
|
$container->set( |
|
53
|
|
|
'gbprod.elasticsearch_extra.create_index_handler', |
|
54
|
|
|
$handler |
|
55
|
|
|
); |
|
56
|
|
|
|
|
57
|
|
|
return $container; |
|
58
|
|
|
} |
|
59
|
|
|
} |