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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners