22. PHPUnit
class StackTest extends PHPUnit_Framework_TestCase
{
public function testPushAndPop()
{
$stack = array();
$this->assertEquals(0, count($stack));
array_push($stack, 'foo');
$this->assertEquals('foo', $stack[count($stack)-1]);
$this->assertEquals(1, count($stack));
$this->assertEquals('foo', array_pop($stack));
$this->assertEquals(0, count($stack));
}
23. Behat
Feature: ls
In order to see the directory structure
As a UNIX user
I need to be able to list the current directory's contents
Scenario:
Given I am in a directory "test"
And I have a file named "foo"
And I have a file named "bar"
When I run "ls"
Then I should get:
"""
bar
foo
"""
24. PHPSpec
class DescribeNewBowlingGame extends PHPSpecContext
{
private $_bowling = null;
public function before()
{
$this->_bowling = $this->spec(new Bowling);
}
public function itShouldScore0ForGutterGame()
{
for ($i=1; $i<=20; $i++) {
// someone is really bad at bowling!
$this->_bowling->hit(0);
}
$this->_bowling->score->should->equal(0);
}