function DiscoveryTraitTest::testHasDefinition
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php \Drupal\Tests\Component\Plugin\Discovery\DiscoveryTraitTest::testHasDefinition()
- 10 core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php \Drupal\Tests\Component\Plugin\Discovery\DiscoveryTraitTest::testHasDefinition()
- 11.x 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 131
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')
->onlyMethods([
'getDefinition',
])
->getMockForTrait();
// Set up our mocked getDefinition() to return TRUE for 'valid' and FALSE
// for 'not_valid'.
$trait->expects($this->once())
->method('getDefinition')
->willReturnMap([
[
'valid',
FALSE,
TRUE,
],
[
'not_valid',
FALSE,
FALSE,
],
]);
// Call hasDefinition().
$this->assertSame($expected, $trait->hasDefinition($plugin_id));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.