You are here

public function BasicTest::testWizardDefaultValues in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Functional/Wizard/BasicTest.php \Drupal\Tests\views\Functional\Wizard\BasicTest::testWizardDefaultValues()

Tests default plugin values are populated from the wizard form.

See also

\Drupal\views\Plugin\views\display\DisplayPluginBase::mergeDefaults()

File

core/modules/views/tests/src/Functional/Wizard/BasicTest.php, line 205

Class

BasicTest
Tests creating views with the wizard and viewing them on the listing page.

Namespace

Drupal\Tests\views\Functional\Wizard

Code

public function testWizardDefaultValues() {
  $random_id = strtolower($this
    ->randomMachineName(16));

  // Create a basic view.
  $view = [];
  $view['label'] = $this
    ->randomMachineName(16);
  $view['id'] = $random_id;
  $view['description'] = $this
    ->randomMachineName(16);
  $view['page[create]'] = FALSE;
  $this
    ->drupalGet('admin/structure/views/add');
  $this
    ->submitForm($view, 'Save and edit');

  // Make sure the plugin types that should not have empty options don't have.
  // Test against all values is unit tested.
  // @see \Drupal\Tests\views\Kernel\Plugin\DisplayKernelTest
  $view = Views::getView($random_id);
  $displays = $view->storage
    ->get('display');
  foreach ($displays as $display) {
    foreach ([
      'query',
      'exposed_form',
      'pager',
      'style',
      'row',
    ] as $type) {
      $this
        ->assertFalse(empty($display['display_options'][$type]['options']), new FormattableMarkup('Default options found for @plugin.', [
        '@plugin' => $type,
      ]));
    }
  }
}