PHPSpec Reference Manual

A Behaviour-Driven Development Framework for PHP

This work is licensed under the Creative Commons Attribution 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

2008-01-09


Table of Contents

Preface
1. Before We Get Started
1.1. Audience
1.2. Requirements
1.3. This Book Is Free
1.4. Acknowledgements
1. Installing PHPSpec
1.1. Installation
1.1.1. Installing PHPSpec with PEAR
1.1.2. Installing PHPSpec from a PEAR download
1.1.3. Installing PHPSpec Manually
2. Getting Started
2.1. Getting Started
2.1.1. What is PHPSpec?
2.1.2. You Start By Writing A Specification
2.1.3. Take Very Small Steps
3. Introduction
3.1. Testing Your Code
3.2. Source Code Examples As Documentation
3.3. Writing Examples (Specs) Before Writing Code
3.3.1. Why Write Examples First?
3.3.2. The Workflow of BDD using PHPSpec
3.4. PHPSpec And BDD In Context
4. PHPSpec's Goals
4.1. Goals!
5. Writing Specs with PHPSpec
5.1. Specs, Examples and Contexts
5.2. Before Writing Code, Specify Its Required Behaviour
5.2.1. Explaining the PHPSpec Spec Layout
5.2.2. The Code To Implement The New Filesystem Logger Specification
5.3. The Spec Domain Specific Language (DSL)
5.3.1. The Actual Value Term
5.3.2. The Expectation Term (Should or Should Not)
5.3.3. The Matcher Term
6. Execution Methods for PHPSpec
6.1. The Console Runner
6.2. The HTTP Runner
A. Copyright Information
Index

List of Tables

5.1. PHPSpec Matchers
6.1. PHPSpec Console Options

List of Examples

3.1. Example with PHPUnit
3.2. Example with PHPSpec
5.1. A Spec in a PHPSpec Example Method
5.2. Some Plain Text Specs for a Filesystem Logger
5.3. Specification for a New Filesystem Logger Context
5.4. Implementation of the Filesystem Logger
5.5. Example Spec DSL: Bowling should not be an instance of Logger
5.6. Actual Term: Scalar Examples
5.7. Actual Term: Object Examples
5.8. Actual Term: Object Name With Constructor Params
5.9. Expectation Term: Various Passing Examples
5.10. Example of Classes and Predicate Matcher Calls