public function testCanDeleteOrphanedVirtualPagesFromLive() { // An unpublished source page $p = new Page(); $p->Content = "test content"; $p->write(); $p->doPublish(); $vp = new VirtualPage(); $vp->CopyContentFromID = $p->ID; $vp->write(); // Delete the source page $this->assertTrue($vp->canPublish()); $this->assertTrue($p->doDeleteFromLive()); // Confirm that we can unpublish, but not publish $this->assertTrue($vp->canDeleteFromLive()); $this->assertFalse($vp->canPublish()); // Confirm that the action really works $this->assertTrue($vp->doDeleteFromLive()); $this->assertNull(DB::query("SELECT \"ID\" FROM \"SiteTree_Live\" WHERE \"ID\" = {$vp->ID}")->value()); }