function WizardPluginBaseKernelTest::testCreateView

Same name in other branches
  1. 9 core/modules/views/tests/src/Kernel/Wizard/WizardPluginBaseKernelTest.php \Drupal\Tests\views\Kernel\Wizard\WizardPluginBaseKernelTest::testCreateView()
  2. 8.9.x core/modules/views/tests/src/Kernel/Wizard/WizardPluginBaseKernelTest.php \Drupal\Tests\views\Kernel\Wizard\WizardPluginBaseKernelTest::testCreateView()
  3. 10 core/modules/views/tests/src/Kernel/Wizard/WizardPluginBaseKernelTest.php \Drupal\Tests\views\Kernel\Wizard\WizardPluginBaseKernelTest::testCreateView()

Tests the creating of a view.

See also

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

File

core/modules/views/tests/src/Kernel/Wizard/WizardPluginBaseKernelTest.php, line 48

Class

WizardPluginBaseKernelTest
Tests the wizard base plugin class.

Namespace

Drupal\Tests\views\Kernel\Wizard

Code

public function testCreateView() : void {
    $form = [];
    $form_state = new FormState();
    $form = $this->wizard
        ->buildForm($form, $form_state);
    $random_id = $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->assertInstanceOf(ViewUI::class, $view);
    $this->assertEquals($random_id, $view->get('id'));
    $this->assertEquals($random_label, $view->get('label'));
    $this->assertEquals($random_description, $view->get('description'));
    $this->assertEquals('views_test_data', $view->get('base_table'));
    $this->assertEquals('it', $view->get('langcode'));
}

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