public function LinkTypeAjaxTest::testNoJavascriptResponse in Flag 8.4
Tests the no-js fallback behavior for the AJAX link type.
File
- tests/
src/ Functional/ LinkTypeAjaxTest.php, line 44
Class
- LinkTypeAjaxTest
- Tests the AJAX link type.
Namespace
Drupal\Tests\flag\FunctionalCode
public function testNoJavascriptResponse() {
// Login as the admin user.
$this
->drupalLogin($this->adminUser);
// Create the flag with the AJAX link type using the form.
$this->flag = $this
->createFlagWithForm('node', [], 'ajax_link');
// Grant flag permissions.
$this
->grantFlagPermissions($this->flag);
// Create and login as an authenticated user.
$auth_user = $this
->drupalCreateUser();
$this
->drupalLogin($auth_user);
$node_url = $this->node
->toUrl();
// Navigate to the node page.
$this
->drupalGet($node_url);
// Confirm the flag link exists.
$this
->assertLink($this->flag
->getShortText('flag'));
// Click the flag link. This ensures that the non-JS fallback works we are
// redirected to back to the page and the node is flagged.
$this
->clickLink($this->flag
->getShortText('flag'));
$this
->assertUrl($node_url);
$this
->assertLink($this->flag
->getShortText('unflag'));
// Click the unflag link, repeat the check.
$this
->clickLink($this->flag
->getShortText('unflag'));
$this
->assertUrl($node_url);
$this
->assertLink($this->flag
->getShortText('flag'));
}