/** * @expectedException \Exception */ public function testProcessAbortsOnMissingCommandAttribute() { $definition = \Mockery::mock(Definition::class); $this->container->shouldReceive('has')->with('tactician.handler.locator.symfony')->once()->andReturn(true); $this->container->shouldReceive('findDefinition')->with('tactician.handler.locator.symfony')->once()->andReturn($definition); $this->container->shouldReceive('findTaggedServiceIds')->with('tactician.handler')->once()->andReturn(['service_id_1' => [['not_command' => 'my_command']], 'service_id_2' => [['command' => 'my_command']]]); $definition->shouldReceive('addArgument')->never(); $this->compiler->process($this->container); }
public function testDoNotProcessWhenTacticianDoctrineIsNotInstalled() { if (class_exists(TransactionMiddleware::class)) { $this->markTestSkipped('"league/tactician-doctrine" is installed'); } $this->container->shouldReceive('hasParameter')->with('doctrine.entity_managers')->andReturn(true); $this->container->shouldNotReceive('getParameter')->withAnyArgs(); $this->container->shouldNotReceive('setDefinition')->withAnyArgs(); $this->container->shouldNotReceive('setAlias')->withAnyArgs(); $this->compiler->process($this->container); }
/** * Prepares the mocks */ public function setup() { $this->setup = true; $this->containerParameters = array(); $containerParameters =& $this->containerParameters; $this->containerDefinitions = array(); $containerDefinitions =& $this->containerDefinitions; $this->containerAliases = array(); $containerAliases =& $this->containerAliases; $this->containerBuilderMock = m::mock('Symfony\\Component\\DependencyInjection\\ContainerBuilder'); $this->containerBuilderMock->shouldReceive('addResource')->andReturn(); $this->containerBuilderMock->shouldReceive('setParameter')->andReturnUsing(function ($key, $value) use(&$containerParameters) { $containerParameters[$key] = $value; }); $this->containerBuilderMock->shouldReceive('setDefinition')->andReturnUsing(function ($id, $definition) use(&$containerDefinitions) { $containerDefinitions[$id] = $definition; }); $this->containerBuilderMock->shouldReceive('setAlias')->andReturnUsing(function ($alias, $id) use(&$containerAliases) { $containerAliases[$alias] = $id; }); }
public function testProcessWithDefinitionFailure() { $contextConfig = ['context1' => ['tag' => 'tag1'], 'context2' => ['tag' => 'tag2']]; $taggedServices = ['tag1' => ['id1' => [], 'id2' => []], 'tag2' => ['id3' => []]]; $this->container->shouldReceive('getParameter')->with('dms_chainlink.contexts')->once()->andReturn($contextConfig); $this->container->shouldReceive('setDefinition')->with('/^dms_chainlink\\.context\\..*/', m::type('Symfony\\Component\\DependencyInjection\\Definition'))->twice(); $this->container->shouldReceive('setAlias')->with(m::anyOf('context1', 'context2'), m::anyOf(HandleTagsPass::SERVICE_PREFIX . 'context1', HandleTagsPass::SERVICE_PREFIX . 'context2'))->twice(); $this->container->shouldReceive('hasDefinition')->with(m::anyOf(HandleTagsPass::SERVICE_PREFIX . 'context1', HandleTagsPass::SERVICE_PREFIX . 'context2'))->twice()->andReturn(false); $this->container->shouldReceive('getDefinition')->never(); $this->container->shouldReceive('getDefinition')->never(); $this->container->shouldReceive('findTaggedServiceIds')->never(); $this->pass->process($this->container); }