Created
March 27, 2018 20:48
-
-
Save harmenjanssen/d114ca40571e20069821817ef5f45663 to your computer and use it in GitHub Desktop.
Use `@dataProvider` to quickly pass a bunch of invalid input through your function to make sure it fails correctly.
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 | |
use PHPUnit\Framework\TestCase; | |
class MyTest extends TestCase { | |
/** | |
* @dataProvider invalidArgumentProvider | |
* @expectedException InvalidArgumentException | |
*/ | |
public function test_should_throw_on_invalid_arguments($arg) { | |
my_func($arg); | |
} | |
public function invalidArgumentProvider() { | |
return [ | |
[new stdClass], | |
[true], | |
[999] | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment