Skip to content

Instantly share code, notes, and snippets.

@everzet
Created May 19, 2011 20:58
Show Gist options
  • Save everzet/981729 to your computer and use it in GitHub Desktop.
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)
<?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!
@MarcelloDuarte
Copy link

Please refer to the update of the syntax in phpspec version 2: https://gist.github.com/07831388218f192068ce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment