function ModuleTest::formatViewOptions

Same name in other branches
  1. 8.9.x core/modules/views/tests/src/Kernel/ModuleTest.php \Drupal\Tests\views\Kernel\ModuleTest::formatViewOptions()
  2. 10 core/modules/views/tests/src/Kernel/ModuleTest.php \Drupal\Tests\views\Kernel\ModuleTest::formatViewOptions()
  3. 11.x core/modules/views/tests/src/Kernel/ModuleTest.php \Drupal\Tests\views\Kernel\ModuleTest::formatViewOptions()

Helper to return an expected views option array.

Parameters

array $views: An array of Drupal\views\Entity\View objects for which to create an options array.

Return value

array A formatted options array that matches the expected output.

1 call to ModuleTest::formatViewOptions()
ModuleTest::testLoadFunctions in core/modules/views/tests/src/Kernel/ModuleTest.php
Tests the load wrapper/helper functions.

File

core/modules/views/tests/src/Kernel/ModuleTest.php, line 325

Class

ModuleTest
Tests basic functions from the Views module.

Namespace

Drupal\Tests\views\Kernel

Code

protected function formatViewOptions(array $views = []) {
    $expected_options = [];
    foreach ($views as $view) {
        foreach ($view->get('display') as $display) {
            $expected_options[$view->id() . ':' . $display['id']] = "View: {$view->id()} - Display: {$display['id']}";
        }
    }
    return $expected_options;
}

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