function DisplayKernelTest::testDefaultOptions

Same name in other branches
  1. 9 core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php \Drupal\Tests\views\Kernel\Plugin\DisplayKernelTest::testDefaultOptions()
  2. 8.9.x core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php \Drupal\Tests\views\Kernel\Plugin\DisplayKernelTest::testDefaultOptions()
  3. 10 core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php \Drupal\Tests\views\Kernel\Plugin\DisplayKernelTest::testDefaultOptions()

Tests the default display options.

File

core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php, line 64

Class

DisplayKernelTest
Drupal unit tests for the DisplayPluginBase class.

Namespace

Drupal\Tests\views\Kernel\Plugin

Code

public function testDefaultOptions() : void {
    // Save the view.
    $view = Views::getView('test_display_defaults');
    $view->mergeDefaults();
    $view->save();
    // Reload to get saved storage values.
    $view = Views::getView('test_display_defaults');
    $view->initDisplay();
    $display_data = $view->storage
        ->get('display');
    foreach ($view->displayHandlers as $id => $display) {
        // Test the view plugin options against the storage.
        foreach ($this->pluginTypes as $type) {
            $options = $display->getOption($type);
            $this->assertSame($display_data[$id]['display_options'][$type]['options'], $options['options']);
        }
        // Test the view handler options against the storage.
        foreach ($this->handlerTypes as $type) {
            $options = $display->getOption($type);
            $this->assertSame($display_data[$id]['display_options'][$type], $options);
        }
    }
}

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