You are here

function ServiceContainerAnnotationDiscoveryIntegrationTest::testMultiple in Service Container 7.2

Same name and namespace in other branches
  1. 7 modules/providers/service_container_annotation_discovery/lib/Drupal/service_container_annotation_discovery/Tests/ServiceContainerAnnotationDiscoveryIntegrationTest.php \Drupal\service_container_annotation_discovery\Tests\ServiceContainerAnnotationDiscoveryIntegrationTest::testMultiple()

Tests if multiple module with plugins annotations are available as services.

File

modules/providers/service_container_annotation_discovery/lib/Drupal/service_container_annotation_discovery/Tests/ServiceContainerAnnotationDiscoveryIntegrationTest.php, line 105
Contains \Drupal\service_container_annotation_discovery\Tests\ServiceContainerBlockIntegrationTest.

Class

ServiceContainerAnnotationDiscoveryIntegrationTest

Namespace

Drupal\service_container_annotation_discovery\Tests

Code

function testMultiple() {
  $plugins = array(
    array(
      'owner' => 'sc_doctrine_test',
      'type' => 'Plugin1',
      'name' => 'Plugin1A',
    ),
    array(
      'owner' => 'sc_doctrine_test',
      'type' => 'Plugin5',
      'name' => 'Plugin5B',
    ),
  );
  foreach ($plugins as $plugin) {
    $plugin_manager = $this->container
      ->get($plugin['owner'] . '.' . $plugin['type']);
    $this
      ->assertTrue($plugin_manager
      ->hasDefinition($plugin['name']));
    $object = $plugin_manager
      ->createInstance($plugin['name']);
    $this
      ->assertTrue($object instanceof PluginBase);
  }
}