You are here

public function DisplayKernelTest::testDefaultOptions in Drupal 9

Same name and namespace in other branches
  1. 8 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() {

  // 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);
    }
  }
}