You are here

public function BasicTest::testWizardDefaultValues in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/Wizard/BasicTest.php \Drupal\views\Tests\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/src/Tests/Wizard/BasicTest.php, line 203
Contains \Drupal\views\Tests\Wizard\BasicTest.

Class

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

Namespace

Drupal\views\Tests\Wizard

Code

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

  // Create a basic view.
  $view = array();
  $view['label'] = $this
    ->randomMachineName(16);
  $view['id'] = $random_id;
  $view['description'] = $this
    ->randomMachineName(16);
  $view['page[create]'] = FALSE;
  $this
    ->drupalPostForm('admin/structure/views/add', $view, t('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\views\Tests\Plugin\DisplayKernelTest
  $view = Views::getView($random_id);
  $displays = $view->storage
    ->get('display');
  foreach ($displays as $display) {
    foreach (array(
      'query',
      'exposed_form',
      'pager',
      'style',
      'row',
    ) as $type) {
      $this
        ->assertFalse(empty($display['display_options'][$type]['options']), SafeMarkup::format('Default options found for @plugin.', array(
        '@plugin' => $type,
      )));
    }
  }
}