function DerivativeDiscoveryDecoratorTest::testGetDeriverClassWithClassedDefinitions

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

Tests getDeriverClass with classed objects instead of arrays.

@covers ::getDeriverClass

File

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

Class

DerivativeDiscoveryDecoratorTest
Unit tests for the derivative discovery decorator.

Namespace

Drupal\Tests\Core\Plugin\Discovery

Code

public function testGetDeriverClassWithClassedDefinitions() {
    $definitions = [];
    $definition = $this->prophesize(DerivablePluginDefinitionInterface::class);
    $definition->id()
        ->willReturn('non_container_aware_discovery');
    $definition->getDeriver()
        ->willReturn(TestDerivativeDiscoveryWithObject::class);
    $definitions['non_container_aware_discovery'] = $definition->reveal();
    $this->discoveryMain
        ->expects($this->any())
        ->method('getDefinitions')
        ->will($this->returnValue($definitions));
    $discovery = new DerivativeDiscoveryDecorator($this->discoveryMain);
    $definitions = $discovery->getDefinitions();
    // Ensure that both test derivatives got added.
    $this->assertContainsOnlyInstancesOf(DerivablePluginDefinitionInterface::class, $definitions);
    $this->assertEquals([
        'non_container_aware_discovery:test_discovery_0',
        'non_container_aware_discovery:test_discovery_1',
    ], array_keys($definitions));
}

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