function EntityOperationsUnitTest::setUp

Same name in other branches
  1. 9 core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php \Drupal\Tests\views\Unit\Plugin\views\field\EntityOperationsUnitTest::setUp()
  2. 8.9.x core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php \Drupal\Tests\views\Unit\Plugin\views\field\EntityOperationsUnitTest::setUp()
  3. 10 core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php \Drupal\Tests\views\Unit\Plugin\views\field\EntityOperationsUnitTest::setUp()

@covers ::__construct

Overrides UnitTestCase::setUp

File

core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php, line 55

Class

EntityOperationsUnitTest
@coversDefaultClass \Drupal\views\Plugin\views\field\EntityOperations @group Views

Namespace

Drupal\Tests\views\Unit\Plugin\views\field

Code

protected function setUp() : void {
    parent::setUp();
    $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
    $this->entityRepository = $this->createMock(EntityRepositoryInterface::class);
    $this->languageManager = $this->createMock('\\Drupal\\Core\\Language\\LanguageManagerInterface');
    $configuration = [
        'entity_type' => 'foo',
        'entity field' => 'bar',
    ];
    $plugin_id = $this->randomMachineName();
    $plugin_definition = [
        'title' => $this->randomMachineName(),
    ];
    $this->plugin = new EntityOperations($configuration, $plugin_id, $plugin_definition, $this->entityTypeManager, $this->languageManager, $this->entityRepository);
    $redirect_service = $this->createMock('Drupal\\Core\\Routing\\RedirectDestinationInterface');
    $redirect_service->expects($this->any())
        ->method('getAsArray')
        ->willReturn([
        'destination' => 'foobar',
    ]);
    $this->plugin
        ->setRedirectDestination($redirect_service);
    $view = $this->getMockBuilder('\\Drupal\\views\\ViewExecutable')
        ->disableOriginalConstructor()
        ->getMock();
    $display = $this->getMockBuilder('\\Drupal\\views\\Plugin\\views\\display\\DisplayPluginBase')
        ->disableOriginalConstructor()
        ->getMockForAbstractClass();
    $view->display_handler = $display;
    $this->plugin
        ->init($view, $display);
}

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