public function ContainerBuilderTest::test_compile in Service Container 7.2
Same name and namespace in other branches
- 7 tests/src/DependencyInjection/ContainerBuilderTest.php \Drupal\Tests\service_container\DependencyInjection\ContainerBuilderTest::test_compile()
@covers ::compile()
File
- tests/
src/ DependencyInjection/ ContainerBuilderTest.php, line 152 - 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 test_compile() {
// Create a fake container class implementing the interface.
$fake_container = Mockery::mock('\\Drupal\\service_container\\DependencyInjection\\ContainerInterface');
$fake_container_class = get_class($fake_container);
$container_builder = Mockery::mock('\\Drupal\\service_container\\DependencyInjection\\ContainerBuilder[moduleAlter]', array(
$this->serviceProviderManager,
));
$container_builder
->shouldAllowMockingProtectedMethods();
$container_builder
->shouldReceive('moduleAlter')
->with(Mockery::on(function (&$container_definition) use ($fake_container_class) {
$container_definition['services']['service_container']['class'] = $fake_container_class;
return TRUE;
}));
$container = $container_builder
->compile();
// Check this returns the right expected class and interfaces.
$this
->assertEquals(TRUE, $container instanceof ContainerInterface, 'Container has instanceof ContainerInterface.');
$this
->assertEquals(TRUE, $container instanceof MockInterface, 'Container has instanceof MockInterface.');
$this
->assertEquals(TRUE, $container instanceof $fake_container_class, 'Container has instanceof dynamic fake container class.');
}