O'Reilly logo

Mastering PHP 7 by Branko Ajzele

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

Writing test

Getting started with writing phpspec tests requires grasping a few basic concepts, such as the following:

  • The it_*() and its_*() methods: This object behavior is made up of individual examples, each one being flagged with the it_*() or its_*() methods. We can have one or more of these methods defined per single specification. Each defined method gets triggered when a test is run.
  • Matchers methods: These are analogous to assertions in PHPUnit. They describe how an object should behave.
  • Object construction methods: Every object we describe in phpspec is not a separate variable, but is $this. Sometimes, however, getting the proper $this variable requires managing constructor parameters. This is where the beConstructedWith()

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