public function ContainerBuilderTest::setUp in Service Container 7
Same name and namespace in other branches
- 7.2 tests/src/DependencyInjection/ContainerBuilderTest.php \Drupal\Tests\service_container\DependencyInjection\ContainerBuilderTest::setUp()
File
- tests/
src/ DependencyInjection/ ContainerBuilderTest.php, line 27 - Contains \Drupal\Tests\service_container\DependencyInjection\ContainerBuilderTest
Class
- ContainerBuilderTest
- @coversDefaultClass \Drupal\service_container\DependencyInjection\ContainerBuilder @group dic
Namespace
Drupal\Tests\service_container\DependencyInjectionCode
public function setUp() {
// Setup the base container definition.
$this->containerDefinition = $this
->getFakeContainerDefinition();
// Alter the definition in a specified way.
$altered_definition = $this->containerDefinition;
$altered_definition['services']['some_service']['tags'][] = array(
'name' => 'bar',
);
$altered_definition['services']['some_service']['tags'][] = array(
'name' => 'baz',
);
$altered_definition['parameters']['some_other_config'] = 'lama';
$this->alteredDefinition = $altered_definition;
// Create a service provider providing these definitions.
$service_provider = Mockery::mock('\\Drupal\\service_container\\DependencyInjection\\ServiceProviderInterface');
$service_provider
->shouldReceive('getContainerDefinition')
->once()
->andReturn($this->containerDefinition);
$service_provider
->shouldReceive('alterContainerDefinition')
->with(Mockery::on(function (&$container_definition) {
$container_definition['services']['some_service']['tags'][] = array(
'name' => 'bar',
);
$container_definition['services']['some_service']['tags'][] = array(
'name' => 'baz',
);
$container_definition['parameters']['some_other_config'] = 'lama';
return TRUE;
}))
->once();
$this->serviceProvider = $service_provider;
// Set up definitions for the Fake plugin manager.
$definitions = array(
'fake_provider' => array(
'class' => '\\Drupal\\Tests\\service_container\\DependencyInjection\\FakeProvider',
),
);
// And create a static plugin manager mock.
$service_provider_manager = Mockery::mock('\\Drupal\\Component\\Plugin\\PluginManagerInterface', array(
'getDefinitions' => $definitions,
'getDefinition' => $definitions['fake_provider'],
'hasDefinition' => TRUE,
'createInstance' => $this->serviceProvider,
'getInstance' => $this->serviceProvider,
));
$this->serviceProviderManager = $service_provider_manager;
}