コード例 #1
0
 public function isPublished()
 {
     if (!$this->status->equals(PublishStatus::usable())) {
         return false;
     }
     if (!$this->published || $this->published < new DateTime('now')) {
         return false;
     }
     if ($this->expires && $this->expires < new DateTime('now')) {
         return false;
     }
     return true;
 }
コード例 #2
0
 public function testSerialize()
 {
     $draft = PublishStatus::draft();
     $usable = PublishStatus::usable();
     $withheld = PublishStatus::withheld();
     $canceled = PublishStatus::canceled();
     $this->assertEquals('"draft"', json_encode($draft));
     $this->assertEquals('"usable"', json_encode($usable));
     $this->assertEquals('"withheld"', json_encode($withheld));
     $this->assertEquals('"canceled"', json_encode($canceled));
 }
コード例 #3
0
 public function testCancelPage()
 {
     $this->post->cancel();
     $this->assertTrue(PublishStatus::canceled()->equals($this->post->getStatus()));
     $this->assertFalse($this->post->isPublished());
 }