public function DerivativeDiscoveryDecoratorTest::testSingleExistingDerivative in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php \Drupal\Tests\Core\Plugin\Discovery\DerivativeDiscoveryDecoratorTest::testSingleExistingDerivative()
Tests a single definition when a derivative already exists.
File
- core/
tests/ Drupal/ Tests/ Core/ Plugin/ Discovery/ DerivativeDiscoveryDecoratorTest.php, line 179 - Contains \Drupal\Tests\Core\Plugin\Discovery\DerivativeDiscoveryDecoratorTest.
Class
- DerivativeDiscoveryDecoratorTest
- Unit tests for the derivative discovery decorator.
Namespace
Drupal\Tests\Core\Plugin\DiscoveryCode
public function testSingleExistingDerivative() {
$base_definition = array(
'id' => 'non_container_aware_discovery',
'deriver' => '\\Drupal\\Tests\\Core\\Plugin\\Discovery\\TestDerivativeDiscovery',
'string' => 'string',
'empty_string' => 'not_empty',
'array' => array(
'one',
'two',
),
'empty_array' => array(
'three',
),
'null_value' => TRUE,
);
// This will clash with a derivative id.
// @see \Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscovery
$derivative_definition = array(
'id' => 'non_container_aware_discovery:test_discovery_1',
'string' => 'string',
'empty_string' => '',
'array' => array(
'one',
'two',
),
'empty_array' => array(),
'null_value' => NULL,
);
$this->discoveryMain
->expects($this
->at(0))
->method('getDefinition')
->with('non_container_aware_discovery:test_discovery_1')
->will($this
->returnValue($derivative_definition));
$this->discoveryMain
->expects($this
->at(1))
->method('getDefinition')
->with('non_container_aware_discovery')
->will($this
->returnValue($base_definition));
$discovery = new DerivativeDiscoveryDecorator($this->discoveryMain);
$expected = $base_definition;
$expected['id'] = 'non_container_aware_discovery:test_discovery_1';
$this
->assertArrayEquals($expected, $discovery
->getDefinition('non_container_aware_discovery:test_discovery_1'));
}