function EntityTest::setUp

Same name in this branch
  1. 11.x core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php \Drupal\Tests\views\Unit\Plugin\argument_validator\EntityTest::setUp()
Same name in other branches
  1. 9 core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php \Drupal\Tests\views\Unit\Plugin\argument_validator\EntityTest::setUp()
  2. 9 core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php \Drupal\Tests\views\Unit\Plugin\area\EntityTest::setUp()
  3. 8.9.x core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php \Drupal\Tests\views\Unit\Plugin\argument_validator\EntityTest::setUp()
  4. 8.9.x core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php \Drupal\Tests\views\Unit\Plugin\area\EntityTest::setUp()
  5. 10 core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php \Drupal\Tests\views\Unit\Plugin\argument_validator\EntityTest::setUp()
  6. 10 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/area/EntityTest.php, line 86

Class

EntityTest
@coversDefaultClass \Drupal\views\Plugin\views\area\Entity @group Entity

Namespace

Drupal\Tests\views\Unit\Plugin\area

Code

protected function setUp() : void {
    parent::setUp();
    $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
    $this->entityRepository = $this->createMock(EntityRepositoryInterface::class);
    $this->entityDisplayRepository = $this->createMock(EntityDisplayRepositoryInterface::class);
    $this->entityStorage = $this->createMock('Drupal\\Core\\Entity\\EntityStorageInterface');
    $this->entityViewBuilder = $this->createMock('Drupal\\Core\\Entity\\EntityViewBuilderInterface');
    $this->executable = $this->getMockBuilder('Drupal\\views\\ViewExecutable')
        ->disableOriginalConstructor()
        ->getMock();
    $this->display = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\DisplayPluginBase')
        ->disableOriginalConstructor()
        ->getMock();
    $this->stylePlugin = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\style\\StylePluginBase')
        ->disableOriginalConstructor()
        ->getMock();
    $this->executable->style_plugin = $this->stylePlugin;
    $this->entityHandler = new Entity([], 'entity', [
        'entity_type' => 'entity_test',
    ], $this->entityTypeManager, $this->entityRepository, $this->entityDisplayRepository);
    $this->display
        ->expects($this->any())
        ->method('getPlugin')
        ->with('style')
        ->willReturn($this->stylePlugin);
    $this->executable
        ->expects($this->any())
        ->method('getStyle')
        ->willReturn($this->stylePlugin);
    $token = $this->getMockBuilder('Drupal\\Core\\Utility\\Token')
        ->disableOriginalConstructor()
        ->getMock();
    $token->expects($this->any())
        ->method('replace')
        ->willReturnArgument(0);
    $container = new ContainerBuilder();
    $container->set('token', $token);
    \Drupal::setContainer($container);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.