public function DevelMenuLinksTest::testCsrfProtectedLinks in Devel 8
Same name and namespace in other branches
- 8.3 tests/src/Functional/DevelMenuLinksTest.php \Drupal\Tests\devel\Functional\DevelMenuLinksTest::testCsrfProtectedLinks()
- 8.2 tests/src/Functional/DevelMenuLinksTest.php \Drupal\Tests\devel\Functional\DevelMenuLinksTest::testCsrfProtectedLinks()
- 4.x tests/src/Functional/DevelMenuLinksTest.php \Drupal\Tests\devel\Functional\DevelMenuLinksTest::testCsrfProtectedLinks()
Tests CSFR protected links.
File
- tests/
src/ Functional/ DevelMenuLinksTest.php, line 47
Class
- DevelMenuLinksTest
- Tests devel menu links.
Namespace
Drupal\Tests\devel\FunctionalCode
public function testCsrfProtectedLinks() {
// Ensure CSRF link are not accessible directly.
$this
->drupalGet('devel/run-cron');
$this
->assertResponse(403);
$this
->drupalGet('devel/cache/clear');
$this
->assertResponse(403);
// Ensure clear cache link works properly.
$this
->assertLink('Cache clear');
$this
->clickLink('Cache clear');
$this
->assertText('Cache cleared.');
// Ensure run cron link works properly.
$this
->assertLink('Run cron');
$this
->clickLink('Run cron');
$this
->assertText('Cron ran successfully.');
// Ensure CSRF protected links work properly after change session.
$this
->drupalLogout();
$this
->drupalLogin($this->develUser);
$this
->assertLink('Cache clear');
$this
->clickLink('Cache clear');
$this
->assertText('Cache cleared.');
$this
->assertLink('Run cron');
$this
->clickLink('Run cron');
$this
->assertText('Cron ran successfully.');
}