function WorkspaceTestUtilities::createNodeThroughUi

Same name and namespace in other branches
  1. 9 core/modules/workspaces/tests/src/Functional/WorkspaceTestUtilities.php \Drupal\Tests\workspaces\Functional\WorkspaceTestUtilities::createNodeThroughUi()
  2. 8.9.x core/modules/workspaces/tests/src/Functional/WorkspaceTestUtilities.php \Drupal\Tests\workspaces\Functional\WorkspaceTestUtilities::createNodeThroughUi()
  3. 10 core/modules/workspaces/tests/src/Functional/WorkspaceTestUtilities.php \Drupal\Tests\workspaces\Functional\WorkspaceTestUtilities::createNodeThroughUi()

Creates a node by "clicking" buttons.

Parameters

string $label: The label of the Node to create.

string $bundle: The bundle of the Node to create.

bool $publish: The publishing status to set.

Return value

\Drupal\node\NodeInterface The Node that was just created.

Throws

\Behat\Mink\Exception\ElementNotFoundException

7 calls to WorkspaceTestUtilities::createNodeThroughUi()
WorkspaceBypassTest::testBypassOwnWorkspace in core/modules/workspaces/tests/src/Functional/WorkspaceBypassTest.php
Verifies that a user can edit anything in a workspace they own.
WorkspaceConcurrentEditingTest::testConcurrentEditing in core/modules/workspaces/tests/src/Functional/WorkspaceConcurrentEditingTest.php
Tests editing a node in multiple workspaces.
WorkspaceEntityDeleteTest::testEntityDelete in core/modules/workspaces/tests/src/Functional/WorkspaceEntityDeleteTest.php
Test entity deletion with workspaces.
WorkspaceEntityDeleteTest::testNodeDeleteWithBypassAccessPermission in core/modules/workspaces/tests/src/Functional/WorkspaceEntityDeleteTest.php
Test node deletion with workspaces and the 'bypass node access' permission.
WorkspaceTest::testDeleteWorkspaceWithExistingContent in core/modules/workspaces/tests/src/Functional/WorkspaceTest.php
Verifies that a workspace with existing content may be deleted.

... See full list

File

core/modules/workspaces/tests/src/Functional/WorkspaceTestUtilities.php, line 169

Class

WorkspaceTestUtilities
Utility methods for use in BrowserTestBase tests.

Namespace

Drupal\Tests\workspaces\Functional

Code

protected function createNodeThroughUi($label, $bundle, $publish = TRUE) {
    $this->drupalGet('/node/add/' . $bundle);
    
    /** @var \Behat\Mink\Session $session */
    $session = $this->getSession();
    $this->assertSession()
        ->statusCodeEquals(200);
    
    /** @var \Behat\Mink\Element\DocumentElement $page */
    $page = $session->getPage();
    $page->fillField('Title', $label);
    if ($publish) {
        $page->findButton('Save')
            ->click();
    }
    else {
        $page->uncheckField('Published');
        $page->findButton('Save')
            ->click();
    }
    $session->getPage()
        ->hasContent("{$label} has been created");
    return $this->getOneEntityByLabel('node', $label);
}

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