PHPackages                             pamil/prophecy-common - 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. pamil/prophecy-common

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

pamil/prophecy-common
=====================

Common helper classes for Prophecy

v0.1.0(10y ago)13176.0k↑5950%2MITPHP

Since May 6Pushed 10y ago1 watchersCompare

[ Source](https://github.com/pamil/prophecy-common)[ Packagist](https://packagist.org/packages/pamil/prophecy-common)[ RSS](/packages/pamil-prophecy-common/feed)WikiDiscussions master Synced yesterday

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

Prophecy Common [![Build Status](https://camo.githubusercontent.com/59f90fbfd15b834041f89484bf90caabf725e37b70e11a57b74143e1cbef76bb/68747470733a2f2f7472617669732d63692e6f72672f70616d696c2f70726f70686563792d636f6d6d6f6e2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/pamil/prophecy-common)
==============================================================================================================================================================================================================================================================================================================

[](#prophecy-common-)

Bunch of useful classes to solve some issues I've encountered while using PhpSpec. MIT licensed.

CompositePromise
----------------

[](#compositepromise)

Allows the same method to throw different exceptions, return and throw exceptions at the same time and limit calls without using `shouldBeCalledTimes()`.

```
$collabolator->mockedMethod()->will(
    CompositePromise::it()->willThrow(\LogicException::class)->andThenReturn('value')
);
```

#### Differences

[](#differences)

- `CompositePromise::willReturn()` and `CompositePromise::andThenReturn()` behave the same as `MethodProphecy::willReturn()`(in PhpSpec: `$collabolator->callMethod()->willReturn()`)
- `CompositePromise::willThrow()` and `CompositePromiser::andThenThrow()` behave the same as `MethodProphecy::willThrow()`(in PhpSpec: `$collabolator->callMethod()->willThrow()`), but they can receive more than one argument, e.g. `CompositePromise::willThrow(\FirstException::class)->andThenThrow(\SecondException::class)` is equal to `CompositePromise::willThrow(\FirstException::class, \SecondException::class)`
- `CompositePromise::will()` and `CompositePromise::andThen()` behave the same as `MethodProphecy::will()`, but they can receive more than one argument just as the previous methods

#### Example

[](#example)

```
