function DiscoveryTraitTest::testDoGetDefinition

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

@covers ::doGetDefinition @dataProvider providerDoGetDefinition

File

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

Class

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

Namespace

Drupal\Tests\Component\Plugin\Discovery

Code

public function testDoGetDefinition($expected, $definitions, $plugin_id) {
    // Mock the trait.
    $trait = $this->getMockForTrait('Drupal\\Component\\Plugin\\Discovery\\DiscoveryTrait');
    // Un-protect the method using reflection.
    $method_ref = new \ReflectionMethod($trait, 'doGetDefinition');
    $method_ref->setAccessible(TRUE);
    // Call doGetDefinition, with $exception_on_invalid always FALSE.
    $this->assertSame($expected, $method_ref->invoke($trait, $definitions, $plugin_id, FALSE));
}

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