Skip to content

Commit

Permalink
Merge branch '2.4' into 2
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Sep 13, 2021
2 parents e306264 + 3a2ef2b commit 0179176
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions tests/php/SubsiteAdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
namespace SilverStripe\Subsites\Tests;

use SilverStripe\CMS\Controllers\CMSMain;
use SilverStripe\Control\Director;
use SilverStripe\Control\Session;
use SilverStripe\Core\Config\Config;
use SilverStripe\Security\Member;
use SilverStripe\Dev\FunctionalTest;
use SilverStripe\Subsites\Model\Subsite;

class SubsiteAdminTest extends BaseSubsiteTest
class SubsiteAdminTest extends FunctionalTest
{
protected static $fixture_file = 'SubsiteTest.yml';

Expand All @@ -20,38 +18,27 @@ protected function setUp()
Config::modify()->set(Subsite::class, 'write_hostmap', false);
}

protected function adminLoggedInSession()
{
return new Session([
'loggedInAs' => $this->idFromFixture(Member::class, 'admin')
]);
}

/**
* Test generation of the view
*/
public function testBasicView()
{
$subsite1ID = $this->objFromFixture(Subsite::class, 'domaintest1')->ID;

// Open the admin area logged in as admin
$response1 = Director::test('admin/subsites/', null, $this->adminLoggedInSession());
$this->logInAs('admin');

// Confirm that this URL gets you the entire page, with the edit form loaded
$response2 = Director::test(
$response = $this->get(
"admin/subsites/SilverStripe-Subsites-Model-Subsite/EditForm/field/"
."SilverStripe-Subsites-Model-Subsite/item/$subsite1ID/edit",
null,
$this->adminLoggedInSession()
."SilverStripe-Subsites-Model-Subsite/item/$subsite1ID/edit"
);
$this->assertTrue(
strpos($response2->getBody(), 'id="Form_ItemEditForm_ID"') !== false,
strpos($response->getBody(), 'id="Form_ItemEditForm_ID"') !== false,
'Testing Form_ItemEditForm_ID exists'
);
$this->assertTrue(strpos($response2->getBody(), '<head') !== false, 'Testing <head> exists');
$this->assertTrue(strpos($response->getBody(), '<head') !== false, 'Testing <head> exists');
}


/**
* 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.
Expand Down

0 comments on commit 0179176

Please sign in to comment.