| @@ 16-61 (lines=46) @@ | ||
| 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 | $this->mockGenerator->unshuntParentClassCalls(); |
|
| 47 | ||
| 48 | return $handler; |
|
| 49 | } |
|
| 50 | ||
| 51 | public function createContainer($handler) |
|
| 52 | { |
|
| 53 | $container = new Container(); |
|
| 54 | $container->set( |
|
| 55 | 'gbprod.elasticsearch_extra.create_index_handler', |
|
| 56 | $handler |
|
| 57 | ); |
|
| 58 | ||
| 59 | return $container; |
|
| 60 | } |
|
| 61 | } |
|
| @@ 16-61 (lines=46) @@ | ||
| 13 | * |
|
| 14 | * @author gbprod <[email protected]> |
|
| 15 | */ |
|
| 16 | class PutIndexMappingsCommand extends atoum |
|
| 17 | { |
|
| 18 | public function testCreateIndexCallsHandler() |
|
| 19 | { |
|
| 20 | $this |
|
| 21 | ->given($this->newTestedInstance) |
|
| 22 | ->and($handler = $this->newPutIndexMappingsHandler()) |
|
| 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 newPutIndexMappingsHandler() |
|
| 40 | { |
|
| 41 | $this->mockGenerator->shuntParentClassCalls(); |
|
| 42 | $this->mockGenerator->orphanize('__construct'); |
|
| 43 | ||
| 44 | $handler = new PutIndexMappingsHandler(); |
|
| 45 | ||
| 46 | $this->mockGenerator->unshuntParentClassCalls(); |
|
| 47 | ||
| 48 | return $handler; |
|
| 49 | } |
|
| 50 | ||
| 51 | public function createContainer($handler) |
|
| 52 | { |
|
| 53 | $container = new Container(); |
|
| 54 | $container->set( |
|
| 55 | 'gbprod.elasticsearch_extra.put_index_mappings_handler', |
|
| 56 | $handler |
|
| 57 | ); |
|
| 58 | ||
| 59 | return $container; |
|
| 60 | } |
|
| 61 | } |
|
| @@ 16-61 (lines=46) @@ | ||
| 13 | * |
|
| 14 | * @author gbprod <[email protected]> |
|
| 15 | */ |
|
| 16 | class PutIndexSettingsCommand extends atoum |
|
| 17 | { |
|
| 18 | public function testCreateIndexCallsHandler() |
|
| 19 | { |
|
| 20 | $this |
|
| 21 | ->given($this->newTestedInstance) |
|
| 22 | ->and($handler = $this->newPutIndexSettingsHandler()) |
|
| 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 newPutIndexSettingsHandler() |
|
| 40 | { |
|
| 41 | $this->mockGenerator->shuntParentClassCalls(); |
|
| 42 | $this->mockGenerator->orphanize('__construct'); |
|
| 43 | ||
| 44 | $handler = new PutIndexSettingsHandler(); |
|
| 45 | ||
| 46 | $this->mockGenerator->unshuntParentClassCalls(); |
|
| 47 | ||
| 48 | return $handler; |
|
| 49 | } |
|
| 50 | ||
| 51 | public function createContainer($handler) |
|
| 52 | { |
|
| 53 | $container = new Container(); |
|
| 54 | $container->set( |
|
| 55 | 'gbprod.elasticsearch_extra.put_index_settings_handler', |
|
| 56 | $handler |
|
| 57 | ); |
|
| 58 | ||
| 59 | return $container; |
|
| 60 | } |
|
| 61 | } |
|