function DerivativeDiscoveryDecoratorTest::testNonExistentDerivativeFetcher

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php \Drupal\Tests\Core\Plugin\Discovery\DerivativeDiscoveryDecoratorTest::testNonExistentDerivativeFetcher()
  2. 10 core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php \Drupal\Tests\Core\Plugin\Discovery\DerivativeDiscoveryDecoratorTest::testNonExistentDerivativeFetcher()
  3. 11.x 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 139

Class

DerivativeDiscoveryDecoratorTest
Unit tests for the derivative discovery decorator.

Namespace

Drupal\Tests\Core\Plugin\Discovery

Code

public function testNonExistentDerivativeFetcher() {
    $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')
        ->will($this->returnValue($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.