function DerivativeDiscoveryDecoratorTest::testInvalidDerivativeFetcher

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

Tests the getDerivativeFetcher method with an invalid class.

See also

\Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator::getDeriver().\

File

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

Class

DerivativeDiscoveryDecoratorTest
Unit tests for the derivative discovery decorator.

Namespace

Drupal\Tests\Core\Plugin\Discovery

Code

public function testInvalidDerivativeFetcher() {
    $definitions = [];
    // Do this with a class that doesn't implement the interface.
    $definitions['invalid_discovery'] = [
        'id' => 'invalid_discovery',
        'deriver' => '\\Drupal\\KernelTests\\Core\\Plugin\\DerivativeTest',
    ];
    $this->discoveryMain
        ->expects($this->any())
        ->method('getDefinitions')
        ->willReturn($definitions);
    $discovery = new DerivativeDiscoveryDecorator($this->discoveryMain);
    $this->expectException(InvalidDeriverException::class);
    $this->expectExceptionMessage('Plugin (invalid_discovery) deriver "\\Drupal\\KernelTests\\Core\\Plugin\\DerivativeTest" must implement \\Drupal\\Component\\Plugin\\Derivative\\DeriverInterface.');
    $discovery->getDefinitions();
}

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