You are here

protected function ContainerAwarePluginManagerTest::getContainerDefinition in Service Container 7.2

Same name and namespace in other branches
  1. 7 tests/src/Plugin/ContainerAwarePluginManagerTest.php \Drupal\Tests\service_container\Plugin\ContainerAwarePluginManagerTest::getContainerDefinition()

Returns a container definition used for testing.

Return value

array The container definition with services and parameters.

1 call to ContainerAwarePluginManagerTest::getContainerDefinition()
ContainerAwarePluginManagerTest::setUp in tests/src/Plugin/ContainerAwarePluginManagerTest.php

File

tests/src/Plugin/ContainerAwarePluginManagerTest.php, line 80
Contains \Drupal\Tests\service_container\Plugin\ContainerAwarePluginManagerTest

Class

ContainerAwarePluginManagerTest
@coversDefaultClass \Drupal\service_container\Plugin\ContainerAwarePluginManager @group dic

Namespace

Drupal\Tests\service_container\Plugin

Code

protected function getContainerDefinition() {
  $parameters = array();

  // This are just example classes.
  $mock_render_stack = Mockery::mock('\\Drupal\\render_cache\\Cache\\RenderStackInterface');
  $mock_cache_adapter = Mockery::mock('\\Drupal\\render_cache\\Cache\\RenderCacheBackendAdapterInterface');
  $mock_block_controller = Mockery::mock('\\Drupal\\render_cache_block\\RenderCache\\Controller\\BlockController');
  $services = array();
  $services['service_container'] = array(
    'class' => '\\Drupal\\service_container\\DependencyInjection\\Container',
  );
  $services['render_stack'] = array(
    'class' => get_class($mock_render_stack),
  );
  $services['service_container.cache'] = array(
    'class' => get_class($mock_cache_adapter),
    'arguments' => array(
      '@render_stack',
    ),
  );
  $services['service_container.controller'] = array(
    'class' => '\\Drupal\\service_container\\Plugin\\ContainerAwarePluginManager',
    'arguments' => array(
      'service_container.controller.internal.',
    ),
    'calls' => array(
      array(
        'setContainer',
        array(
          '@service_container',
        ),
      ),
    ),
    'tags' => array(
      array(
        'ctools.plugin',
        array(
          'owner' => 'service_container',
          'type' => 'controller',
          'prefix' => 'service_container.controller.internal.',
        ),
      ),
    ),
  );

  // This would have been autogenerated by the ctools.plugin tag definition.
  $services['service_container.controller.internal.block'] = array(
    'class' => get_class($mock_block_controller),
    'arguments' => array(
      array(
        'class' => get_class($mock_block_controller),
        'name' => 'Block',
        'arguments' => array(
          '@render_stack',
          '@service_container.cache',
        ),
      ),
      '@render_stack',
      '@service_container.cache',
    ),
    'public' => FALSE,
  );
  return array(
    'parameters' => $parameters,
    'services' => $services,
  );
}