Merge pull request #467 from creative-commoners/pulls/2.4/fix-test

MNT Fix test to work with session-manager module
This commit is contained in:
Maxime Rainville 2021-09-09 22:48:38 +12:00 committed by GitHub
commit 3a2ef2b3bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 20 deletions

View File

@ -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';
@ -20,13 +18,6 @@ class SubsiteAdminTest extends BaseSubsiteTest
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
*/
@ -34,24 +25,20 @@ class SubsiteAdminTest extends BaseSubsiteTest
{
$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.