protected function EntityTest::setUp in Zircon Profile 8
Same name in this branch
- 8 core/modules/hal/src/Tests/EntityTest.php \Drupal\hal\Tests\EntityTest::setUp()
- 8 core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php \Drupal\Tests\views\Unit\Plugin\area\EntityTest::setUp()
- 8 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.0 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 50 - Contains \Drupal\Tests\views\Unit\Plugin\argument_validator\EntityTest.
Class
- EntityTest
- @coversDefaultClass \Drupal\views\Plugin\views\argument_validator\Entity @group views
Namespace
Drupal\Tests\views\Unit\Plugin\argument_validatorCode
protected function setUp() {
parent::setUp();
$this->entityManager = $this
->getMock('Drupal\\Core\\Entity\\EntityManagerInterface');
$mock_entity = $this
->getMockForAbstractClass('Drupal\\Core\\Entity\\Entity', array(), '', FALSE, TRUE, TRUE, array(
'bundle',
'access',
));
$mock_entity
->expects($this
->any())
->method('bundle')
->will($this
->returnValue('test_bundle'));
$mock_entity
->expects($this
->any())
->method('access')
->will($this
->returnValueMap(array(
array(
'test_op',
NULL,
FALSE,
TRUE,
),
array(
'test_op_2',
NULL,
FALSE,
FALSE,
),
array(
'test_op_3',
NULL,
FALSE,
TRUE,
),
)));
$mock_entity_bundle_2 = $this
->getMockForAbstractClass('Drupal\\Core\\Entity\\Entity', array(), '', FALSE, TRUE, TRUE, array(
'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')
->will($this
->returnValueMap(array(
array(
'test_op',
NULL,
FALSE,
FALSE,
),
array(
'test_op_2',
NULL,
FALSE,
FALSE,
),
array(
'test_op_3',
NULL,
FALSE,
TRUE,
),
)));
$storage = $this
->getMock('Drupal\\Core\\Entity\\EntityStorageInterface');
// Setup values for IDs passed as strings or numbers.
$value_map = array(
array(
array(),
array(),
),
array(
array(
1,
),
array(
1 => $mock_entity,
),
),
array(
array(
'1',
),
array(
1 => $mock_entity,
),
),
array(
array(
1,
2,
),
array(
1 => $mock_entity,
2 => $mock_entity_bundle_2,
),
),
array(
array(
'1',
'2',
),
array(
1 => $mock_entity,
2 => $mock_entity_bundle_2,
),
),
array(
array(
2,
),
array(
2 => $mock_entity_bundle_2,
),
),
array(
array(
'2',
),
array(
2 => $mock_entity_bundle_2,
),
),
);
$storage
->expects($this
->any())
->method('loadMultiple')
->will($this
->returnValueMap($value_map));
$this->entityManager
->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 = array(
'entity_type' => 'entity_test',
);
$this->argumentValidator = new Entity(array(), 'entity_test', $definition, $this->entityManager);
}