Created
February 13, 2019 11:41
-
-
Save dataich/cb2d227f7144035787f788d8e0a5ebd6 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 | |
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