public function ConfigEntityBaseUnitTest::testCalculateDependenciesWithPluginCollections in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testCalculateDependenciesWithPluginCollections()
@covers ::getDependencies @covers ::calculateDependencies
@dataProvider providerCalculateDependenciesWithPluginCollections
File
- core/
tests/ Drupal/ Tests/ Core/ Config/ Entity/ ConfigEntityBaseUnitTest.php, line 221 - Contains \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest.
Class
- ConfigEntityBaseUnitTest
- @coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityBase @group Config
Namespace
Drupal\Tests\Core\Config\EntityCode
public function testCalculateDependenciesWithPluginCollections($definition, $expected_dependencies) {
$values = array();
$this->entity = $this
->getMockBuilder('\\Drupal\\Tests\\Core\\Config\\Entity\\Fixtures\\ConfigEntityBaseWithPluginCollections')
->setConstructorArgs(array(
$values,
$this->entityTypeId,
))
->setMethods(array(
'getPluginCollections',
))
->getMock();
// Create a configurable plugin that would add a dependency.
$instance_id = $this
->randomMachineName();
$instance = new TestConfigurablePlugin(array(), $instance_id, $definition);
// Create a plugin collection to contain the instance.
$pluginCollection = $this
->getMockBuilder('\\Drupal\\Core\\Plugin\\DefaultLazyPluginCollection')
->disableOriginalConstructor()
->setMethods(array(
'get',
))
->getMock();
$pluginCollection
->expects($this
->atLeastOnce())
->method('get')
->with($instance_id)
->will($this
->returnValue($instance));
$pluginCollection
->addInstanceId($instance_id);
// Return the mocked plugin collection.
$this->entity
->expects($this
->once())
->method('getPluginCollections')
->will($this
->returnValue(array(
$pluginCollection,
)));
$this
->assertEquals($expected_dependencies, $this->entity
->calculateDependencies()
->getDependencies());
}