Created
May 19, 2011 20:58
-
-
Save everzet/981729 to your computer and use it in GitHub Desktop.
comparison of BDD-style PHPUnit VS PHPSpec1 (has almost nothing to do with phpspec2)
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 | |
// how that: | |
class DescribeContextZend extends PHPSpec_Context | |
{ | |
public function itShouldSetControllerNameUsingContextClass() | |
{ | |
$context = new DescribeFooController; | |
$this->spec($context->getController())->should->be('Foo'); | |
} | |
public function itShouldCreateFrontControllerWhenInstantiated() | |
{ | |
$context = new DescribeFooController; | |
$this->spec($context->getFrontController())->should | |
->beAnInstanceOf('Zend_Controller_Front'); | |
} | |
} | |
// is better than that: | |
class ContextZendTest extends PHPUnit_Framework_TestCase | |
{ | |
/** | |
* @Test | |
*/ | |
public function itShouldSetControllerNameUsingContextClass() | |
{ | |
$context = new DescribeFooController; | |
$this->assertEquals('Foo', $context->getController()); | |
} | |
/** | |
* @Test | |
*/ | |
public function itShouldCreateFrontControllerWhenInstantiated() | |
{ | |
$context = new DescribeFooController; | |
$this->assertInstanceOf('Zend_Controller_Front', $context->getFrontController()); | |
} | |
} | |
// ? :-) | |
// And what's even worse - second one is really-really more readable! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please refer to the update of the syntax in phpspec version 2: https://gist.github.com/07831388218f192068ce