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; }
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)); }
public function testCancelPage() { $this->post->cancel(); $this->assertTrue(PublishStatus::canceled()->equals($this->post->getStatus())); $this->assertFalse($this->post->isPublished()); }