function DerivativeDiscoveryDecoratorTest::testGetDeriverClassWithInvalidClassedDefinitions

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php \Drupal\Tests\Core\Plugin\Discovery\DerivativeDiscoveryDecoratorTest::testGetDeriverClassWithInvalidClassedDefinitions()
  2. 8.9.x core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php \Drupal\Tests\Core\Plugin\Discovery\DerivativeDiscoveryDecoratorTest::testGetDeriverClassWithInvalidClassedDefinitions()
  3. 11.x core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php \Drupal\Tests\Core\Plugin\Discovery\DerivativeDiscoveryDecoratorTest::testGetDeriverClassWithInvalidClassedDefinitions()

@covers ::getDeriverClass

File

core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php, line 120

Class

DerivativeDiscoveryDecoratorTest
Unit tests for the derivative discovery decorator.

Namespace

Drupal\Tests\Core\Plugin\Discovery

Code

public function testGetDeriverClassWithInvalidClassedDefinitions() : void {
    $definition = $this->prophesize(DerivablePluginDefinitionInterface::class);
    $definition->id()
        ->willReturn('non_existent_discovery');
    $definition->getDeriver()
        ->willReturn('\\Drupal\\system\\Tests\\Plugin\\NonExistentDeriver');
    $definitions['non_existent_discovery'] = $definition->reveal();
    $this->discoveryMain
        ->expects($this->any())
        ->method('getDefinitions')
        ->willReturn($definitions);
    $discovery = new DerivativeDiscoveryDecorator($this->discoveryMain);
    $this->expectException(InvalidDeriverException::class);
    $this->expectExceptionMessage('Plugin (non_existent_discovery) deriver "\\Drupal\\system\\Tests\\Plugin\\NonExistentDeriver" does not exist.');
    $discovery->getDefinitions();
}

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