class DevelGenerateManagerTest
Same name in other branches
- 4.x devel_generate/tests/src/Unit/DevelGenerateManagerTest.php \Drupal\Tests\devel_generate\Unit\DevelGenerateManagerTest
- 5.x devel_generate/tests/src/Unit/DevelGenerateManagerTest.php \Drupal\Tests\devel_generate\Unit\DevelGenerateManagerTest
@coversDefaultClass \Drupal\devel_generate\DevelGeneratePluginManager @group devel_generate
Hierarchy
- class \Drupal\Tests\devel_generate\DevelGenerateManagerTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of DevelGenerateManagerTest
File
-
devel_generate/
tests/ src/ DevelGenerateManagerTest.php, line 23
Namespace
Drupal\Tests\devel_generateView source
class DevelGenerateManagerTest extends UnitTestCase {
/**
* The plugin discovery.
*
* @var \Drupal\Component\Plugin\Discovery\DiscoveryInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $discovery;
/**
* A list of devel generate plugin definitions.
*
* @var array
*/
protected $definitions = array(
'devel_generate_example' => array(
'id' => 'devel_generate_example',
'class' => 'Drupal\\devel_generate_example\\Plugin\\DevelGenerate\\ExampleDevelGenerate',
'url' => 'devel_generate_example',
),
);
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Mock a Discovery object to replace AnnotationClassDiscovery.
$this->discovery = $this->getMock('Drupal\\Component\\Plugin\\Discovery\\DiscoveryInterface');
$this->discovery
->expects($this->any())
->method('getDefinitions')
->will($this->returnValue($this->definitions));
}
/**
* Test creating an instance of the DevelGenerateManager.
*/
public function testCreateInstance() {
$namespaces = new \ArrayObject(array(
'Drupal\\devel_generate_example' => realpath(dirname(__FILE__) . '/../../../modules/devel_generate_example/lib'),
));
$cache_backend = $this->getMock('Drupal\\Core\\Cache\\CacheBackendInterface');
$module_handler = $this->getMock('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');
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
DevelGenerateManagerTest::$definitions | protected | property | A list of devel generate plugin definitions. |
DevelGenerateManagerTest::$discovery | protected | property | The plugin discovery. |
DevelGenerateManagerTest::setUp | protected | function | |
DevelGenerateManagerTest::testCreateInstance | public | function | Test creating an instance of the DevelGenerateManager. |