You are here

public function ContainerBuilderTest::test_alter in Service Container 7

Same name and namespace in other branches
  1. 7.2 tests/src/DependencyInjection/ContainerBuilderTest.php \Drupal\Tests\service_container\DependencyInjection\ContainerBuilderTest::test_alter()

@covers ::getContainerDefinition() @covers ::moduleAlter()

File

tests/src/DependencyInjection/ContainerBuilderTest.php, line 97
Contains \Drupal\Tests\service_container\DependencyInjection\ContainerBuilderTest

Class

ContainerBuilderTest
@coversDefaultClass \Drupal\service_container\DependencyInjection\ContainerBuilder @group dic

Namespace

Drupal\Tests\service_container\DependencyInjection

Code

public function test_alter() {
  $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) {
    $container_definition['services']['foo'] = array(
      'class' => 'FooService',
    );
    return TRUE;
  }));
  $altered_definition = $this->alteredDefinition;
  $altered_definition['services']['foo'] = array(
    'class' => 'FooService',
  );
  $definition = $container_builder
    ->getContainerDefinition();
  $this
    ->assertEquals($definition, $altered_definition, 'Definition of the container when altered matches.');
}