https://sebastiandedeyne.com/beware-of-phpunit-data-providers-with-heavy-setup-methods/ https://sebastiandedeyne.com/tags/php/ https://sebastiandedeyne.com/tags/phpunit/ https://sebastiandedeyne.com/tags/testing/Data providers can be a perfect fit to assert a lot of expectations without writing a full test for each. For an in-depth introduction to data providers, I recommend https://tighten.co/blog/tidying-up-your-phpunit-tests-with-data-providers/ on the Tighten blog. { /** @dataProvider values */ public function it_adds_values(int $a, int $b, int $result): void

If you don’t, data providers make your tests slower than they need to be.

class MyTest extends TestCase public function setUp(): void parent::setUp(); // Do some heavy lifting…
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners