Download the PHP package habanero/spectre without Composer
On this page you can find all versions of the php package habanero/spectre. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package spectre
Spectre
Aims to write-and-run your specs in a easy way. Quickly.
- Mock support for classes and functions*
- Code-coverage reporting with PHPUnit
- Don't struggle with classes!
- Save as TAP or JSON
- Watch mode
How to?
composer.json
inc/sum.php
specs/sum-spec.php
Execute your specs:
Available matchers
- toBe($value) — Strict equal comparison (with
===
) - toBeA($value) — Data-type comparison (with
is_<type>()
) - toBeLike($value) — Alias for toEqual
- toEquals($value) — Alias for toEqual
- toBeGreaterThan($value) — Comparison using the
>
operator - toBeLessThan($value) — Comparison using the
<
operator - toBeAnInstanceOf($value) — Alias for toBeInstanceOf
- toBeInstanceOf($value) — Comparison using the
instanceof
operator - toBeEmpty() — Tests agains
empty()
- toBeTruthy() — Test for truthy-values
- toBeFalsy() — Test for falsy-values
- toBeArray() — Test using
is_array()
- toBeBoolean() — Alias for toBeBool
- toBeBool() — Test using
is_bool()
- toBeCallable() — Test using
is_callable()
- toBeDouble() — Test using
is_double()
- toBeFloat() — Test using
is_float()
- toBeInt() — Test using
is_int()
- toBeInteger() — Test using
is_integer()
- toBeLong() — Test using
is_long()
- toBeNull() — Test using
is_null()
- toBeNumeric() — Test using
is_numeric()
- toBeObject() — Test using
is_object()
- toBeReal() — Test using
is_real()
- toBeResource() — Test using
is_resource()
- toBeScalar() — Test using
is_scalar()
- toBeString() — Test using
is_string()
- toHaveKey($value) — Test arrays using
isset()
- toHaveLength([$value]) — Tests using
count()
andstrlen()
- toEndWith($value) — Test for trailing substrings
- toStartWith($value) — Test for leading substrings
- toContains($value) — Alias for toContain
- toContain($value) — Test for including substrings
- toEqual($value) — Weak equal comparison (with
==
) - toMatch($value) — Test strings with regular expressions
- toPrint($value) — Test for buffered-substrings (capture includes/echos with buffers)
- toThrow([$value]) — Test for exceptions, if
$value
is provided will test againstinstanceof
- toWarn([$value]) — Test for buffered-substrings at user-level errors, notices and warnings (no fatal ones)
Custom matchers
To register your own matchers you should implements the following code:
Note that any additional arguments will be passed after the $value
argument.
Mock support
Since 0.3.0
you can mock classes and some built-in functions using the same API, see spec/mock-spec.php for more examples.
In short, you can mock any class or function as follows:
Available constraints
- any()
- never()
- atLeast($count)
- atLeastOnce()
- once()
- exactly($count)
- atMost($count)
- at($index)
- returnValue($test)
- returnValueMap($test)
- returnArgument($index)
- returnCallback($fn)
- returnSelf()
- throwException($e)
- onConsecutiveCalls()
Some constraints are also spies, given a $callback
reference you can ask later for:
- hasBeenInvoked()
- getInvocations()
- getInvocationCount()
CLI options
Type vendor/bin/spectre
without arguments to get the following:
Examples
You can mix almost all arguments on several ways, i.e:
All versions of spectre with dependencies
habanero/clipper Version ^0.2.6
phpunit/php-code-coverage Version ~2.0.10
phpunit/phpunit-mock-objects Version ^2.3
phpunit/php-text-template Version ^1.2