function BasicTest::testWizardDefaultValues

Same name in other branches
  1. 8.9.x core/modules/views/tests/src/Functional/Wizard/BasicTest.php \Drupal\Tests\views\Functional\Wizard\BasicTest::testWizardDefaultValues()
  2. 10 core/modules/views/tests/src/Functional/Wizard/BasicTest.php \Drupal\Tests\views\Functional\Wizard\BasicTest::testWizardDefaultValues()
  3. 11.x 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 204

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->assertNotEmpty($display['display_options'][$type]['options'], "There should be default options available for '{$type}'.");
        }
    }
}

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