You are here

public function ViewExecutableTest::testBuildThemeFunctions in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Unit/ViewExecutableTest.php \Drupal\Tests\views\Unit\ViewExecutableTest::testBuildThemeFunctions()
  2. 9 core/modules/views/tests/src/Unit/ViewExecutableTest.php \Drupal\Tests\views\Unit\ViewExecutableTest::testBuildThemeFunctions()

@covers ::buildThemeFunctions

File

core/modules/views/tests/src/Unit/ViewExecutableTest.php, line 300

Class

ViewExecutableTest
@coversDefaultClass \Drupal\views\ViewExecutable @group views

Namespace

Drupal\Tests\views\Unit

Code

public function testBuildThemeFunctions() {

  /** @var \Drupal\views\ViewExecutable|\PHPUnit\Framework\MockObject\MockObject $view */

  /** @var \Drupal\views\Plugin\views\display\DisplayPluginBase|\PHPUnit\Framework\MockObject\MockObject $display */
  [
    $view,
    $display,
  ] = $this
    ->setupBaseViewAndDisplay();
  unset($view->display_handler);
  $expected = [
    'test_hook__test_view',
    'test_hook',
  ];
  $this
    ->assertEquals($expected, $view
    ->buildThemeFunctions('test_hook'));
  $view->display_handler = $display;
  $expected = [
    'test_hook__test_view__default',
    'test_hook__default',
    'test_hook__one',
    'test_hook__two',
    'test_hook__and_three',
    'test_hook__test_view',
    'test_hook',
  ];
  $this
    ->assertEquals($expected, $view
    ->buildThemeFunctions('test_hook'));

  // Change the name of the display plugin and make sure that is in the array.
  $view->display_handler->display['display_plugin'] = 'default2';
  $expected = [
    'test_hook__test_view__default',
    'test_hook__default',
    'test_hook__one',
    'test_hook__two',
    'test_hook__and_three',
    'test_hook__test_view__default2',
    'test_hook__default2',
    'test_hook__test_view',
    'test_hook',
  ];
  $this
    ->assertEquals($expected, $view
    ->buildThemeFunctions('test_hook'));
}