From 30f9d1569470d7a4e5b87cf283080f47c3d27e23 Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Mon, 1 Mar 2010 22:32:42 +0000 Subject: [PATCH] MINOR when a parent page is unpublished, unpublish all related virtual pages, includes test coverage (from r94777) (from r96340) --- tests/SubsitesVirtualPageTest.php | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/SubsitesVirtualPageTest.php b/tests/SubsitesVirtualPageTest.php index 61dc493..79f60b6 100644 --- a/tests/SubsitesVirtualPageTest.php +++ b/tests/SubsitesVirtualPageTest.php @@ -282,6 +282,46 @@ class SubsitesVirtualPageTest extends SapphireTest { $this->assertTrue($vp->ExistsOnLive); $this->assertFalse($vp->IsModifiedOnStage); } + + function testUnpublishingParentPageUnpublishesSubsiteVirtualPages() { + StaticPublisher::$disable_realtime = true; + + // Go to main site, get parent page + $subsite = $this->objFromFixture('Subsite_Template', 'main'); + Subsite::changeSubsite($subsite->ID); + $page = $this->objFromFixture('SiteTree', 'importantpage'); + + // Create two SVPs on other subsites + $subsite = $this->objFromFixture('Subsite_Template', 'subsite1'); + Subsite::changeSubsite($subsite->ID); + $vp1 = new SubsitesVirtualPage(); + $vp1->CopyContentFromID = $page->ID; + $vp1->write(); + $vp1->doPublish(); + + $subsite = $this->objFromFixture('Subsite_Template', 'subsite2'); + Subsite::changeSubsite($subsite->ID); + $vp2 = new SubsitesVirtualPage(); + $vp2->CopyContentFromID = $page->ID; + $vp2->write(); + $vp2->doPublish(); + + // Switch back to main site, unpublish source + $subsite = $this->objFromFixture('Subsite_Template', 'main'); + Subsite::changeSubsite($subsite->ID); + $page = $this->objFromFixture('SiteTree', 'importantpage'); + $page->doUnpublish(); + + $subsite = $this->objFromFixture('Subsite_Template', 'subsite1'); + Subsite::changeSubsite($subsite->ID); + $onLive = Versioned::get_by_stage('Page', 'Live', "SiteTree_Live.ID = ".$vp1->ID); + $this->assertNull($onLive, 'SVP has been removed from live'); + + $subsite = $this->objFromFixture('Subsite_Template', 'subsite2'); + Subsite::changeSubsite($subsite->ID); + $onLive = Versioned::get_by_stage('Page', 'Live', "SiteTree_Live.ID = ".$vp2->ID); + $this->assertNull($onLive, 'SVP has been removed from live'); + } function fixVersionNumberCache($page) { $pages = func_get_args();