function PathNodeFormTest::testNodeForm

Same name and namespace in other branches
  1. 8.9.x core/modules/path/tests/src/Functional/PathNodeFormTest.php \Drupal\Tests\path\Functional\PathNodeFormTest::testNodeForm()
  2. 10 core/modules/path/tests/src/Functional/PathNodeFormTest.php \Drupal\Tests\path\Functional\PathNodeFormTest::testNodeForm()
  3. 11.x core/modules/path/tests/src/Functional/PathNodeFormTest.php \Drupal\Tests\path\Functional\PathNodeFormTest::testNodeForm()

Tests the node form ui.

File

core/modules/path/tests/src/Functional/PathNodeFormTest.php, line 41

Class

PathNodeFormTest
Tests the Path Node form UI.

Namespace

Drupal\Tests\path\Functional

Code

public function testNodeForm() {
    $assert_session = $this->assertSession();
    $this->drupalGet('node/add/page');
    // Make sure we have a vertical tab fieldset and 'Path' fields.
    $assert_session->elementContains('css', '.js-form-type-vertical-tabs #edit-path-0 summary', 'URL alias');
    $assert_session->fieldExists('path[0][alias]');
    // Disable the 'Path' field for this content type.
    \Drupal::service('entity_display.repository')->getFormDisplay('node', 'page', 'default')
        ->removeComponent('path')
        ->save();
    $this->drupalGet('node/add/page');
    // See if the whole fieldset is gone now.
    $assert_session->elementNotExists('css', '.js-form-type-vertical-tabs #edit-path-0');
    $assert_session->fieldNotExists('path[0][alias]');
}

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