Last active
August 29, 2015 14:13
-
-
Save localheinz/2ad804a3c5451780486d to your computer and use it in GitHub Desktop.
How can you mark a test as skipped if the annotated data provider returns an empty array?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Foo; | |
class BarTest extends PHPUnit_Framework_TestCase | |
{ | |
protected function setUp() | |
{ | |
if (null === $this->providerBaz()) { | |
$this->markTestSkipped('No data'); | |
} | |
} | |
/** | |
* @dataProvider providerBaz | |
* | |
* @param string $baz | |
*/ | |
public function testBaz($baz) | |
{ | |
// ... | |
} | |
/** | |
* @return array | |
*/ | |
public function providerBaz() | |
{ | |
// retrieve some data, may not have any | |
if (0 === count($data)) { | |
return null; | |
} | |
// return a not-empty array | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe just prime the argument set array in the provider with an empty record?