function testEmbargoUntilPublished() { $s1 = $this->objFromFixture('SiteTree', 's1'); $doc = new DMSDocument(); $doc->Filename = "test file"; $doc->Folder = "0"; $dID = $doc->write(); $doc->addPage($s1); $s1->publish('Stage', 'Live'); $s1->doPublish(); $this->assertFalse($doc->isHidden(), "Document is not hidden"); $this->assertFalse($doc->isEmbargoed(), "Document is not embargoed"); $this->assertFalse($doc->isExpired(), "Document is not expired"); $doc->embargoUntilPublished(); $this->assertTrue($doc->isHidden(), "Document is hidden"); $this->assertTrue($doc->isEmbargoed(), "Document is embargoed"); $this->assertFalse($doc->isExpired(), "Document is not expired"); $s1->publish('Stage', 'Live'); $s1->doPublish(); $doc = DataObject::get_by_id("DMSDocument", $dID); $this->assertFalse($doc->isHidden(), "Document is not hidden"); $this->assertFalse($doc->isEmbargoed(), "Document is not embargoed"); $this->assertFalse($doc->isExpired(), "Document is not expired"); $doc->embargoUntilPublished(); $doc = DataObject::get_by_id("DMSDocument", $dID); $this->assertTrue($doc->isHidden(), "Document is hidden"); $this->assertTrue($doc->isEmbargoed(), "Document is embargoed"); $this->assertFalse($doc->isExpired(), "Document is not expired"); $doc->embargoIndefinitely(); $doc = DataObject::get_by_id("DMSDocument", $dID); $this->assertTrue($doc->isHidden(), "Document is hidden"); $this->assertTrue($doc->isEmbargoed(), "Document is embargoed"); $this->assertFalse($doc->isExpired(), "Document is not expired"); $s1->publish('Stage', 'Live'); $s1->doPublish(); $doc = DataObject::get_by_id("DMSDocument", $dID); $this->assertTrue($doc->isHidden(), "Document is still hidden because although the untilPublish flag is cleared, the indefinitely flag is still there"); $this->assertTrue($doc->isEmbargoed(), "Document is embargoed"); $this->assertFalse($doc->isExpired(), "Document is not expired"); $doc->clearEmbargo(); $doc = DataObject::get_by_id("DMSDocument", $dID); $this->assertFalse($doc->isHidden(), "Document is not hidden"); $this->assertFalse($doc->isEmbargoed(), "Document is not embargoed"); $this->assertFalse($doc->isExpired(), "Document is not expired"); }
function testUnpublishPageWithAssociatedDocuments() { $s2 = $this->objFromFixture('SiteTree', 's2'); $s2->publish('Stage', 'Live'); $s2ID = $s2->ID; $doc = new DMSDocument(); $doc->Filename = "delete test file"; $doc->Folder = "0"; $doc->write(); $doc->addPage($s2); $s2->doDeleteFromLive(); $documents = DataObject::get("DMSDocument", "\"Filename\" = 'delete test file'"); $this->assertEquals($documents->Count(), '1', "Deleting a page from live stage doesn't delete the associated docs," . "even if it's the last page they're associated with"); $s2 = Versioned::get_one_by_stage('SiteTree', 'Stage', sprintf('"SiteTree"."ID" = %d', $s2ID)); $s2->delete(); $documents = DataObject::get("DMSDocument", "\"Filename\" = 'delete test file'"); $this->assertEquals($documents->Count(), '0', "However, deleting the draft version of the last page that a document is " . "associated with causes that document to be deleted as well"); }