function EntityTest::setUp
Same name in this branch
- main core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php \Drupal\Tests\views\Unit\Plugin\area\EntityTest::setUp()
Same name and namespace in other branches
- 11.x core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php \Drupal\Tests\views\Unit\Plugin\argument_validator\EntityTest::setUp()
- 11.x core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php \Drupal\Tests\views\Unit\Plugin\area\EntityTest::setUp()
- 10 core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php \Drupal\Tests\views\Unit\Plugin\argument_validator\EntityTest::setUp()
- 10 core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php \Drupal\Tests\views\Unit\Plugin\area\EntityTest::setUp()
- 9 core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php \Drupal\Tests\views\Unit\Plugin\argument_validator\EntityTest::setUp()
- 9 core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php \Drupal\Tests\views\Unit\Plugin\area\EntityTest::setUp()
- 8.9.x core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php \Drupal\Tests\views\Unit\Plugin\argument_validator\EntityTest::setUp()
- 8.9.x core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php \Drupal\Tests\views\Unit\Plugin\area\EntityTest::setUp()
Overrides UnitTestCase::setUp
File
-
core/
modules/ views/ tests/ src/ Unit/ Plugin/ argument_validator/ EntityTest.php, line 63
Class
Namespace
Drupal\Tests\views\Unit\Plugin\argument_validatorCode
protected function setUp() : void {
parent::setUp();
$this->entityTypeManager = $this->createStub(EntityTypeManagerInterface::class);
$this->entityTypeBundleInfo = $this->createStub(EntityTypeBundleInfoInterface::class);
$mock_entity = $this->createStub(StubEntityBase::class);
$mock_entity->method('bundle')
->willReturn('test_bundle');
$mock_entity->method('access')
->willReturnMap([
[
'test_op',
NULL,
FALSE,
TRUE,
],
[
'test_op_2',
NULL,
FALSE,
FALSE,
],
[
'test_op_3',
NULL,
FALSE,
TRUE,
],
]);
$mock_entity_bundle_2 = $this->createStub(StubEntityBase::class);
$mock_entity_bundle_2->method('bundle')
->willReturn('test_bundle_2');
$mock_entity_bundle_2->method('access')
->willReturnMap([
[
'test_op',
NULL,
FALSE,
FALSE,
],
[
'test_op_2',
NULL,
FALSE,
FALSE,
],
[
'test_op_3',
NULL,
FALSE,
TRUE,
],
]);
$storage = $this->createStub(EntityStorageInterface::class);
// Setup values for IDs passed as strings or numbers.
$value_map = [
[
[],
[],
],
[
[
1,
],
[
1 => $mock_entity,
],
],
[
[
'1',
],
[
1 => $mock_entity,
],
],
[
[
1,
2,
],
[
1 => $mock_entity,
2 => $mock_entity_bundle_2,
],
],
[
[
'1',
'2',
],
[
1 => $mock_entity,
2 => $mock_entity_bundle_2,
],
],
[
[
2,
],
[
2 => $mock_entity_bundle_2,
],
],
[
[
'2',
],
[
2 => $mock_entity_bundle_2,
],
],
];
$storage->method('loadMultiple')
->willReturnMap($value_map);
$this->entityTypeManager
->method('getStorage')
->willReturn($storage);
$this->executable = $this->createStub(ViewExecutable::class);
$this->display = $this->createStub(DisplayPluginBase::class);
$definition = [
'entity_type' => 'entity_test',
];
$this->argumentValidator = new Entity([], 'entity_test', $definition, $this->entityTypeManager, $this->entityTypeBundleInfo);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.