function PluginManagerBaseTest::testGetInstanceWithoutMapperShouldThrowException

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php \Drupal\Tests\Component\Plugin\PluginManagerBaseTest::testGetInstanceWithoutMapperShouldThrowException()
  2. 10 core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php \Drupal\Tests\Component\Plugin\PluginManagerBaseTest::testGetInstanceWithoutMapperShouldThrowException()
  3. 11.x core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php \Drupal\Tests\Component\Plugin\PluginManagerBaseTest::testGetInstanceWithoutMapperShouldThrowException()

@covers ::getInstance

File

core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php, line 115

Class

PluginManagerBaseTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Component%21Plugin%21PluginManagerBase.php/class/PluginManagerBase/8.9.x" title="Base class for plugin managers." class="local">\Drupal\Component\Plugin\PluginManagerBase</a> @group Plugin

Namespace

Drupal\Tests\Component\Plugin

Code

public function testGetInstanceWithoutMapperShouldThrowException() {
    $options = [
        'foo' => 'F00',
        'bar' => 'bAr',
    ];
    
    /** @var \Drupal\Component\Plugin\PluginManagerBase $manager */
    $manager = $this->getMockBuilder(PluginManagerBase::class)
        ->getMockForAbstractClass();
    // Set the expected exception thrown by ::getInstance.
    $this->expectException(\BadMethodCallException::class);
    $this->expectExceptionMessage(sprintf('%s does not support this method unless %s::$mapper is set.', get_class($manager), get_class($manager)));
    $manager->getInstance($options);
}

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