function ViewsHandlerManagerTest::testGetHandlerBaseInformationPropagation

Same name in other branches
  1. 9 core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php \Drupal\Tests\views\Unit\ViewsHandlerManagerTest::testGetHandlerBaseInformationPropagation()
  2. 10 core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php \Drupal\Tests\views\Unit\ViewsHandlerManagerTest::testGetHandlerBaseInformationPropagation()
  3. 11.x core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php \Drupal\Tests\views\Unit\ViewsHandlerManagerTest::testGetHandlerBaseInformationPropagation()

Tests getHandler() and its base information propagation.

File

core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php, line 83

Class

ViewsHandlerManagerTest
Tests the ViewsHandlerManager class.

Namespace

Drupal\Tests\views\Unit

Code

public function testGetHandlerBaseInformationPropagation() {
    $this->setupMockedFactory();
    $item = [];
    $item['table'] = 'test_table';
    $item['field'] = 'test_field';
    $views_data = [];
    $views_data['test_field']['test']['id'] = 'test_id';
    $views_data['test_field']['test']['more_information'] = 'test_id';
    $views_data['test_field']['group'] = 'test_group';
    $views_data['test_field']['title'] = 'test title';
    $views_data['test_field']['real field'] = 'test real field';
    $views_data['test_field']['real table'] = 'test real table';
    $views_data['test_field']['entity field'] = 'test entity field';
    $this->viewsData
        ->expects($this->once())
        ->method('get')
        ->with('test_table')
        ->willReturn($views_data);
    $expected_definition = [
        'id' => 'test_id',
        'more_information' => 'test_id',
        'group' => 'test_group',
        'title' => 'test title',
        'real field' => 'test real field',
        'real table' => 'test real table',
        'entity field' => 'test entity field',
    ];
    $plugin = $this->createMock('Drupal\\views\\Plugin\\views\\ViewsHandlerInterface');
    $this->factory
        ->expects($this->once())
        ->method('createInstance')
        ->with('test_id', $expected_definition)
        ->willReturn($plugin);
    $result = $this->handlerManager
        ->getHandler($item);
    $this->assertSame($plugin, $result);
}

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