How to Clear Session Data When Testing with Laravel Dusk

Each time you run a browser test in Laravel Dusk you will share session and cookie data with other tests in your file. If you’re trying to test a login form or something similar you may run into issues where one test is using session data from a different test.

Here’s how you can clear and delete the session data between tests to ensure that each test is sanitized.

Open up /tests/DuskTestCase.php and create or update the tearDown() method with the following.

This will clear cookie data for every test you create. If you’d rather only do it for a single file or test, you can either move the tearDown() method into the test file you want to update or create a different method and call it inside of individual Laravel Dusk tests.

 

Setting up a great looking macOS OS X terminal/shell

Switch from bash to ZSH. I personally like using Oh My Zsh, which is a framework for managing themes, plugins and other good stuff related to ZSH.

Switch from the default terminal prompt to Pure, which cleans up how the terminal looks as you use it. It removes some noise from the prompt and keeps things organized.

Add the snazzy theme to your terminal which adds some nice colors.

Use Droid Sans Mono as the default terminal font.

Add ZSH Syntax Highlighting to Oh My Zsh. It helps with hinting terminal commands along with some extra interactivity with the command prompt.

Turn on vim syntax highlighting.

Getting Google reCAPTCHA to Work Locally on Vagrant

Typically you can use “localhost” in the reCAPTCHA settings if you want to test your app locally, but if you’re using vagrant to manage your local servers this won’t work.

You won’t be able to use “localhost” or your custom hostname, such as “myapp.dev” that’s hard coded into your host file for local development with reCAPTCHA if you’re using vagrant.

You’re going to need to use the IP address you assigned to the vagrant box when you created it. You can either view the config file related to the vagrant box or you can echo out $_SERVER[‘REMOTE_ADDR’] from your PHP app. That will give you the IP address that you can enter into the reCAPTCHA settings page next to your production URL.

PayPal Direct Recurring Payments Script

This is an open source script for accepting direct recurring credit card payments on your website. Users select a length of subscription for your products and will be billed monthly for that amount. Credit cards are entered on your website, but billed through PayPal. Continue reading “PayPal Direct Recurring Payments Script”