Skip to content

Instantly share code, notes, and snippets.

@dataich
Created February 13, 2019 11:41
Show Gist options
  • Save dataich/cb2d227f7144035787f788d8e0a5ebd6 to your computer and use it in GitHub Desktop.
Save dataich/cb2d227f7144035787f788d8e0a5ebd6 to your computer and use it in GitHub Desktop.
<?php
spl_autoload_register(function ($className) {
include "$className.php";
});
class EntrySpec extends PHPUnit_Extensions_Story_TestCase {
/**
* @scenario
*/
public function statusForNewEntryIsDraft() {
$this->given('New Entry')
->then('Status should be', Entry::STATUS_DRAFT);
}
/**
* @scenario
*/
public function statusAfterPublishEntryIsPublished() {
$this->given('Some Entry')
->when('publish Entry')
->then('Status should be', Entry::STATUS_PUBLISHED);
}
/**
* @scenario
*/
public function statusAfterDeleteEntryIsDeleted() {
$this->given('Some Entry')
->when('delete Entry')
->then('Status should be', Entry::STATUS_DELETED);
}
public function runGiven(&$world, $action, $arguments) {
switch($action) {
case 'New Entry':
case 'Some Entry':
$world['entry'] = new Entry();
break;
default:
return $this->notImplemented($action);
}
}
public function runWhen(&$world, $action, $arguments) {
switch($action) {
case 'delete Entry':
$world['entry']->delete();
break;
case 'publish Entry':
$world['entry']->publish();
break;
default:
return $this->notImplemented($action);
}
}
public function runThen(&$world, $action, $arguments) {
switch($action) {
case 'Status should be':
$this->assertEquals($arguments[0], $world['entry']->status);
break;
default:
return $this->notImplemented($action);
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment