protected function CustomAnnotationClassDiscoveryTest::setUp

Sets up unit test environment.

Unlike Drupal\simpletest\WebTestBase::setUp(), UnitTestBase::setUp() does not install modules because tests are performed without accessing the database. Any required files must be explicitly included by the child class setUp() method.

Overrides UnitTestBase::setUp

File

drupal/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/CustomAnnotationClassDiscoveryTest.php, line 27
Contains \Drupal\system\Tests\Plugin\Discovery\CustomAnnotationClassDiscoveryTest.

Class

CustomAnnotationClassDiscoveryTest
Tests that a custom annotation class is used.

Namespace

Drupal\system\Tests\Plugin\Discovery

Code

protected function setUp() {
  parent::setUp();
  $this->expectedDefinitions = array(
    'example_1' => array(
      'id' => 'example_1',
      'custom' => 'John',
      'class' => 'Drupal\\plugin_test\\Plugin\\plugin_test\\custom_annotation\\Example1',
    ),
    'example_2' => array(
      'id' => 'example_2',
      'custom' => 'Paul',
      'class' => 'Drupal\\plugin_test\\Plugin\\plugin_test\\custom_annotation\\Example2',
    ),
  );
  $root_namespaces = new \ArrayObject(array(
    'Drupal\\plugin_test' => DRUPAL_ROOT . '/core/modules/system/tests/modules/plugin_test/lib',
  ));
  $annotation_namespaces = array(
    'Drupal\\plugin_test\\Plugin\\Annotation' => DRUPAL_ROOT . '/core/modules/system/tests/modules/plugin_test/lib',
  );
  $this->discovery = new AnnotatedClassDiscovery('plugin_test/custom_annotation', $root_namespaces, $annotation_namespaces, 'Drupal\\plugin_test\\Plugin\\Annotation\\PluginExample');
  $this->emptyDiscovery = new AnnotatedClassDiscovery('non_existing_module/non_existing_plugin_type', $root_namespaces, $annotation_namespaces, 'Drupal\\plugin_test\\Plugin\\Annotation\\PluginExample');
}