Browsed by
Category: PHPUnit

How Test Doubles Improve Your Code: PHPUnit and Laravel

How Test Doubles Improve Your Code: PHPUnit and Laravel

Ever avoided writing tests because setting up a real database felt like too much work? In PHPUnit, test doubles are a way of testing your code in isolation from its dependencies. Common types include stubs, mocks, and fakes. Imagine you’re testing a function which has a dependency injected into it, e.g. a Database class. You want to test your function but you do not want to instantiate and test the dependency, at least not in this test. Your test can…

Read More Read More