function EntityTest::testCalculateDependencies
Same name in other branches
- 8.9.x core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php \Drupal\Tests\views\Unit\Plugin\argument_validator\EntityTest::testCalculateDependencies()
- 10 core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php \Drupal\Tests\views\Unit\Plugin\argument_validator\EntityTest::testCalculateDependencies()
- 11.x core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php \Drupal\Tests\views\Unit\Plugin\argument_validator\EntityTest::testCalculateDependencies()
@covers ::calculateDependencies
File
-
core/
modules/ views/ tests/ src/ Unit/ Plugin/ argument_validator/ EntityTest.php, line 190
Class
- EntityTest
- @coversDefaultClass \Drupal\views\Plugin\views\argument_validator\Entity @group views
Namespace
Drupal\Tests\views\Unit\Plugin\argument_validatorCode
public function testCalculateDependencies() {
// Create an entity type manager, storage, entity type, and entity to mock the
// loading of entities providing bundles.
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
$storage = $this->createMock('Drupal\\Core\\Entity\\EntityStorageInterface');
$entity_type = $this->createMock('Drupal\\Core\\Entity\\EntityTypeInterface');
$mock_entity = $this->createMock('Drupal\\Core\\Entity\\EntityInterface');
$mock_entity->expects($this->any())
->method('getConfigDependencyKey')
->willReturn('config');
$mock_entity->expects($this->any())
->method('getConfigDependencyName')
->willReturn('test_bundle');
$storage->expects($this->any())
->method('loadMultiple')
->with([
'test_bundle',
])
->willReturn([
'test_bundle' => $mock_entity,
]);
$entity_type->expects($this->any())
->method('getBundleEntityType')
->willReturn('entity_test_bundle');
$entity_type_manager->expects($this->any())
->method('getDefinition')
->with('entity_test')
->willReturn($entity_type);
$entity_type_manager->expects($this->any())
->method('hasHandler')
->with('entity_test_bundle', 'storage')
->willReturn(TRUE);
$entity_type_manager->expects($this->any())
->method('getStorage')
->with('entity_test_bundle')
->willReturn($storage);
// Set up the argument validator.
$argumentValidator = new Entity([], 'entity_test', [
'entity_type' => 'entity_test',
], $entity_type_manager, $this->entityTypeBundleInfo);
$options = [];
$options['access'] = FALSE;
$options['bundles'] = [
'test_bundle' => 1,
];
$argumentValidator->init($this->executable, $this->display, $options);
$this->assertEquals([
'config' => [
'test_bundle',
],
], $argumentValidator->calculateDependencies());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.