Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Laravel 5.x Cookbook

You're reading from  Laravel 5.x Cookbook

Product type Book
Published in Sep 2016
Publisher Packt
ISBN-13 9781786462084
Pages 402 pages
Edition 1st Edition
Languages
Authors (2):
Terry Matula Terry Matula
Profile icon Terry Matula
Alfred Nutile Alfred Nutile
Profile icon Alfred Nutile
View More author details

Table of Contents (17) Chapters

Laravel 5.x Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
1. Setting Up and Installing Laravel 2. Using Composer Packages 3. Routing 4. Building Views and Adding Style 5. Working with Data 6. Adding Angular to Your App 7. Authentication, Security, and Subscriptions 8. Testing and Debugging Your Application 9. Adding Advanced Features to Your App 10. Deploying Your App Index

Testing your route in PHPUnit


As seen in the preceding recipe, I used the browser to show that the API is working. Here, I want to show how you can speed up your workflow by using PHPUnit to do this and then, more importantly, you end up with long term testing.

Getting ready

The previous recipes will help show how to lay the foundation. In this one, I will continue from there.

How to do it…

Follow these steps to test your route:

  1. Make a test:

    > php artisan make:test SearchComicsApiTest
    
  2. Then, edit the file tests/SearchComicsApiTest.php:

  3. And run phpunit:

    > phpunit --filter=api_results_from_search_verify_format
    
  4. Now let's make it do something by hitting that API:

  5. And let's verify some data, first, I will dump the data to my terminal to get a sense of what I can look for:

    We will get the following output:

  6. Then, I decide to assert a few things:

  7. That's it, I now know my route is working, without going in the browser, and can now start working with the AngularJS code to display this.

How it works…

Pretty...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}