Derek MacDonald

Posts Tagged “testing”

Running Laravel Dusk tests in Firefox

Posted Jun 3, 2020 at 12:31pm GMT-0500

PHP package Laravel Dusk (initially released in April 2018) allows Laravel Framework applications to run browser tests with minimal configuration. The target browser can be configured but out-of-the-box it is setup to run tests in Google Chrome via Chromedriver. Well what about other web browsers?

Attempting to escape the far-reaching tentacles of surveillance capital, last year I uninstalled Chrome and replaced it with Mozilla Firefox and DuckDuckGo. But I still wished to locally run browsers tests on Laravel apps. Thankfully W3C’s WebDriver recommendation in June 2018 provided a clear path for other browsers to add automated testing. Geckodriver for Gecko-based browsers (including Firefox) has been stable since late 2019 so a Laravel Dusk integration is actually very easy now.

Read the rest of this entry »

Can’t mock Laravel CacheManager store()

Posted May 18, 2017 at 03:35am GMT-0500

Testing stateful API endpoints in Laravel, you may come across this exception message:

BadMethodCallException: Method Mockery_1_Illuminate_Cache_CacheManager::store() does not exist on this mock object

In the official documentation, the facade service mock example covers Cache::shouldReceive() but there are potential limitations. Generally APIs are stateless, so developers are less likely to hit this roadblock. Here’s a solution to it anyhow!

Read the rest of this entry »

Derek MacDonald

Derek

Toronto, ON

Web application developer.



© Copyright Derek MacDonald. All rights reserved.