Created
February 21, 2012 13:03
-
-
Save marijn/1876426 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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