function DevelGenerateManagerTest::testCreateInstance

Same name in other branches
  1. 5.x devel_generate/tests/src/Unit/DevelGenerateManagerTest.php \Drupal\Tests\devel_generate\Unit\DevelGenerateManagerTest::testCreateInstance()

Test creating an instance of the DevelGenerateManager.

File

devel_generate/tests/src/Unit/DevelGenerateManagerTest.php, line 52

Class

DevelGenerateManagerTest
@coversDefaultClass \Drupal\devel_generate\DevelGeneratePluginManager @group devel_generate

Namespace

Drupal\Tests\devel_generate\Unit

Code

public function testCreateInstance() {
    $namespaces = new \ArrayObject([
        'Drupal\\devel_generate_example' => realpath(dirname(__FILE__) . '/../../../modules/devel_generate_example/lib'),
    ]);
    $cache_backend = $this->createMock('Drupal\\Core\\Cache\\CacheBackendInterface');
    $module_handler = $this->createMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
    $manager = new TestDevelGeneratePluginManager($namespaces, $cache_backend, $module_handler);
    $manager->setDiscovery($this->discovery);
    $example_instance = $manager->createInstance('devel_generate_example');
    $plugin_def = $example_instance->getPluginDefinition();
    $this->assertInstanceOf('Drupal\\devel_generate_example\\Plugin\\DevelGenerate\\ExampleDevelGenerate', $example_instance);
    $this->assertArrayHasKey('url', $plugin_def);
    $this->assertTrue($plugin_def['url'] == 'devel_generate_example');
}