X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fdevel%2Fsrc%2FTests%2FDevelMenuLinksTest.php;fp=web%2Fmodules%2Fcontrib%2Fdevel%2Fsrc%2FTests%2FDevelMenuLinksTest.php;h=1183745f70170ee1aef6203038b25f00a123f356;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/devel/src/Tests/DevelMenuLinksTest.php b/web/modules/contrib/devel/src/Tests/DevelMenuLinksTest.php new file mode 100644 index 000000000..1183745f7 --- /dev/null +++ b/web/modules/contrib/devel/src/Tests/DevelMenuLinksTest.php @@ -0,0 +1,109 @@ +drupalPlaceBlock('system_menu_block:devel'); + $this->drupalPlaceBlock('page_title_block'); + + $this->develUser = $this->drupalCreateUser(['access devel information', 'administer site configuration']); + $this->drupalLogin($this->develUser); + } + + /** + * Tests CSFR protected links. + */ + 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.'); + } + + /** + * Tests redirect destination links. + */ + public function testRedirectDestinationLinks() { + // By default, in the testing profile, front page is the user canonical URI. + // For better testing do not use the default frontpage. + $url = Url::fromRoute('devel.simple_page'); + $destination = Url::fromRoute('devel.simple_page', [], ['absolute' => FALSE]); + + $this->drupalGet($url); + $this->assertLink(t('Reinstall Modules')); + $this->clickLink(t('Reinstall Modules')); + $this->assertUrl('devel/reinstall', ['query' => ['destination' => $destination->toString()]]); + + $this->drupalGet($url); + $this->assertLink(t('Rebuild Menu')); + $this->clickLink(t('Rebuild Menu')); + $this->assertUrl('devel/menu/reset', ['query' => ['destination' => $destination->toString()]]); + + $this->drupalGet($url); + $this->assertLink(t('Cache clear')); + $this->clickLink(t('Cache clear')); + $this->assertText('Cache cleared.'); + $this->assertUrl($url); + + $this->drupalGet($url); + $this->assertLink(t('Run cron')); + $this->clickLink(t('Run cron')); + $this->assertText(t('Cron ran successfully.')); + $this->assertUrl($url); + } + +}