O'Reilly logo

Mastering Laravel by Christopher John Pecoraro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Specifying with phpspec

At the core of phpspec is the ability to allow us to specify the behavior of entities and simultaneously test them. By simply specifying what the business rules are as given by the customer, we can easily create tests for each business rule. However, the real power of phpspec lies in how it uses an expressive, natural language syntax. Let's take a look at the business rules that were previously given to us regarding reservations:

  • The start date of the reservation must come before the end date
  • A reservation cannot be made for more than fifteen days
  • A reservation cannot include more than four rooms

Run the following command:

# phpspec describe
 MyCompany/Accommodation/ReservationValidator

phpspec will produce the following output ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required