You are here

public function DerivativeDiscoveryDecoratorTest::testNonExistentDerivativeFetcher in Drupal 8

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();
}