2009-05-04 07:03:44 +02:00
|
|
|
<?php
|
2007-08-16 08:38:29 +02:00
|
|
|
|
2015-11-23 04:53:45 +01:00
|
|
|
class SubsiteAdminTest extends BaseSubsiteTest
|
|
|
|
{
|
|
|
|
public static $fixture_file = 'subsites/tests/SubsiteTest.yml';
|
2007-08-21 00:37:43 +02:00
|
|
|
|
2015-11-23 04:53:45 +01:00
|
|
|
public function adminLoggedInSession()
|
|
|
|
{
|
2007-08-21 03:38:20 +02:00
|
|
|
return new Session(array(
|
|
|
|
'loggedInAs' => $this->idFromFixture('Member', 'admin')
|
|
|
|
));
|
|
|
|
}
|
2012-07-16 01:14:13 +02:00
|
|
|
|
2007-08-21 03:38:20 +02:00
|
|
|
/**
|
|
|
|
* Test generation of the view
|
|
|
|
*/
|
2015-11-23 04:53:45 +01:00
|
|
|
public function testBasicView()
|
|
|
|
{
|
|
|
|
Subsite::$write_hostmap = false;
|
|
|
|
$subsite1ID = $this->objFromFixture('Subsite', 'domaintest1')->ID;
|
2010-08-04 00:41:10 +02:00
|
|
|
|
2007-08-21 03:38:20 +02:00
|
|
|
// Open the admin area logged in as admin
|
|
|
|
$response1 = Director::test('admin/subsites/', null, $this->adminLoggedInSession());
|
|
|
|
|
|
|
|
// Confirm that this URL gets you the entire page, with the edit form loaded
|
2015-11-23 04:53:45 +01:00
|
|
|
$response2 = Director::test("admin/subsites/Subsite/EditForm/field/Subsite/item/$subsite1ID/edit", null, $this->adminLoggedInSession());
|
|
|
|
$this->assertTrue(strpos($response2->getBody(), 'id="Form_ItemEditForm_ID"') !== false, "Testing Form_ItemEditForm_ID exists");
|
2008-03-19 05:26:00 +01:00
|
|
|
$this->assertTrue(strpos($response2->getBody(), '<head') !== false, "Testing <head> exists");
|
2007-08-21 03:38:20 +02:00
|
|
|
}
|
2009-02-24 23:09:15 +01:00
|
|
|
|
2015-11-23 04:53:45 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test that the main-site user with ADMIN permissions can access all subsites, regardless
|
|
|
|
* of whether he is in a subsite-specific group or not.
|
|
|
|
*/
|
|
|
|
public function testMainsiteAdminCanAccessAllSubsites()
|
|
|
|
{
|
|
|
|
$member = $this->objFromFixture('Member', 'admin');
|
|
|
|
Session::set("loggedInAs", $member->ID);
|
|
|
|
|
|
|
|
$cmsMain = new CMSMain();
|
|
|
|
foreach ($cmsMain->Subsites() as $subsite) {
|
|
|
|
$ids[$subsite->ID] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->assertArrayHasKey(0, $ids, "Main site accessible");
|
|
|
|
$this->assertArrayHasKey($this->idFromFixture('Subsite', 'main'), $ids, "Site with no groups inaccesible");
|
|
|
|
$this->assertArrayHasKey($this->idFromFixture('Subsite', 'subsite1'), $ids, "Subsite1 Template inaccessible");
|
|
|
|
$this->assertArrayHasKey($this->idFromFixture('Subsite', 'subsite2'), $ids, "Subsite2 Template inaccessible");
|
|
|
|
}
|
2007-08-16 08:38:29 +02:00
|
|
|
}
|