You are here

protected function EntityOperationsUnitTest::setUp in Drupal 8

Same name and namespace 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. 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 50

Class

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

Namespace

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

Code

protected function setUp() {
  $this->entityTypeManager = $this
    ->createMock(EntityTypeManagerInterface::class);
  $this->entityRepository = $this
    ->createMock(EntityRepositoryInterface::class);
  $this->languageManager = $this
    ->createMock('\\Drupal\\Core\\Language\\LanguageManagerInterface');
  $configuration = [];
  $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);
}