You are here

public function WizardPluginBaseKernelTest::testCreateView in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/Wizard/WizardPluginBaseKernelTest.php \Drupal\views\Tests\Wizard\WizardPluginBaseKernelTest::testCreateView()

Tests the creating of a view.

See also

\Drupal\views\Plugin\views\wizard\WizardPluginBase

File

core/modules/views/src/Tests/Wizard/WizardPluginBaseKernelTest.php, line 50
Contains \Drupal\views\Tests\Wizard\WizardPluginBaseKernelTest.

Class

WizardPluginBaseKernelTest
Tests the wizard base plugin class.

Namespace

Drupal\views\Tests\Wizard

Code

public function testCreateView() {
  $form = array();
  $form_state = new FormState();
  $form = $this->wizard
    ->buildForm($form, $form_state);
  $random_id = strtolower($this
    ->randomMachineName());
  $random_label = $this
    ->randomMachineName();
  $random_description = $this
    ->randomMachineName();

  // Add a new language and mark it as default.
  ConfigurableLanguage::createFromLangcode('it')
    ->save();
  $this
    ->config('system.site')
    ->set('default_langcode', 'it')
    ->save();
  $form_state
    ->setValues([
    'id' => $random_id,
    'label' => $random_label,
    'description' => $random_description,
    'base_table' => 'views_test_data',
  ]);
  $this->wizard
    ->validateView($form, $form_state);
  $view = $this->wizard
    ->createView($form, $form_state);
  $this
    ->assertTrue($view instanceof ViewUI, 'The created view is a ViewUI object.');
  $this
    ->assertEqual($view
    ->get('id'), $random_id);
  $this
    ->assertEqual($view
    ->get('label'), $random_label);
  $this
    ->assertEqual($view
    ->get('description'), $random_description);
  $this
    ->assertEqual($view
    ->get('base_table'), 'views_test_data');
  $this
    ->assertEqual($view
    ->get('langcode'), 'it');
}