From c0e6d1ad3835b56f5006e85ae02d16699fb9a0d5 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 23 Oct 2013 01:50:55 +0200 Subject: [PATCH] Added unit test around "forbidden section" redirection See https://github.com/silverstripe/silverstripe-subsites/pull/115 --- tests/SubsiteAdminFunctionalTest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/SubsiteAdminFunctionalTest.php b/tests/SubsiteAdminFunctionalTest.php index ed1c7b2..57f445a 100644 --- a/tests/SubsiteAdminFunctionalTest.php +++ b/tests/SubsiteAdminFunctionalTest.php @@ -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(),