function DiscoveryTraitTest::testGetDefinition

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php \Drupal\Tests\Component\Plugin\Discovery\DiscoveryTraitTest::testGetDefinition()
  2. 10 core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php \Drupal\Tests\Component\Plugin\Discovery\DiscoveryTraitTest::testGetDefinition()
  3. 11.x core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php \Drupal\Tests\Component\Plugin\Discovery\DiscoveryTraitTest::testGetDefinition()

@covers ::getDefinition @dataProvider providerDoGetDefinition

File

core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php, line 80

Class

DiscoveryTraitTest
@group Plugin @coversDefaultClass \Drupal\Component\Plugin\Discovery\DiscoveryTrait

Namespace

Drupal\Tests\Component\Plugin\Discovery

Code

public function testGetDefinition($expected, $definitions, $plugin_id) {
    // Since getDefinition is a wrapper around doGetDefinition(), we can re-use
    // its data provider. We just have to tell abstract method getDefinitions()
    // to use the $definitions array.
    $trait = $this->getMockForTrait('Drupal\\Component\\Plugin\\Discovery\\DiscoveryTrait');
    $trait->expects($this->once())
        ->method('getDefinitions')
        ->willReturn($definitions);
    // Call getDefinition(), with $exception_on_invalid always FALSE.
    $this->assertSame($expected, $trait->getDefinition($plugin_id, FALSE));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.