2011-04-11 02:59:42 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class SubsiteAdminFunctionalTest extends FunctionalTest {
|
|
|
|
static $fixture_file = 'subsites/tests/SubsiteTest.yml';
|
|
|
|
static $use_draft_site = true;
|
|
|
|
|
|
|
|
protected $autoFollowRedirection = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Admin should be able to access all subsites and the main site
|
|
|
|
*/
|
|
|
|
function testAdminCanAccessAllSubsites() {
|
|
|
|
$member = $this->objFromFixture('Member', 'admin');
|
|
|
|
Session::set("loggedInAs", $member->ID);
|
|
|
|
|
2012-10-12 04:09:38 +02:00
|
|
|
$this->get('admin/pages?SubsiteID=0&ajax=1');
|
2011-04-11 02:59:42 +02:00
|
|
|
$this->get('admin');
|
|
|
|
$this->assertEquals(Subsite::currentSubsiteID(), '0', 'Can access main site');
|
|
|
|
|
2013-01-03 17:38:51 +01:00
|
|
|
$mainSubsite = $this->objFromFixture('Subsite', 'main');
|
2012-10-12 04:09:38 +02:00
|
|
|
$this->get("admin/pages?SubsiteID={$mainSubsite->ID}&ajax=1");
|
2011-04-11 02:59:42 +02:00
|
|
|
$this->get('admin');
|
|
|
|
$this->assertEquals(Subsite::currentSubsiteID(), $mainSubsite->ID, 'Can access the subsite');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* User which has AccessAllSubsites set to 1 should be able to access all subsites and main site,
|
|
|
|
* even though he does not have the ADMIN permission.
|
|
|
|
*/
|
|
|
|
function testEditorCanAccessAllSubsites() {
|
|
|
|
$member = $this->objFromFixture('Member', 'editor');
|
|
|
|
Session::set("loggedInAs", $member->ID);
|
|
|
|
|
2012-10-12 04:09:38 +02:00
|
|
|
$this->get('admin/pages?SubsiteID=0&ajax=1');
|
2011-04-11 02:59:42 +02:00
|
|
|
$this->get('admin');
|
|
|
|
$this->assertEquals(Subsite::currentSubsiteID(), '0', 'Can access main site');
|
|
|
|
|
2013-01-03 17:38:51 +01:00
|
|
|
$mainSubsite = $this->objFromFixture('Subsite', 'main');
|
2012-10-12 04:09:38 +02:00
|
|
|
$this->get("admin/pages?SubsiteID={$mainSubsite->ID}&ajax=1");
|
2011-04-11 02:59:42 +02:00
|
|
|
$this->get('admin');
|
|
|
|
$this->assertEquals(Subsite::currentSubsiteID(), $mainSubsite->ID, 'Can access the subsite');
|
|
|
|
}
|
|
|
|
}
|