function LinkFieldFormStatesTest::testLinkFieldFormStates

Same name in other branches
  1. 9 core/modules/link/tests/src/FunctionalJavascript/LinkFieldFormStatesTest.php \Drupal\Tests\link\FunctionalJavascript\LinkFieldFormStatesTest::testLinkFieldFormStates()
  2. 11.x core/modules/link/tests/src/FunctionalJavascript/LinkFieldFormStatesTest.php \Drupal\Tests\link\FunctionalJavascript\LinkFieldFormStatesTest::testLinkFieldFormStates()

@dataProvider linkFieldFormStatesData

File

core/modules/link/tests/src/FunctionalJavascript/LinkFieldFormStatesTest.php, line 44

Class

LinkFieldFormStatesTest
Tests link field form states functionality.

Namespace

Drupal\Tests\link\FunctionalJavascript

Code

public function testLinkFieldFormStates(string $uri, string $title) : void {
    $this->drupalGet('entity_test/add');
    $session = $this->assertSession();
    $session->elementNotExists('css', '#edit-links-0-uri[required]');
    $session->elementNotExists('css', '#edit-links-0-title[required]');
    $page = $this->getSession()
        ->getPage();
    if ($uri !== '') {
        $page->fillField('links[0][uri]', $uri);
        $session->elementNotExists('css', '#edit-links-0-uri[required]');
        $session->elementExists('css', '#edit-links-0-title[required]');
    }
    else {
        $page->fillField('links[0][title]', $title);
        $session->elementExists('css', '#edit-links-0-uri[required]');
        $session->elementNotExists('css', '#edit-links-0-title[required]');
    }
}

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