Categories
Laravel Samuel Test Driven Laravel Series

Setting up phpstorm to run unit tests

In This post we will go through the process of setting up phpstorm to run our tests.

Step 1:

Our first step is to get to the phpunit settings portion of phpstorm, to do this we can type control + shift + a or we can type “shift shift” and then type phpunit. The easier method is to hit control + shift + a, type phpunit and select the first option with the “settings” next to it.

Step 2:

Once the settings screen pulls up we should already be at the phpunit section. If not just type phpunit in the search bar at the top left. On this screen you will need to input 2 variables to get your tests working:

C:\wamp64\www\project-name\vendor\autoload.php

C:\wamp64\www\project-name\phpunit.xml

The final result should look like the snapshot below:

phpstorm-tests

Step 3:

Now we are ready to run our tests. To do this you can hit shift + f10 or you can go to the top nav bar and select “run > run all”.

Other helpful notes:

-control f5 will run the most recent test again
-alt + shift + f10 will run all the tests. This is helpful if you have only been running one specific test and would like to go back to running all tests

Categories
Laravel Samuel Test Driven Laravel Series

Third Hard Stop

Now when Adam runs this test he is getting updated errors that are created by adding the “formatted_date” variable to the blade file and then building out his second test. To fix this issue it actually ends up being really simple. All that we had wrong was the following code:

/**@test */

function can_get_formatted_date ()

This needed to be updated to add a space in between the ** and the @ symbol, so it looks like:

/** @test */

function can_get_formatted_date ()

If the ** is connected to the @ symbol then the test will not work. Once updated we can run the test and start following along with Adams errors.

Categories
Samuel Test Driven Laravel Series

Second Test Driven Laravel Hard Stop

The steps to fix this second Hard stop

1.) Open up ConcertsController.php and find the line: $concert = Concert::find($id);

2.) Hover over the class name, which is Concert::. Once your mouse is hovering over this hold down Alt and right click. In php storm this will bring up a new window that says “import this class”. Click to import the class. Alternatively if you are not using PHPstorm you can import the class by copying the code below:

use App\Concert; This goes at the top of the ConcertsController.php document.

Categories
Fixing Stuff Samuel

Fixing Internet Connection when connected to VPN

We were having an issue with our VPN setup and just wanted to document the fix. When working remotely we preferred to VPN back to the office from time to time but we were running into an issue where when connected to the office VPN we could not browse the internet. Everything else worked fine, our file share on the office network, we could send/receive email, print at the office ect… the only thing that was not working was actual internet browsing. To fix the issue we found a great piece of helpful information on Stack Overflow. The info is copied below for easy access and there is also a link to the stack overflow thread:

Link to thread: Here

Working steps to take:

uncheck “Use default gateway on remote network” in the TCP/IPv4 advanced settings for the VPN connection.

nbiwl

Categories
Laravel Samuel Test Driven Laravel Series

List Of Hard Stops In Test Driven Laravel Series

We have recently started a new continuing education series called Test Driven Laravel. Only a few episodes in and this has already proved to be an excellent and well made series of tutorials. If you would like to check this series out head over to https://adamwathan.me/test-driven-laravel/

First Hard Stop:

Setting up blank laravel install using the Laravel Composer Tool. Written about here

Second Hard Stop:

on the “getting green” episode once we have created a provider, a controller and a view we get to the point where we need to add $concert = Concert::find($id);

For my local install this causes an issue when we run the test ./vendor/bin/phpunit.

I get the error Fatal error: Class 'App\Http\Controllers\Concert' not found

Fix for this Written about here

Third Hard Stop
On the unit testing presentation logic episode anytime the test snippet is run we keep getting the same error even after we have created a new file in test/unit/ConcertTest.php and followed along with all of Adams steps we keep getting the same error when running the test command:

./vendor/bin/phpunit

We get the error:

Failed asserting that the page contains the HTML [December 6, 2016]. Please check the content above.

Fix for this written about here

Fourth Hard Stop

When we get past the previous ** error we run into an issue on the very last test of this episode. When Adam runs the last test he gets all greens and the lesson is over, when we run the test we get:

ConcertTest::can_get_formatted_date
Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 no such table: concerts

This was an issue in the very beginning of the lesson where we forgot to add in use DatabaseMigrations;. You will want to add this code to the ConcertTest.php inside of the ConcertTest class.

Fifth Hard Stop

Setting up phpstorm to run unit tests instead of running them in the command line, this allows us to run individual tests instead of all the tests at once

Categories
Laravel Samuel

Setting Up the Laravel Installer On Windows with Wamp Server

If you are struggling to get the laravel installer working on wamp server you have come to the right place. We just got done struggleing with this setup and took detailed notes:

Step 1: Install Laravel installation tool via composer.

Open Git Bash then run: composer global require "laravel/installer"

**If you do not have composer installed on your computer yet you can circle back to our initial laravel 4 wamp setup guide

Step 2: Try to run Laravel Installer (it will most likely error out during this first try)

-navigate to your wamp > www directory then open up gitbash. Type the following code:
laravel new folder-name
*replace folder-name with your actual desired folder name

**At this point we will most likely get the error message: Bash: Laravel: command not found**

Step 3: Fix our Error message

To fix this error message we will need to set our environment variables and allow the laravel installer commands to be executed. To do this follow these steps:

On windows 7:

1.) hit start > then type environment variables into the search bar and click on the link that pops up. This will take you too this screen:
mtgad

2.) find the “Path” variable from the list, click on it to highlight it and then click edit. This will take you to this screen:
9z8nb

3.) navigate to the end of the line and add a ; then type into the following: C:\Users\computer-name\AppData\Roaming\Composer\vendor\bin (*replace computer name with your computer name).

Time to Install Laravel!

No circle back and run the code from step 2:
laravel new.

Make sure to run this inside the folder where you would like your new laravel project made. If all goes correctly you will see the laravel installer execute.

**if you get an error, try simply typing “Laravel” into your command prompt. If that errors out, close your gitbash window and re-open it.