Download the PHP package ciarand/pho without Composer
On this page you can find all versions of the php package ciarand/pho. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package pho
Short Description A BDD testing framework
License MIT
Homepage https://github.com/danielstjules/pho
Informations about the package pho
This project is deprecated and unmaintained. Proceed with caution!
BDD test framework for PHP, inspired by Jasmine and RSpec. Work in progress. Feature requests and pull requests welcome!
- Installation
- Writing Specs
- Running Specs
- Expectations/Matchers
- Reporters
- Mocking
- Namespace
- Options
Installation
The following instructions outline installation using Composer. If you don't have Composer, you can download it from http://getcomposer.org/
- Run either of the following commands, depending on your environment:
- Edit your
~/.bash_profile
or~/.profile
and add:
Writing Specs
Pho exposes 8 functions for organizing and writing your tests: describe
,
context
, it
, before
, after
, beforeEach
, afterEach
and expect
.
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.
Objects may be passed between suites and specs with php's use
keyword. Here's
an example:
Things can get a bit verbose when dealing with multiple objects that need to be
passed into closures with use
. To avoid such long lists of arguments, $this
can be used to set and retrieve values between suites and specs.
Hooks are available for running functions as setups and teardowns. before
is
ran prior to any specs in a suite, and after
, once all in the suite have been
ran. beforeEach
and afterEach
both run their closures once per spec. Note
that beforeEach
and afterEach
are both stacklable, and will apply to specs
within nested suites.
Running Specs
By default, pho looks for specs in either a test
or spec
folder under the
working directory. It will recurse through all subfolders and run any files
ending with Spec.php
, ie: userSpec.php. Furthermore, continuous testing is as
easy as using the --watch
option, which will monitor all files in the path for
changes, and rerun specs on save.
Expectations/Matchers
Type Matching
Instance Matching
Strict Equality Matching
Loose Equality Matching
Length Matching
Inclusion Matching
Pattern Matching
Numeric Matching
Print Matching
Exception Matching
Reporters
dot (default)
spec
list
Mocking
Pho doesn't currently provide mocks/stubs out of the box. Instead, it's suggested that a mocking framework such as prophecy or mockery be used.
Namespace
If you'd rather not have pho use the global namespace for its functions, you
can set the --namespace
flag to force it to only use the pho namespace. This
will be a nicer alternative in PHP 5.6 with
https://wiki.php.net/rfc/use_function