Book Image

Mastering Laravel

By : Christopher Pecoraro
Book Image

Mastering Laravel

By: Christopher Pecoraro

Overview of this book

<p>PHP continues to revive and Laravel is at its forefront. Laravel follows modern PHP's object-oriented best practices and reduces time-to-market, enabling you to build robust web and API-driven mobile applications that can be automatically tested and deployed.</p> <p>With this book you will learn how to rapidly develop software applications using the Laravel 5 PHP framework.</p> <p>This book walks you through the creation of an application, starting with behavior-driven design of entities. You'll explore various aspects of modern software including the RESTful API, and will be introduced to command bus. Laravel's annotations package is also explained and demonstrated. Finally, the book closes with a demonstration of different ways to deploy and scale your applications.</p>
Table of Contents (17 chapters)
Mastering Laravel
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
3
Building Services, Commands, and Events
Index

Running tests with Elixir


In addition to compiling and sending notifications, Elixir may also be used to automate the launching of tests. The following sections will discuss how Elixir can be used for both PHPSpec and PHPUnit.

PHPSpec

The first step would be to run the PHPSpec tests to automate code testing. By adding phpSpec() to our gulpfile.js as follows, PHPSpec tests will run:

elixir(function(mix) {
    mix.less('app.less').phpSpec();
});

The output is shown in the following screenshot. The PHPSpec output is maintained, so the test output is very useful:

When the PHPSpec tests fail, the results are easily readable:

A screenshot of Laravel Elixir's output

In this example, phpspec encountered an error in the it creates a reservation test line as shown in the preceding screenshot.

PHPUnit

Similarly, we may add PHPUnit to our suite of tests by adding phpUnit to the list of tasks as follows:

elixir(function(mix) {
    mix.less('app.less').phpSpec().phpUnit();
});

Creating custom tasks

Elixir gives us...