Skip to content

Instantly share code, notes, and snippets.

@marijn
Created February 21, 2012 13:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marijn/1876426 to your computer and use it in GitHub Desktop.
Save marijn/1876426 to your computer and use it in GitHub Desktop.
<?php
final class BlogPost
{
private $created;
private $publish;
public function __construct()
{
$this->created = new DateTime('now');
}
public function markForPublishing(DateTime $publish)
{
$this->publish = $publish;
}
public function isPublishedOn(DateTime $reference)
{
return $this->publish instanceof DateTime && $this->publish >= reference;
}
public function getCreated()
{
return $this->created;
}
}
Feature: Blogpost date example
In order to see if an article is published
As an author
I need to be able to check if a blog post has been published
Scenario: Not yet published blogpost
Given a blogpost
When I mark it for publishing "tomorrow"
And I check if the blogpost is published "now"
Then it tells me the blogpost is not yet published
Scenario: Published blogpost
Given a blogpost
When I mark it for publishing "now"
And I check if the blogpost is published "tomorrow"
Then it tells me the blogpost is published
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment