PHPackages                             danielstjules/pho - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. danielstjules/pho

ActiveLibrary[Framework](/categories/framework)

danielstjules/pho
=================

A BDD testing framework

1.2.1(9y ago)28220.1k147MITPHPPHP &gt;=5.4.0

Since Nov 28Pushed 9y ago16 watchersCompare

[ Source](https://github.com/danielstjules/pho)[ Packagist](https://packagist.org/packages/danielstjules/pho)[ Docs](https://github.com/danielstjules/pho)[ RSS](/packages/danielstjules-pho/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (7)DependenciesVersions (9)Used By (7)

[![pho](https://camo.githubusercontent.com/660a8edbfd23cbe51b053ae5b3e3ba48c0f5434eb0a05c4b453e03cc5db813b0/687474703a2f2f64616e69656c73746a756c65732e636f6d2f6769746875622f70686f2d6c6f676f2e706e67)](https://camo.githubusercontent.com/660a8edbfd23cbe51b053ae5b3e3ba48c0f5434eb0a05c4b453e03cc5db813b0/687474703a2f2f64616e69656c73746a756c65732e636f6d2f6769746875622f70686f2d6c6f676f2e706e67)

BDD test framework for PHP, inspired by Jasmine and RSpec. Features a familiar syntax, and a watch command to automatically re-run specs during development. It can also be extended with custom matchers and reporters.

[![Build Status](https://camo.githubusercontent.com/cd5a859a5f164b566cf51f573b1d42303da20cef1368b973a8bffd7175fa2e0f/68747470733a2f2f7472617669732d63692e6f72672f64616e69656c73746a756c65732f70686f2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/danielstjules/pho)

- [Installation](#installation)
- [Usage](#usage)
- [Writing Specs](#writing-specs)
- [Running Specs](#running-specs)
- [Expectations/Matchers](#expectationsmatchers)
- [Custom Matchers](#custom-matchers)
- [Reporters](#reporters)
- [Mocking](#mocking)
- [Namespace](#namespace)

Installation
------------

[](#installation)

The following instructions outline installation using Composer. If you don't have Composer, you can download it from If you're new to composer, make sure to add the vendor bin to your PATH:

```
# Append the following to your profile file, for example in ~/.profile
export PATH=$HOME/.composer/vendor/bin:$PATH
```

To install pho, run:

```
composer global require danielstjules/pho
```

Usage
-----

[](#usage)

```
Usage: pho [options] [files]

Options

   -a   --ascii                     Show ASCII art on completion
   -b   --bootstrap      Bootstrap file to load
   -f   --filter           Run specs containing a pattern
   -h   --help                      Output usage information
   -n   --namespace                 Only use namespaced functions
   -r   --reporter            Specify the reporter to use
   -s   --stop                      Stop on failure
   -v   --version                   Display version number
   -w   --watch                     Watch files for changes and rerun specs
   -C   --no-color                  Disable terminal colors
```

Writing Specs
-------------

[](#writing-specs)

Pho exposes a DSL for organizing and writing your tests, which includes the following functions: `describe`, `context`, `it`, `before`, `after`, `beforeEach`, `afterEach` and `expect`. Equivalent functions for disabling specs and suites also exist via `xdescribe`, `xcontext` and `xit`.

To create a suite, `describe` and `context` can be used by passing them a string and function. Both are interchangeable, though context is more often nested in a describe to group some set of behaviour. `it` is then used to create a spec, or test.

A spec may contain multiple expectations or assertions, and will pass so long as all assertions pass and no exception is uncaught. For asserting values in pho, `expect` can be used. The function accepts the value to be tested, and may be chained with a handful of matchers.

```
