-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature/PHPGL-10 Add form_type tag to compiler pass collector
- Loading branch information
maciej
committed
Nov 30, 2015
1 parent
3386f3d
commit 39be37e
Showing
5 changed files
with
82 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
tests/Bundle/DependencyInjection/Compiler/CommandHandlersCompilerPassTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
namespace tests\Clearcode\CommandBusConsole\Bundle\DependencyInjection\Compiler; | ||
|
||
use Clearcode\CommandBusConsole\Bundle\DependencyInjection\Compiler\CommandHandlersCompilerPass; | ||
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
|
||
class CommandHandlersCompilerPassTest extends AbstractCompilerPassTestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function it_should_collects_classes_names_by_adding_method_when_there_is_handles_argument() | ||
{ | ||
$collectingService = new Definition(); | ||
$this->setDefinition('command_bus_console.command_collector', $collectingService); | ||
|
||
$collectedService = new Definition(); | ||
$collectedService->addTag('command_handler', ['handles' => 'test_class']); | ||
$this->setDefinition('colected_service_id', $collectedService); | ||
|
||
$this->compile(); | ||
|
||
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall( | ||
'command_bus_console.command_collector', | ||
'processCommandServices', | ||
[[['handles' => 'test_class']]] | ||
); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_should_collects_classes_names_and_form_types_by_adding_method_when_there_is_form_type_argument() | ||
{ | ||
$collectingService = new Definition(); | ||
$this->setDefinition('command_bus_console.command_collector', $collectingService); | ||
|
||
$collectedService = new Definition(); | ||
$collectedService->addTag('command_handler', ['handles' => 'test_class', 'form_type' => 'form_type_name']); | ||
$this->setDefinition('colected_service_id', $collectedService); | ||
|
||
$this->compile(); | ||
|
||
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall( | ||
'command_bus_console.command_collector', | ||
'processCommandServices', | ||
[[[ | ||
'handles' => 'test_class', | ||
'form_type' => 'form_type_name' | ||
]]] | ||
); | ||
} | ||
|
||
/** | ||
* Register the compiler pass under test, just like you would do inside a bundle's load() | ||
* method: | ||
* | ||
* $container->addCompilerPass(new MyCompilerPass()); | ||
*/ | ||
protected function registerCompilerPass(ContainerBuilder $container) | ||
{ | ||
$container->addCompilerPass(new CommandHandlersCompilerPass()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters