symfony/phpunit-bridge instructions:
* Write test cases in the tests/ folder
* Use MakerBundle's make:test command as a shortcut!
* Run the tests with php bin/phpunit
Notes
If using the recommended command bin/phpunit, v9 will be used;
If setting a newer phpunit version in phpunit.xml.dist, "SYMFONY_PHPUNIT_VERSION", that version will be installed/used, however the command will fail with the error:
PHP Fatal error: Uncaught Error: Class "PHPUnit\TextUI\Command" not found in /home/radu/p/fastricambi/clippartsws-demo/vendor/symfony/phpunit-bridge/Legacy/CommandForV9.php:25
Issue, opened since 2023: https://github.com/symfony/symfony/issues/49069
class Test
{
#[DataProvider('someProvider')]
public function test($foo, $bar): void
{
...
}
public static function someProvider(): \Generator
{
yield 'Name of current parameters' => ['fooValue1', 'barValue1'];
yield 'Name of current parameters' => ['fooValue2', 'barValue2'];
}
}
Mocking
mock: assert how the object is being used (expects, method, with, willReturn, etc);