protected function EntityTest::setUp in Drupal 10
Same name in this branch
- 10 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()
Same name and namespace in other branches
- 8 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/argument_validator/EntityTest.php \Drupal\Tests\views\Unit\Plugin\argument_validator\EntityTest::setUp()
Overrides UnitTestCase::setUp
File
- core/
modules/ views/ tests/ src/ Unit/ Plugin/ argument_validator/ EntityTest.php, line 54
Class
- EntityTest
- @coversDefaultClass \Drupal\views\Plugin\views\argument_validator\Entity @group views
Namespace
Drupal\Tests\views\Unit\Plugin\argument_validatorCode
protected function setUp() : void {
parent::setUp();
$this->entityTypeManager = $this
->createMock(EntityTypeManagerInterface::class);
$this->entityTypeBundleInfo = $this
->createMock(EntityTypeBundleInfoInterface::class);
$mock_entity = $this
->getMockForAbstractClass('Drupal\\Core\\Entity\\EntityBase', [], '', FALSE, TRUE, TRUE, [
'bundle',
'access',
]);
$mock_entity
->expects($this
->any())
->method('bundle')
->will($this
->returnValue('test_bundle'));
$mock_entity
->expects($this
->any())
->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
->getMockForAbstractClass('Drupal\\Core\\Entity\\EntityBase', [], '', FALSE, TRUE, TRUE, [
'bundle',
'access',
]);
$mock_entity_bundle_2
->expects($this
->any())
->method('bundle')
->will($this
->returnValue('test_bundle_2'));
$mock_entity_bundle_2
->expects($this
->any())
->method('access')
->willReturnMap([
[
'test_op',
NULL,
FALSE,
FALSE,
],
[
'test_op_2',
NULL,
FALSE,
FALSE,
],
[
'test_op_3',
NULL,
FALSE,
TRUE,
],
]);
$storage = $this
->createMock('Drupal\\Core\\Entity\\EntityStorageInterface');
// 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
->expects($this
->any())
->method('loadMultiple')
->willReturnMap($value_map);
$this->entityTypeManager
->expects($this
->any())
->method('getStorage')
->with('entity_test')
->will($this
->returnValue($storage));
$this->executable = $this
->getMockBuilder('Drupal\\views\\ViewExecutable')
->disableOriginalConstructor()
->getMock();
$this->display = $this
->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\DisplayPluginBase')
->disableOriginalConstructor()
->getMock();
$definition = [
'entity_type' => 'entity_test',
];
$this->argumentValidator = new Entity([], 'entity_test', $definition, $this->entityTypeManager, $this->entityTypeBundleInfo);
}