public function BasicTest::testWizardDefaultValues

Tests default plugin values are populated from the wizard form.

See also

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

File

drupal/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php, line 159
Definition of 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
    ->randomName(16));

  // Create a basic view.
  $view = array();
  $view['label'] = $this
    ->randomName(16);
  $view['id'] = $random_id;
  $view['description'] = $this
    ->randomName(16);
  $view['page[create]'] = FALSE;
  $this
    ->drupalPost('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\DisplayUnitTest
  $view = views_get_view($random_id);
  $displays = $view->storage
    ->get('display');
  foreach (array(
    'query',
    'exposed_form',
    'pager',
    'style',
    'row',
  ) as $type) {
    foreach ($displays as $display) {
      $this
        ->assertFalse(empty($display['display_options'][$type]['options']), format_string('Default options found for @plugin.', array(
        '@plugin' => $type,
      )));
    }
  }
}