function WorkspaceViewsIntegrationTest::testCreateWorkspaceView

Same name in other branches
  1. 11.x core/modules/workspaces/tests/src/Kernel/WorkspaceViewsIntegrationTest.php \Drupal\Tests\workspaces\Kernel\WorkspaceViewsIntegrationTest::testCreateWorkspaceView()

Tests creating a view of workspace entities.

See also

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

File

core/modules/workspaces/tests/src/Kernel/WorkspaceViewsIntegrationTest.php, line 184

Class

WorkspaceViewsIntegrationTest
Tests the views integration for workspaces.

Namespace

Drupal\Tests\workspaces\Kernel

Code

public function testCreateWorkspaceView() : void {
    $wizard = \Drupal::service('plugin.manager.views.wizard')->createInstance('standard:workspace', []);
    $form = [];
    $form_state = new FormState();
    $form = $wizard->buildForm($form, $form_state);
    $random_id = $this->randomMachineName();
    $random_label = $this->randomMachineName();
    $form_state->setValues([
        'id' => $random_id,
        'label' => $random_label,
        'base_table' => 'workspace',
    ]);
    $wizard->validateView($form, $form_state);
    $view = $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('workspace', $view->get('base_table'));
}

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