function DerivativeDiscoveryDecoratorTest::testNonExistentDerivativeFetcher

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

Tests the getDerivativeFetcher method with a non-existent class.

See also

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

File

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

Class

DerivativeDiscoveryDecoratorTest
Unit tests for the derivative discovery decorator.

Namespace

Drupal\Tests\Core\Plugin\Discovery

Code

public function testNonExistentDerivativeFetcher() : void {
    $definitions = [];
    // Do this with a class that doesn't exist.
    $definitions['non_existent_discovery'] = [
        'id' => 'non_existent_discovery',
        'deriver' => '\\Drupal\\system\\Tests\\Plugin\\NonExistentDeriver',
    ];
    $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.