PHPackages                             aleczhang/phpspock - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. aleczhang/phpspock

ActiveLibrary[Testing &amp; Quality](/categories/testing)

aleczhang/phpspock
==================

PhpSpock is a php implementation of Spock testing framework

0.1.4(11y ago)4413[1 PRs](https://github.com/aleczhang/PhpSpock/pulls)GNUPHPPHP &gt;=5.3.0

Since Jan 26Pushed 5y ago2 watchersCompare

[ Source](https://github.com/aleczhang/PhpSpock)[ Packagist](https://packagist.org/packages/aleczhang/phpspock)[ Docs](http://github.com/aleczhang/PhpSpock)[ RSS](/packages/aleczhang-phpspock/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

PhpSpock
========

[](#phpspock)

PhpSpock is a php implementation of Spock testing framework. Syntax of tests is replicated as much as php language syntax permits. PhpSpock is standalone library, but is designed to be used in partnership with other testings framework like PhpUnit.

Useful links:

- [Github page](https://github.com/ribozz/PhpSpock)
- [Spock framework](http://code.google.com/p/spock/)

Implemented features
--------------------

[](#implemented-features)

- Spock syntax
- Support for "use" class import in tests
- PhpUnit framework adapter
- Parametrization
- Several when-&gt;then block pairs
- Custom error message in assertion
- Support for run under debugger
- Spock style mocking (Iteractions)

Changelog
---------

[](#changelog)

### 0.1.1

[](#011)

- Several bugfixes

### 0.1.2

[](#012)

- Simplified cardinality syntax. Now you can ommit "(" and ")" and use +1, -1, +0 instead of constructions like (\_..4)

Known problems
--------------

[](#known-problems)

### Problem with @specDebug

[](#problem-with-specdebug)

**Description:**When you generate debug code with @specDebug, some errors are thrown into console. The same thing when you delete this annotation.

**Reason:**PhpUnitAdapter changes code of class where the marked test method resist (to insert debug code). And now when specification parser tries to get body of some other test in this file using reflection, it fails, beacuse reflection does not reflect file changes.

**Solution:**If you need to add/remove @specDebug annotation, just execute phpunit command twice gnoring all errors appeared. Debug code still will be valid and should run correctly on a second time.

Plans
-----

[](#plans)

Features to implement:

- Make assertionFailure output more descriptive
- Create proper docs with index on github pages

Licence
=======

[](#licence)

Full text of licenses are attached as COPYING and COPYING.LESSER files.

```
PhpSpock is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

PhpSpock is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with PhpSpock.  If not, see .

```

Copyright 2011 Aleksandr Rudakov

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

[](#installation)

For a moment the only way to install PhpSpock is to checkout sourcecode from git and to feet it to some PSR0 compatible autoloader.

You can checkout source code from github: git://github.com/ribozz/PhpSpock.git

Current stable release is: 0.1

So, something like:

git clone git://github.com/ribozz/PhpSpock.git git checkout 0.1

### Integration with frameworks

[](#integration-with-frameworks)

For now, only PhpUnit framework is supported out of the box.

#### PhpUnit integration

[](#phpunit-integration)

Integration with phpUnit is optional. The only thing it gives, is that you wouldn'r need anymore to override runTest() method in every your test case where you use specification.

Just override runTest method in your common TestCase or right in phpUnit test:

```
