function FieldTest::setupLanguageRenderer

Same name in other branches
  1. 9 core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldTest::setupLanguageRenderer()
  2. 8.9.x core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldTest::setupLanguageRenderer()
  3. 10 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\EntityField $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 726

Class

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

Namespace

Drupal\Tests\views\Unit\Plugin\field

Code

protected function setupLanguageRenderer(EntityField $handler, $definition) : void {
    $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->createMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
    $entity_type->expects($this->any())
        ->method('id')
        ->willReturn($definition['entity_type']);
    $this->entityTypeManager
        ->expects($this->any())
        ->method('getDefinition')
        ->willReturn($entity_type);
}

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