/**
  * Test that a page with a past unpublish date creates the correct jobs
  */
 public function testPastUnPublishThenPublish()
 {
     $page = new Page();
     $page->Title = 'My Page';
     $page->write();
     // No publish
     $this->assertEmpty($page->PublishJobID);
     $this->assertEmpty($page->UnPublishJobID);
     // Set a past unpublish date
     $page->UnPublishOnDate = '2010-01-01 00:00:00';
     $page->write();
     // We should still have a job to unpublish this page, but not publish
     $this->assertEmpty($page->PublishJobID);
     $this->assertNotEmpty($page->UnPublishJobID);
     // Check that this job is set for immediate run
     $unpublish = strtotime($page->UnPublishJob()->StartAfter);
     $this->assertEmpty($unpublish);
     // Now add an publish date in the past, but after the unpublish job,
     // and ensure that this correctly overrides the open unpublish request
     $page->PublishOnDate = '2010-01-02 00:00:00';
     $page->write();
     // Now we should have an publish job, but the unpublish job is noticably absent
     $this->assertNotEmpty($page->PublishJobID);
     $this->assertEmpty($page->UnPublishJobID);
     // Check that this publish job is set for immediate run
     $publish = strtotime($page->PublishJob()->StartAfter);
     $this->assertEmpty($publish);
     // Now add a publish date in the future, and ensure that we get the correct combination of
     // publish and unpublish jobs
     $page->PublishOnDate = '2015-01-01 12:00:00';
     $page->write();
     // Both jobs exist
     $this->assertNotEmpty($page->PublishJobID);
     $this->assertNotEmpty($page->UnPublishJobID);
     // Check that this unpublish job is set for immediate run and the unpublish for future
     $publish = strtotime($page->PublishJob()->StartAfter);
     $unpublish = strtotime($page->UnPublishJob()->StartAfter);
     $this->assertEmpty($unpublish);
     // for immediate run
     $this->assertGreaterThan(strtotime(SS_Datetime::now()->getValue()), $publish);
     // for later run
 }