Hi:
I just started using PHPUnit testing on my project and am stumped when using @dataProvider. Let’s say one of my models is:
class MyClass extends CActiveRecord
{
...
public function dummy($a, $b, $c)
{
return array($a, $b, $c);
}
}
Then the unit test could be:
class MyClassTest extends CDbTest
{
public static function provider()
{
return array(
array('A','B','C')
);
}
/*
* @dataProvider provider
*/
public function testDummy($a, $b, $c)
{
echo $a.' - '.$b.' - '.$c;
$this->assertTrue(true);
}
}
However, when I run [font="Courier New"]$phpunit unit/MyClassTest.php[/font] I get:
PHPUnit 3.5.13 by Sebastian Bergman
- - .
Time 0 seconds, memory 6.25 MB.
OK (1 test, 1 assertion)
Now I’ve tried more sophisticated tests with the same result. It seems that the @dataProvider annotation is ignored (I don’t know whether it’s Yii or PHPUnit) because on all tests where I’ve hardcoded the test data, it seems to work. Any ideas? Thanks in advance.