I'm using PHPUnit 3.4.9, but I'm having some problems with the @depends
annotation. It works like in the examples, but breaks when the producer reliers on a provider. I don't know if this is meant to work or not, but my code is basically in the form:
<?php
class StackTest extends PHPUnit_Framework_TestCase {
/**
* @dataProvider provider
*/
public function testEmpty($data) {
$stack = array();
$this->assertTrue(empty($stack));
return $stack;
}
/**
* @depends testEmpty
*/
public function testPush(array $stack) {
array_push($stack, 'foo');
$this->assertEquals('foo', $stack[count($stack)-1]);
$this->assertFalse(empty($stack));
return $stack;
}
/**
* @depends testPush
*/
public function testPop(array $stack) {
$this->assertEquals('foo', array_pop($stack));
$this->assertTrue(empty($stack));
}
public function provider () {
return array(
// Some testing data here...
);
}
}
The code above is just an example, but shows what my code's structure is like. When ran, it skips the consumer tests, acting as though the producer had failed. I'm expecting that for every set of testing data in the provider, the producer will be run with that data, and all of its consumer correspondingly run.