Added unit test around "forbidden section" redirection

See https://github.com/silverstripe/silverstripe-subsites/pull/115
This commit is contained in:
Ingo Schommer 2013-10-23 01:50:55 +02:00
parent 8b5a1c92b2
commit c0e6d1ad38
1 changed files with 7 additions and 1 deletions

View File

@ -98,10 +98,16 @@ class SubsiteAdminFunctionalTest extends FunctionalTest {
$this->assertNotRegExp('#^admin/assets/.*#', $this->mainSession->lastUrl(),
'Is redirected away from forbidden section');
// Check forbidden site.
// Check forbidden site, on a section that's allowed on another subsite
$this->getAndFollowAll("admin/pages/?SubsiteID=0");
$this->assertEquals(Subsite::currentSubsiteID(), $subsite1->ID, 'Is redirected to permitted subsite.');
// Check forbidden site, on a section that's not allowed on any other subsite
$this->getAndFollowAll("admin/assets/?SubsiteID=0");
$this->assertEquals(Subsite::currentSubsiteID(), $subsite1->ID, 'Is redirected to first permitted subsite.');
var_dump($this->mainSession->lastUrl());
$this->assertNotRegExp('#^Security/login.*#', $this->mainSession->lastUrl(), 'Is not denied access');
// Check the standalone XHR controller.
$response = $this->getAndFollowAll('SubsiteXHRController');
$this->assertNotRegExp('#^Security/login.*#', $this->mainSession->lastUrl(),