You are here

protected function FieldTest::setupLanguageRenderer in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldTest::setupLanguageRenderer()

Setup the mock data needed to make language renderers work.

Parameters

\Drupal\views\Plugin\views\field\Field $handler: The field handler.

$definition: An array with entity type definition data.

3 calls to FieldTest::setupLanguageRenderer()
FieldTest::testPrepareItemsByDelta in core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php
@covers ::prepareItemsByDelta
FieldTest::testQueryWithGroupByForBaseField in core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php
@covers ::query
FieldTest::testQueryWithGroupByForConfigField in core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php
@covers ::query

File

core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php, line 696
Contains \Drupal\Tests\views\Unit\Plugin\field\FieldTest.

Class

FieldTest
@coversDefaultClass \Drupal\views\Plugin\views\field\Field @group views

Namespace

Drupal\Tests\views\Unit\Plugin\field

Code

protected function setupLanguageRenderer(Field $handler, $definition) {
  $display_handler = $this
    ->getMockBuilder('\\Drupal\\views\\Plugin\\views\\display\\DisplayPluginBase')
    ->disableOriginalConstructor()
    ->getMock();
  $display_handler
    ->expects($this
    ->any())
    ->method('getOption')
    ->with($this
    ->equalTo('rendering_language'))
    ->willReturn('en');
  $handler->view->display_handler = $display_handler;
  $data['table']['entity type'] = $definition['entity_type'];
  $views_data = $this
    ->getMockBuilder('\\Drupal\\views\\ViewsData')
    ->disableOriginalConstructor()
    ->getMock();
  $views_data
    ->expects($this
    ->any())
    ->method('get')
    ->willReturn($data);
  $this->container
    ->set('views.views_data', $views_data);
  $entity_type = $this
    ->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
  $entity_type
    ->expects($this
    ->any())
    ->method('id')
    ->willReturn($definition['entity_type']);
  $this->entityManager
    ->expects($this
    ->any())
    ->method('getDefinition')
    ->willReturn($entity_type);
}