You are here

public function EntityOperationsUnitTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 46
Contains \Drupal\Tests\views\Unit\Plugin\views\field\EntityOperationsUnitTest.

Class

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

Namespace

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

Code

public function setUp() {
  $this->entityManager = $this
    ->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
  $this->languageManager = $this
    ->getMock('\\Drupal\\Core\\Language\\LanguageManagerInterface');
  $configuration = array();
  $plugin_id = $this
    ->randomMachineName();
  $plugin_definition = array(
    'title' => $this
      ->randomMachineName(),
  );
  $this->plugin = new EntityOperations($configuration, $plugin_id, $plugin_definition, $this->entityManager, $this->languageManager);
  $redirect_service = $this
    ->getMock('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);
}