FIX Allow persisted subsite IDs to session from state, fix remaining unit tests

This commit is contained in:
Robbie Averill 2017-08-30 15:29:13 +12:00
parent c155855100
commit b0087b9035
12 changed files with 170 additions and 112 deletions

View File

@ -6,10 +6,6 @@ After:
SilverStripe\AssetAdmin\Controller\AssetAdmin:
treats_subsite_0_as_global: true
Director:
rules:
SubsiteXHRController: SilverStripe\Subsites\Controller\SubsiteXHRController
SilverStripe\Reports\Report:
excluded_reports:
- SilverStripe\Subsites\Reports\SubsiteReportWrapper

View File

@ -2,24 +2,61 @@
namespace SilverStripe\Subsites\Middleware;
use SilverStripe\Admin\AdminRootController;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Control\Middleware\HTTPMiddleware;
use SilverStripe\Core\Config\Configurable;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\Subsites\State\SubsiteState;
class InitStateMiddleware implements HTTPMiddleware
{
use Configurable;
/**
* URL paths that should be considered as admin only, i.e. not frontend
*
* @config
* @var array
*/
private static $admin_url_paths = [
'dev/',
'graphql/',
];
public function process(HTTPRequest $request, callable $delegate)
{
$state = SubsiteState::create();
Injector::inst()->registerService($state);
// If the request is from the CMS, we should enable session storage
$state->setUseSessions($this->getIsAdmin($request));
$state->setSubsiteId($this->detectSubsiteId($request));
return $delegate($request);
}
/**
* Determine whether the website is being viewed from an admin protected area or not
*
* @param HTTPRequest $request
* @return bool
*/
public function getIsAdmin(HTTPRequest $request)
{
$adminPaths = static::config()->get('admin_url_paths');
$adminPaths[] = AdminRootController::config()->get('url_base') . '/';
$currentPath = rtrim($request->getURL(), '/') . '/';
foreach ($adminPaths as $adminPath) {
if (substr($currentPath, 0, strlen($adminPath)) === $adminPath) {
return true;
}
}
return false;
}
/**
* Use the given request to detect the current subsite ID
*
@ -34,7 +71,7 @@ class InitStateMiddleware implements HTTPMiddleware
$id = (int) $request->getVar('SubsiteID');
}
if (Subsite::$use_session_subsiteid) {
if (SubsiteState::singleton()->getUseSessions()) {
$id = $request->getSession()->get('SubsiteID');
}

View File

@ -2,6 +2,7 @@
namespace SilverStripe\Subsites\State;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Core\Injector\Injector;
@ -17,6 +18,11 @@ class SubsiteState
*/
protected $subsiteId;
/**
* @var bool
*/
protected $useSessions;
/**
* Get the current subsite ID
*
@ -37,6 +43,36 @@ class SubsiteState
{
$this->subsiteId = (int) $id;
// Persist to session, if they are enabled
if ($this->getUseSessions() && Injector::inst()->has(HTTPRequest::class)) {
Injector::inst()
->get(HTTPRequest::class)
->getSession()
->set('SubsiteID', $id);
}
return $this;
}
/**
* Get whether to use sessions for storing the subsite ID
*
* @return bool
*/
public function getUseSessions()
{
return $this->useSessions;
}
/**
* Set whether to use sessions for storing the subsite ID
*
* @param bool $useSessions
* @return $this
*/
public function setUseSessions($useSessions)
{
$this->useSessions = $useSessions;
return $this;
}

View File

@ -11,12 +11,10 @@ use SilverStripe\Subsites\Model\Subsite;
*/
class SubsiteXHRController extends LeftAndMain
{
/**
* @todo Temporary addition due to new requirements for LeftAndMain
* descendants in SS4. Consider alternate implementation.
*/
private static $url_segment = 'subsite_xhr';
private static $ignore_menuitem = true;
/**
* Relax the access permissions, so anyone who has access to any CMS subsite can access this controller.
* @param null $member
@ -24,7 +22,7 @@ class SubsiteXHRController extends LeftAndMain
*/
public function canView($member = null)
{
if (parent::canView()) {
if (parent::canView($member)) {
return true;
}
@ -50,11 +48,10 @@ class SubsiteXHRController extends LeftAndMain
public function getResponseNegotiator()
{
$negotiator = parent::getResponseNegotiator();
$self = $this;
// Register a new callback
$negotiator->setCallback('SubsiteList', function () use (&$self) {
return $self->SubsiteList();
$negotiator->setCallback('SubsiteList', function () {
return $this->SubsiteList();
});
return $negotiator;

View File

@ -2,6 +2,7 @@
namespace SilverStripe\Subsites\Extensions;
use SilverStripe\Admin\AdminRootController;
use SilverStripe\Admin\CMSMenu;
use SilverStripe\Admin\LeftAndMainExtension;
use SilverStripe\CMS\Model\SiteTree;
@ -153,13 +154,13 @@ class LeftAndMainSubsites extends LeftAndMainExtension
$module = ModuleLoader::getModule('silverstripe/subsites');
Requirements::javascript($module->getRelativeResourcePath('javascript/LeftAndMain_Subsites.js'));
$output = new ArrayList();
$output = ArrayList::create();
foreach ($list as $subsite) {
$CurrentState = $subsite->ID == $currentSubsiteID ? 'selected' : '';
$currentState = $subsite->ID == $currentSubsiteID ? 'selected' : '';
$output->push(new ArrayData([
'CurrentState' => $CurrentState,
$output->push(ArrayData::create([
'CurrentState' => $currentState,
'ID' => $subsite->ID,
'Title' => Convert::raw2xml($subsite->Title)
]));
@ -175,7 +176,7 @@ class LeftAndMainSubsites extends LeftAndMainExtension
}
// Don't display SubsiteXHRController
if ($controllerName == SubsiteXHRController::class) {
if (singleton($controllerName) instanceof SubsiteXHRController) {
return false;
}
@ -255,31 +256,28 @@ class LeftAndMainSubsites extends LeftAndMainExtension
*/
public function onBeforeInit()
{
// We are accessing the CMS, so we need to let Subsites know we will be using the session.
Subsite::$use_session_subsiteid = true;
$request = Controller::curr()->getRequest();
$session = $request->getSession();
// FIRST, check if we need to change subsites due to the URL.
// Catch forced subsite changes that need to cause CMS reloads.
if ($request->getVar('SubsiteID')) {
if ($request->getVar('SubsiteID') !== null) {
// Clear current page when subsite changes (or is set for the first time)
if (!$session->get('SubsiteID') || $request->getVar('SubsiteID') != $session->get('SubsiteID')) {
$session->clear(sprintf('%s.currentPage', get_class($this->owner)));
}
// Update current subsite in session
Subsite::changeSubsite($_GET['SubsiteID']);
Subsite::changeSubsite($request->getVar('SubsiteID'));
//Redirect to clear the current page
// Redirect to clear the current page
if ($this->owner->canView(Security::getCurrentUser())) {
//Redirect to clear the current page
return $this->owner->redirect($this->owner->Link());
}
//Redirect to the default CMS section
return $this->owner->redirect('admin/');
// Redirect to the default CMS section
return $this->owner->redirect(AdminRootController::config()->get('url_base') . '/');
}
// Automatically redirect the session to appropriate subsite when requesting a record.

View File

@ -31,6 +31,7 @@ use SilverStripe\ORM\SS_List;
use SilverStripe\Security\Group;
use SilverStripe\Security\Member;
use SilverStripe\Security\Permission;
use SilverStripe\Security\Security;
use SilverStripe\Subsites\State\SubsiteState;
use SilverStripe\Versioned\Versioned;
use UnexpectedValueException;
@ -46,15 +47,6 @@ class Subsite extends DataObject
private static $table_name = 'Subsite';
/**
* @var $use_session_subsiteid Boolean Set to TRUE when using the CMS and FALSE
* when browsing the frontend of a website.
*
* @todo Remove flag once the Subsite CMS works without session state,
* similarly to the Translatable module.
*/
public static $use_session_subsiteid = false;
/**
* @var boolean $disable_subsite_filter If enabled, bypasses the query decoration
* to limit DataObject::get*() calls to a specific subsite. Useful for debugging.
@ -155,7 +147,7 @@ class Subsite extends DataObject
/**
* Switch to another subsite through storing the subsite identifier in the current PHP session.
* Only takes effect when {@link Subsite::$use_session_subsiteid} is set to TRUE.
* Only takes effect when {@link SubsiteState::singleton()->getUseSessions()} is set to TRUE.
*
* @param int|Subsite $subsite Either the ID of the subsite, or the subsite object itself
*/
@ -163,7 +155,7 @@ class Subsite extends DataObject
{
// Session subsite change only meaningful if the session is active.
// Otherwise we risk setting it to wrong value, e.g. if we rely on currentSubsiteID.
if (!Subsite::$use_session_subsiteid) {
if (!SubsiteState::singleton()->getUseSessions()) {
return;
}
@ -216,6 +208,12 @@ class Subsite extends DataObject
}
$SQL_host = Convert::raw2sql($host);
if (!in_array('SubsiteDomain', DB::table_list())) {
// Table hasn't been created yet. Might be a dev/build, skip.
return 0;
}
$matchingDomains = DataObject::get(
SubsiteDomain::class,
"'$SQL_host' LIKE replace(\"SubsiteDomain\".\"Domain\",'*','%')",

View File

@ -4,6 +4,7 @@ namespace SilverStripe\Subsites\Tests;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\Subsites\State\SubsiteState;
class BaseSubsiteTest extends SapphireTest
{
@ -11,7 +12,7 @@ class BaseSubsiteTest extends SapphireTest
{
parent::setUp();
Subsite::$use_session_subsiteid = true;
SubsiteState::singleton()->setUseSessions(true);
Subsite::$force_subsite = null;
}

View File

@ -68,7 +68,7 @@ class LeftAndMainSubsitesTest extends FunctionalTest
$ids[] = 0;
// Enable session-based subsite tracking.
Subsite::$use_session_subsiteid = true;
SubsiteState::singleton()->setUseSessions(true);
foreach ($ids as $id) {
Subsite::changeSubsite($id);

View File

@ -2,10 +2,10 @@
namespace SilverStripe\Subsites\Tests;
use Page;
use SilverStripe\CMS\Controllers\CMSPageEditController;
use SilverStripe\Core\Config\Config;
use SilverStripe\Dev\FunctionalTest;
use SilverStripe\Subsites\Controller\SubsiteXHRController;
use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\Subsites\State\SubsiteState;
@ -37,19 +37,17 @@ class SubsiteAdminFunctionalTest extends FunctionalTest
*/
public function testAnonymousIsForbiddenAdminAccess()
{
$this->logOut();
$response = $this->getAndFollowAll('admin/pages/?SubsiteID=0');
$this->assertRegExp('#^Security/login.*#', $this->mainSession->lastUrl(), 'Admin is disallowed');
$this->assertContains('Security/login', $this->mainSession->lastUrl(), 'Admin is disallowed');
$subsite1 = $this->objFromFixture(Subsite::class, 'subsite1');
$response = $this->getAndFollowAll("admin/pages/?SubsiteID={$subsite1->ID}");
$this->assertRegExp('#^Security/login.*#', $this->mainSession->lastUrl(), 'Admin is disallowed');
$this->assertContains('Security/login', $this->mainSession->lastUrl(), 'Admin is disallowed');
$response = $this->getAndFollowAll('SubsiteXHRController');
$this->assertRegExp(
'#^Security/login.*#',
$this->mainSession->lastUrl(),
'SubsiteXHRController is disallowed'
);
$response = $this->getAndFollowAll('admin/subsite_xhr');
$this->assertContains('Security/login', $this->mainSession->lastUrl(), 'SubsiteXHRController is disallowed');
}
/**
@ -60,60 +58,57 @@ class SubsiteAdminFunctionalTest extends FunctionalTest
$this->logInAs('admin');
$this->getAndFollowAll('admin/pages/?SubsiteID=0');
$this->assertEquals(SubsiteState::singleton()->getSubsiteId(), '0', 'Can access main site.');
$this->assertRegExp('#^admin/pages.*#', $this->mainSession->lastUrl(), 'Lands on the correct section');
$this->assertEquals(0, $this->session()->get('SubsiteID'), 'Can access main site.');
$this->assertContains('admin/pages', $this->mainSession->lastUrl(), 'Lands on the correct section');
$subsite1 = $this->objFromFixture(Subsite::class, 'subsite1');
$this->getAndFollowAll("admin/pages/?SubsiteID={$subsite1->ID}");
$this->assertEquals(SubsiteState::singleton()->getSubsiteId(), $subsite1->ID, 'Can access other subsite.');
$this->assertRegExp('#^admin/pages.*#', $this->mainSession->lastUrl(), 'Lands on the correct section');
$response = $this->getAndFollowAll(SubsiteXHRController::class);
$this->assertNotRegExp(
'#^Security/login.*#',
$this->mainSession->lastUrl(),
'SubsiteXHRController is reachable'
);
// Check the session manually, since the state is unique to the request, not this test
$this->assertEquals($subsite1->ID, $this->session()->get('SubsiteID'), 'Can access other subsite.');
$this->assertContains('admin/pages', $this->mainSession->lastUrl(), 'Lands on the correct section');
$response = $this->getAndFollowAll('admin/subsite_xhr');
$this->assertNotContains('Security/login', $this->mainSession->lastUrl(), 'SubsiteXHRController is reachable');
}
public function testAdminIsRedirectedToObjectsSubsite()
{
$this->logInAs('admin');
$mainSubsitePage = $this->objFromFixture('Page', 'mainSubsitePage');
$subsite1Home = $this->objFromFixture('Page', 'subsite1_home');
Config::nest();
$mainSubsitePage = $this->objFromFixture(Page::class, 'mainSubsitePage');
$subsite1Home = $this->objFromFixture(Page::class, 'subsite1_home');
Config::modify()->set(CMSPageEditController::class, 'treats_subsite_0_as_global', false);
Subsite::changeSubsite(0);
$this->getAndFollowAll("admin/pages/edit/show/$subsite1Home->ID");
$this->assertEquals(
SubsiteState::singleton()->getSubsiteId(),
$subsite1Home->SubsiteID,
$this->session()->get('SubsiteID'),
'Loading an object switches the subsite'
);
$this->assertRegExp('#^admin/pages.*#', $this->mainSession->lastUrl(), 'Lands on the correct section');
$this->assertContains('admin/pages', $this->mainSession->lastUrl(), 'Lands on the correct section');
Config::modify()->set(CMSPageEditController::class, 'treats_subsite_0_as_global', true);
Subsite::changeSubsite(0);
$this->getAndFollowAll("admin/pages/edit/show/$subsite1Home->ID");
$this->assertEquals(
SubsiteState::singleton()->getSubsiteId(),
$subsite1Home->SubsiteID,
$this->session()->get('SubsiteID'),
'Loading a non-main-site object still switches the subsite if configured with treats_subsite_0_as_global'
);
$this->assertRegExp('#^admin/pages.*#', $this->mainSession->lastUrl(), 'Lands on the correct section');
$this->assertContains('admin/pages', $this->mainSession->lastUrl(), 'Lands on the correct section');
$this->getAndFollowAll("admin/pages/edit/show/$mainSubsitePage->ID");
$this->assertNotEquals(
SubsiteState::singleton()->getSubsiteId(),
$mainSubsitePage->SubsiteID,
$this->session()->get('SubsiteID'),
'Loading a main-site object does not change the subsite if configured with treats_subsite_0_as_global'
);
$this->assertRegExp('#^admin/pages.*#', $this->mainSession->lastUrl(), 'Lands on the correct section');
Config::unnest();
$this->assertContains('admin/pages', $this->mainSession->lastUrl(), 'Lands on the correct section');
}
/**
@ -124,21 +119,17 @@ class SubsiteAdminFunctionalTest extends FunctionalTest
{
$this->logInAs('editor');
$this->getAndFollowAll('admin/pages/?SubsiteID=0');
$this->assertEquals(SubsiteState::singleton()->getSubsiteId(), '0', 'Can access main site.');
$this->assertRegExp('#^admin/pages.*#', $this->mainSession->lastUrl(), 'Lands on the correct section');
$this->get('admin/pages/?SubsiteID=0');
$this->assertEquals(0, $this->session()->get('SubsiteID'), 'Can access main site.');
$this->assertContains('admin/pages', $this->mainSession->lastUrl(), 'Lands on the correct section');
$subsite1 = $this->objFromFixture(Subsite::class, 'subsite1');
$this->getAndFollowAll("admin/pages/?SubsiteID={$subsite1->ID}");
$this->assertEquals(SubsiteState::singleton()->getSubsiteId(), $subsite1->ID, 'Can access other subsite.');
$this->assertRegExp('#^admin/pages.*#', $this->mainSession->lastUrl(), 'Lands on the correct section');
$this->get("admin/pages/?SubsiteID={$subsite1->ID}");
$this->assertEquals($subsite1->ID, $this->session()->get('SubsiteID'), 'Can access other subsite.');
$this->assertContains('admin/pages', $this->mainSession->lastUrl(), 'Lands on the correct section');
$response = $this->getAndFollowAll('SubsiteXHRController');
$this->assertNotRegExp(
'#^Security/login.*#',
$this->mainSession->lastUrl(),
'SubsiteXHRController is reachable'
);
$response = $this->get('admin/subsite_xhr');
$this->assertNotContains('Security/login', $this->mainSession->lastUrl(), 'SubsiteXHRController is reachable');
}
/**
@ -152,33 +143,37 @@ class SubsiteAdminFunctionalTest extends FunctionalTest
// Check allowed URL.
$this->getAndFollowAll("admin/pages/?SubsiteID={$subsite1->ID}");
$this->assertEquals(SubsiteState::singleton()->getSubsiteId(), $subsite1->ID, 'Can access own subsite.');
$this->assertRegExp('#^admin/pages.*#', $this->mainSession->lastUrl(), 'Can access permitted section.');
$this->assertEquals($subsite1->ID, $this->session()->get('SubsiteID'), 'Can access own subsite.');
$this->assertContains('admin/pages', $this->mainSession->lastUrl(), 'Can access permitted section.');
// Check forbidden section in allowed subsite.
$this->getAndFollowAll("admin/assets/?SubsiteID={$subsite1->ID}");
$this->assertEquals(SubsiteState::singleton()->getSubsiteId(), $subsite1->ID, 'Is redirected within subsite.');
$this->assertNotRegExp(
'#^admin/assets/.*#',
$this->assertEquals($subsite1->ID, $this->session()->get('SubsiteID'), 'Is redirected within subsite.');
$this->assertNotContains(
'admin/assets',
$this->mainSession->lastUrl(),
'Is redirected away from forbidden section'
);
// Check forbidden site, on a section that's allowed on another subsite
$this->getAndFollowAll('admin/pages/?SubsiteID=0');
$this->assertEquals(SubsiteState::singleton()->getSubsiteId(), $subsite1->ID, 'Is redirected to permitted subsite.');
$this->assertEquals(
$this->session()->get('SubsiteID'),
$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(SubsiteState::singleton()->getSubsiteId(), $subsite1->ID, 'Is redirected to first permitted subsite.');
$this->assertNotRegExp('#^Security/login.*#', $this->mainSession->lastUrl(), 'Is not denied access');
$this->assertEquals(
$this->session()->get('SubsiteID'),
$subsite1->ID,
'Is redirected to first permitted subsite.'
);
$this->assertNotContains('Security/login', $this->mainSession->lastUrl(), 'Is not denied access');
// Check the standalone XHR controller.
$response = $this->getAndFollowAll(SubsiteXHRController::class);
$this->assertNotRegExp(
'#^Security/login.*#',
$this->mainSession->lastUrl(),
'SubsiteXHRController is reachable'
);
$response = $this->getAndFollowAll('admin/subsite_xhr');
$this->assertNotContains('Security/login', $this->mainSession->lastUrl(), 'SubsiteXHRController is reachable');
}
}

View File

@ -315,8 +315,7 @@ class SubsiteTest extends BaseSubsiteTest
$domain5a = $this->objFromFixture(SubsiteDomain::class, 'dt5');
// Check protocol when current protocol is http://
$_SERVER['HTTP_HOST'] = 'www.mysite.com';
$_SERVER['HTTPS'] = '';
Config::modify()->set(Director::class, 'alternate_base_url', 'http://www.mysite.com');
$this->assertEquals('http://two.mysite.com/', $subsite2->absoluteBaseURL());
$this->assertEquals('http://two.mysite.com/', $domain2a->absoluteBaseURL());
@ -328,8 +327,7 @@ class SubsiteTest extends BaseSubsiteTest
$this->assertEquals('http://www.tertiary.com/', $domain5a->absoluteBaseURL());
// Check protocol when current protocol is https://
$_SERVER['HTTP_HOST'] = 'www.mysite.com';
$_SERVER['HTTPS'] = 'ON';
Config::modify()->set(Director::class, 'alternate_base_url', 'https://www.mysite.com');
$this->assertEquals('https://two.mysite.com/', $subsite2->absoluteBaseURL());
$this->assertEquals('https://two.mysite.com/', $domain2a->absoluteBaseURL());

View File

@ -14,7 +14,7 @@ class SubsiteXHRControllerTest extends FunctionalTest
// Test unauthenticated access
$this->logOut();
$result = $this->get('SubsiteXHRController', null, [
$result = $this->get('admin/subsite_xhr', null, [
'X-Pjax' => 'SubsiteList',
'X-Requested-With' => 'XMLHttpRequest'
]);
@ -22,7 +22,7 @@ class SubsiteXHRControllerTest extends FunctionalTest
// Login with NO permissions
$this->logInWithPermission('NOT_CMS_PERMISSION');
$result = $this->get('SubsiteXHRController', null, [
$result = $this->get('admin/subsite_xhr', null, [
'X-Pjax' => 'SubsiteList',
'X-Requested-With' => 'XMLHttpRequest'
]);
@ -30,12 +30,14 @@ class SubsiteXHRControllerTest extends FunctionalTest
// Test cms user
$this->logInWithPermission('CMS_ACCESS_CMSMain');
$result = $this->get('SubsiteXHRController', null, [
$result = $this->get('admin/subsite_xhr', null, [
'X-Pjax' => 'SubsiteList',
'X-Requested-With' => 'XMLHttpRequest'
]);
$this->assertEquals(200, $result->getStatusCode());
$this->assertEquals('text/json', $result->getHeader('Content-Type'));
$body = $result->getBody();
$this->assertContains('Main site', $body);
$this->assertContains('Test 1', $body);

View File

@ -83,13 +83,13 @@ class SubsitesVirtualPageTest extends BaseSubsiteTest
// Publish the source page
$page = $this->objFromFixture(SiteTree::class, 'page1');
$this->assertTrue($page->doPublish());
$this->assertTrue($page->publishSingle());
// Create a virtual page from it, and publish that
$svp = new SubsitesVirtualPage();
$svp->CopyContentFromID = $page->ID;
$svp->write();
$svp->doPublish();
$svp->publishSingle();
// Rename the file
$file = $this->objFromFixture(File::class, 'file1');
@ -122,7 +122,7 @@ class SubsitesVirtualPageTest extends BaseSubsiteTest
$this->assertTrue($vp->IsAddedToStage);
// VP is still orange after we publish
$p->doPublish();
$p->publishSingle();
$this->fixVersionNumberCache($vp);
$this->assertTrue($vp->IsAddedToStage);
@ -135,12 +135,12 @@ class SubsitesVirtualPageTest extends BaseSubsiteTest
// Also remains orange after a republish
$p->Content = 'new content';
$p->write();
$p->doPublish();
$p->publishSingle();
$this->fixVersionNumberCache($vp2);
$this->assertTrue($vp2->IsAddedToStage);
// VP is now published
$vp->doPublish();
$vp->publishSingle();
$this->fixVersionNumberCache($vp);
$this->assertTrue($vp->ExistsOnLive);
@ -155,7 +155,7 @@ class SubsitesVirtualPageTest extends BaseSubsiteTest
$this->assertTrue($vp->IsModifiedOnStage);
// Publish, VP goes black
$p->doPublish();
$p->publishSingle();
$this->fixVersionNumberCache($vp);
$this->assertTrue($vp->ExistsOnLive);
$this->assertFalse($vp->IsModifiedOnStage);
@ -272,8 +272,8 @@ class SubsitesVirtualPageTest extends BaseSubsiteTest
$subsite1Vp->SubsiteID = $subsite1->ID;
$subsite1Vp->write();
$this->assertNotEquals(
$subsite1Vp->URLSegment,
$subsite1Page->URLSegment,
(string) $subsite1Vp->URLSegment,
(string) $subsite1Page->URLSegment,
"Doesn't allow explicit URLSegment overrides when already existing in same subsite"
);