PHPUnit @dataProvider simply doesn't work
Finally after hours of prodding this test file, I discovered that merely defining the constructor function breaks the functionality of data providers. Good to know.
To fix it, just call the parent constructor. Here's how that looked in my case:
public function __construct()
{
// Truncate the OmniDataManager tables
R::wipe(OmniDataManager::TABLE_GROUP);
R::wipe(OmniDataManager::TABLE_DATA);
parent::__construct(); // <- Necessary
}
As David Harkness and Vasily pointed out in the comments, the constructor override must match the call signature of the base class constructor. In my case the base class constructor didn't require any arguments. I'm not sure if this has just changed in newer versions of phpunit or if it depends on your use case.
In any case, Vasily's example might work better for you:
public function __construct($name = null, array $data = array(), $dataName = '')
{
// Your setup code here
parent::__construct($name, $data, $dataName)
}
If you really need it, David Harkness had the right tip. Here's the code:
public function __construct($name = NULL, array $data = array(), $dataName = '') {
$this->preSetUp();
parent::__construct($name, $data, $dataName);
}
To emphasise the point that micro_user made, the @dataProvider
annotation must be in a docblock comment. i.e. do this:
/**
* @dataProvider myDataProvider
*
*/
public function testMyMethod(...)
{
...
}
Don't do this since it won't work:
/*
* @dataProvider myDataProvider
*
*/
public function testMyMethod(...)
{
...
}