You are here

public function ServiceContainerCToolsIntegrationTest::testCToolsPlugin in Service Container 7.2

Same name and namespace in other branches
  1. 7 lib/Drupal/service_container/Tests/ServiceContainerCToolsIntegrationTest.php \Drupal\service_container\Tests\ServiceContainerCToolsIntegrationTest::testCToolsPlugin()

Tests if a particular CTools plugin is available.

File

lib/Drupal/service_container/Tests/ServiceContainerCToolsIntegrationTest.php, line 57
Contains \Drupal\service_container\Tests\ServiceContainerCToolsIntegrationTest.

Class

ServiceContainerCToolsIntegrationTest

Namespace

Drupal\service_container\Tests

Code

public function testCToolsPlugin() {
  $service = \Drupal::service('service_container_test_ctools.ServiceContainerTestCtoolsPlugin')
    ->createInstance('ServiceContainerTestCtoolsPluginTest1');
  $this
    ->assertEqual($service
    ->beep(), 'beep!');
  try {
    $service = \Drupal::service('service_container_test_ctools.yolo')
      ->createInstance('yolo1');
  } catch (\Exception $e) {
    $this
      ->pass('Non-existant plugin does not exist in the container.');
  }

  // @todo Test and fix instantiating non-class plugins.
}