Testing your view based route in PHPUnit

Using the above recipe, I was able to make a view right from the route, now I want to test my view and make sure it is doing what is expected. Typically, I would use Behat but in this example, I will use PHPUnit.

Getting ready

If you follow the above recipe, you will have an example page in place. From here we will start with the testing.

How to do it…

Follow the listed steps for testing your view based route:

  1. As usual, make a test:
    >php artisan make:test ExampleViewTest
    
  2. Then, in that file tests/ExampleViewTest.php, I begin to write a test:
    How to do it…
  3. Run the test and it passes:
    > phpunit --filter=example_view
    
  4. Now, to see ...

Get Laravel 5.x Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.