function HandlerBaseTest::testGetEntityTypeForFieldOnBaseTable

Same name and namespace in other branches
  1. 11.x core/modules/views/tests/src/Unit/Plugin/HandlerBaseTest.php \Drupal\Tests\views\Unit\Plugin\HandlerBaseTest::testGetEntityTypeForFieldOnBaseTable()
  2. 10 core/modules/views/tests/src/Unit/Plugin/HandlerBaseTest.php \Drupal\Tests\views\Unit\Plugin\HandlerBaseTest::testGetEntityTypeForFieldOnBaseTable()
  3. 9 core/modules/views/tests/src/Unit/Plugin/HandlerBaseTest.php \Drupal\Tests\views\Unit\Plugin\HandlerBaseTest::testGetEntityTypeForFieldOnBaseTable()
  4. 8.9.x core/modules/views/tests/src/Unit/Plugin/HandlerBaseTest.php \Drupal\Tests\views\Unit\Plugin\HandlerBaseTest::testGetEntityTypeForFieldOnBaseTable()

Tests get entity type for field on base table.

File

core/modules/views/tests/src/Unit/Plugin/HandlerBaseTest.php, line 28

Class

HandlerBaseTest
Tests Drupal\views\Plugin\views\HandlerBase.

Namespace

Drupal\Tests\views\Unit\Plugin

Code

public function testGetEntityTypeForFieldOnBaseTable() : void {
  $view = $this->createMock(View::class);
  $executable = $this->createStub(ViewExecutable::class);
  $executable->storage = $view;
  $viewsData = $this->createMock(ViewsData::class);
  $handler = new TestHandler([], 'test_handler', []);
  $handler->init($executable, $this->createStub(DisplayPluginBase::class));
  $view->expects($this->once())
    ->method('get')
    ->with('base_table')
    ->willReturn('test_entity_type_table');
  $viewsData->expects($this->once())
    ->method('get')
    ->with('test_entity_type_table')
    ->willReturn([
    'table' => [
      'entity type' => 'test_entity_type',
    ],
  ]);
  $handler->setViewsData($viewsData);
  $this->assertEquals('test_entity_type', $handler->getEntityType());
}

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