public function DiscoveryTraitTest::testHasDefinition in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php \Drupal\Tests\Component\Plugin\Discovery\DiscoveryTraitTest::testHasDefinition()
@covers ::hasDefinition @dataProvider providerHasDefinition
File
- core/
tests/ Drupal/ Tests/ Component/ Plugin/ Discovery/ DiscoveryTraitTest.php, line 141 - Contains \Drupal\Tests\Component\Plugin\Discovery\DiscoveryTraitTest.
Class
- DiscoveryTraitTest
- @group Plugin @coversDefaultClass Drupal\Component\Plugin\Discovery\DiscoveryTrait
Namespace
Drupal\Tests\Component\Plugin\DiscoveryCode
public function testHasDefinition($expected, $plugin_id) {
$trait = $this
->getMockBuilder('Drupal\\Component\\Plugin\\Discovery\\DiscoveryTrait')
->setMethods(array(
'getDefinition',
))
->getMockForTrait();
// Set up our mocked getDefinition() to return TRUE for 'valid' and FALSE
// for 'not_valid'.
$trait
->expects($this
->once())
->method('getDefinition')
->will($this
->returnValueMap(array(
[
'valid',
FALSE,
TRUE,
],
[
'not_valid',
FALSE,
FALSE,
],
)));
// Call hasDefinition().
$this
->assertSame($expected, $trait
->hasDefinition($plugin_id));
}