PHPackages                             xaerodegreaz/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. xaerodegreaz/phpspock

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

xaerodegreaz/phpspock
=====================

PhpSpock is a php implementation of Spock testing framework

0.2.0(5y ago)09GNUPHPPHP ^7.4

Since Jan 26Pushed 5y agoCompare

[ Source](https://github.com/XaeroDegreaz/PhpSpock)[ Packagist](https://packagist.org/packages/xaerodegreaz/phpspock)[ Docs](http://github.com/XaeroDegreaz/PhpSpock)[ RSS](/packages/xaerodegreaz-phpspock/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (4)Used By (0)

### Notes:

[](#notes)

As of 2020, the original repository at  seems unmaintained. I've made some minor updates so that the newest version of PHPUnit namespaces work correctly for the adapter, and made it so that even arrays can be stubbed out without violating PHP's syntax rules.

By default, any mock interaction without an explicit quantity will be implicitly evaluated as `(1.._)` (at least once). Before this change no stubbing happened for expressions like `$a->getFoo() >> 123`.

I've also made some minor updates to some tests to make sure that the new default stubbing for expressions works correctly.

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:

```
