public function HookDiscoveryTest::testGetDefinition in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Plugin/Discovery/HookDiscoveryTest.php \Drupal\Tests\Core\Plugin\Discovery\HookDiscoveryTest::testGetDefinition()
Tests the getDefinition method with some plugins.
See also
\Drupal\Core\Plugin\Discovery::getDefinition()
File
- core/
tests/ Drupal/ Tests/ Core/ Plugin/ Discovery/ HookDiscoveryTest.php, line 93 - Contains \Drupal\Tests\Core\Plugin\Discovery\HookDiscoveryTest.
Class
- HookDiscoveryTest
- @coversDefaultClass \Drupal\Core\Plugin\Discovery\HookDiscovery @group Plugin
Namespace
Drupal\Tests\Core\Plugin\DiscoveryCode
public function testGetDefinition() {
$this->moduleHandler
->expects($this
->exactly(4))
->method('getImplementations')
->with('test_plugin')
->will($this
->returnValue(array(
'hook_discovery_test',
'hook_discovery_test2',
)));
$this->moduleHandler
->expects($this
->any())
->method('invoke')
->will($this
->returnValueMap(array(
array(
'hook_discovery_test',
'test_plugin',
array(),
hook_discovery_test_test_plugin(),
),
array(
'hook_discovery_test2',
'test_plugin',
array(),
hook_discovery_test2_test_plugin(),
),
)));
$this
->assertNull($this->hookDiscovery
->getDefinition('test_non_existant', FALSE));
$plugin_definition = $this->hookDiscovery
->getDefinition('test_id_1');
$this
->assertEquals($plugin_definition['class'], 'Drupal\\plugin_test\\Plugin\\plugin_test\\fruit\\Apple');
$this
->assertEquals($plugin_definition['provider'], 'hook_discovery_test');
$plugin_definition = $this->hookDiscovery
->getDefinition('test_id_2');
$this
->assertEquals($plugin_definition['class'], 'Drupal\\plugin_test\\Plugin\\plugin_test\\fruit\\Orange');
$this
->assertEquals($plugin_definition['provider'], 'hook_discovery_test');
$plugin_definition = $this->hookDiscovery
->getDefinition('test_id_3');
$this
->assertEquals($plugin_definition['class'], 'Drupal\\plugin_test\\Plugin\\plugin_test\\fruit\\Cherry');
$this
->assertEquals($plugin_definition['provider'], 'hook_discovery_test2');
}