mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 09:05:55 +00:00
Added test case for subsites virtual page onAfterWrite issue, plus changed get_from_all_subsites method to immediately eval and return an ArrayList, instead of lazy eval DataList. Fixes #106
This commit is contained in:
parent
110ce7751d
commit
586d88562c
@ -649,6 +649,8 @@ JS;
|
||||
$oldState = self::$disable_subsite_filter;
|
||||
self::$disable_subsite_filter = true;
|
||||
$result = DataObject::get($className, $filter, $sort, $join, $limit);
|
||||
// conversion to ArrayList forces immediate evaluation, respecting subsite filter setting
|
||||
$result = ArrayList::create($result->toArray());
|
||||
self::$disable_subsite_filter = $oldState;
|
||||
return $result;
|
||||
}
|
||||
|
@ -137,6 +137,53 @@ class SubsitesVirtualPageTest extends BaseSubsiteTest {
|
||||
$this->assertFalse($vp->IsModifiedOnStage);
|
||||
}
|
||||
|
||||
/**
|
||||
* This test ensures published Subsites Virtual Pages immediately reflect updates
|
||||
* to their published target pages. Note - this has to happen when the virtual page
|
||||
* is in a different subsite to the page you are editing and republishing,
|
||||
* otherwise the test will pass falsely due to current subsite ID being the same.
|
||||
*/
|
||||
function testPublishedSubsiteVirtualPagesUpdateIfTargetPageUpdates()
|
||||
{
|
||||
// create page
|
||||
$p = new Page();
|
||||
$p->Content = 'Content';
|
||||
$p->Title = 'Title';
|
||||
$p->writeToStage('Stage');
|
||||
$p->publish('Stage', 'Live');
|
||||
$this->assertTrue($p->ExistsOnLive);
|
||||
|
||||
// change to subsite
|
||||
$subsite = $this->objFromFixture('Subsite', 'subsite2');
|
||||
Subsite::changeSubsite($subsite->ID);
|
||||
Subsite::$disable_subsite_filter = false;
|
||||
|
||||
// create svp in subsite
|
||||
$svp = new SubsitesVirtualPage();
|
||||
$svp->CopyContentFromID = $p->ID;
|
||||
$svp->writeToStage('Stage');
|
||||
$svp->publish('Stage', 'Live');
|
||||
$this->assertEquals($svp->SubsiteID, $subsite->ID);
|
||||
$this->assertTrue($svp->ExistsOnLive);
|
||||
|
||||
// change back to original subsite ("Main site")
|
||||
Subsite::changeSubsite(0);
|
||||
|
||||
// update original page
|
||||
$p->Title = 'New Title';
|
||||
// "save & publish"
|
||||
$p->writeToStage('Stage');
|
||||
$p->publish('Stage', 'Live');
|
||||
$this->assertNotEquals($p->SubsiteID, $subsite->ID);
|
||||
|
||||
// reload SVP from database
|
||||
// can't use DO::get by id because caches.
|
||||
$svpdb = $svp->get()->byID($svp->ID);
|
||||
|
||||
// ensure title changed
|
||||
$this->assertEquals($svpdb->Title, $p->Title);
|
||||
}
|
||||
|
||||
function testUnpublishingParentPageUnpublishesSubsiteVirtualPages() {
|
||||
Config::inst()->update('StaticPublisher', 'disable_realtime', true);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user