PHPackages                             polishsymfonycommunity/mockery-bundle - 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. polishsymfonycommunity/mockery-bundle

AbandonedSymfony-bundle[Testing &amp; Quality](/categories/testing)

polishsymfonycommunity/mockery-bundle
=====================================

This Bundle provides Mockery integration to make it possible to mock service in Behat.

v1.0.0(14y ago)152963MITPHPPHP &gt;=5.3.2

Since Mar 2Pushed 13y agoCompare

[ Source](https://github.com/PolishSymfonyCommunity/PSSMockeryBundle)[ Packagist](https://packagist.org/packages/polishsymfonycommunity/mockery-bundle)[ Docs](http://symfonylab.pl)[ RSS](/packages/polishsymfonycommunity-mockery-bundle/feed)WikiDiscussions master Synced today

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

PSSMockeryBundle
================

[](#pssmockerybundle)

**Note**: Since Behat 2.4 got its own extension system this bundle is replaced by [Symfony2MockerExtension](https://github.com/PolishSymfonyCommunity/Symfony2MockerExtension).

[![Build Status](https://camo.githubusercontent.com/274d31ca3077d96ee11e4593ca81cbb776844b862b845f7fc136606c9e589ff9/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f506f6c69736853796d666f6e79436f6d6d756e6974792f5053534d6f636b65727942756e646c652e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/PolishSymfonyCommunity/PSSMockeryBundle)

Symfony2 Mockery integration bundle. Currently it supports service mocking.

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

[](#installation)

Add PSSMockeryBundle to your composer.json:

```
{
    "require": {
        "polishsymfonycommunity/mockery-bundle": "*"
    }
}

```

Usage
-----

[](#usage)

Replace base container class for test environment in `app/AppKernel.php`::

```
/**
 * @return string
 */
protected function getContainerBaseClass()
{
    if ('test' == $this->environment) {
        return '\PSS\Bundle\MockeryBundle\DependencyInjection\MockerContainer';
    }

    return parent::getContainerBaseClass();
}

```

Clear your cache

To use it with Behat enable sub-context in your `FeatureContext` class::

```
/**
 * @param \Symfony\Component\HttpKernel\HttpKernelInterface $kernel
 *
 * @return null
 */
public function __construct(HttpKernelInterface $kernel)
{
    parent::__construct($kernel);

    $this->useContext('container', new \PSS\Bundle\MockeryBundle\Behat\Context\MockerContainerContext($kernel));
}

```

Example story::

```
Feature: Submitting contact request form
  As a Visitor
  I want to contact sales
  In order to receive more information

  Scenario: Submitting the form
    When I go to "/contact-us"
     And I complete the contact us form with following information
       |First name|Last name|Email                |
       |Jakub     |Zalas    |jzalas+spam@gmail.com|
     And CRM API is available
     And I submit the contact us form
    Then the contact request should be sent to the CRM

```

Step definitions::

```
/**
 * @Given /^CRM API is available$/
 *
 * @return null
 */
public function crmApiIsAvailable()
{
    $this->getMainContext()->getSubContext('container')
        ->mockService('crm.client', 'PSS\Crm\Client')
        ->shouldReceive('send')
        ->once()
        ->andReturn(true);
}

/**
 * @Given /^(the )?contact request should be sent to (the )?CRM$/
 *
 * @return null
 */
public function theContactRequestShouldBeSentToCrm()
{
    return new Then(sprintf('the "%s" service should meet my expectations', 'crm.client'));
}

```

All the expectations are checked automatically with an `@afterScenario` hook. Doing it manually only improves the readability of the scenario and gives better error message.

To discuss
----------

[](#to-discuss)

- Does it have to be a bundle? Currently it's rather a Symfony independent library.
- Is this the right approach/implementation?
- Do we need more features?

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

5183d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/012270929478a287f88353135a39d275db09c1856d344d0245e04df709879262?d=identicon)[jakzal](/maintainers/jakzal)

---

Top Contributors

[![jakzal](https://avatars.githubusercontent.com/u/190447?v=4)](https://github.com/jakzal "jakzal (22 commits)")[![khepin](https://avatars.githubusercontent.com/u/455656?v=4)](https://github.com/khepin "khepin (1 commits)")[![richardmiller-zz](https://avatars.githubusercontent.com/u/783827?v=4)](https://github.com/richardmiller-zz "richardmiller-zz (1 commits)")

---

Tags

testBDDTDDmockerymockBehat

### Embed Badge

![Health badge](/badges/polishsymfonycommunity-mockery-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/polishsymfonycommunity-mockery-bundle/health.svg)](https://phpackages.com/packages/polishsymfonycommunity-mockery-bundle)
```

###  Alternatives

[mockery/mockery

Mockery is a simple yet flexible PHP mock object framework

10.7k497.0M23.6k](/packages/mockery-mockery)[polishsymfonycommunity/symfony-mocker-container

Provides base Symfony dependency injection container enabling service mocking.

1468.0M237](/packages/polishsymfonycommunity-symfony-mocker-container)[polishsymfonycommunity/symfony2-mocker-extension

Behat extension for mocking services defined in the Symfony2 dependency injection container.

26253.1k4](/packages/polishsymfonycommunity-symfony2-mocker-extension)[php-mock/php-mock

PHP-Mock can mock built-in PHP functions (e.g. time()). PHP-Mock relies on PHP's namespace fallback policy. No further extension is needed.

36918.1M98](/packages/php-mock-php-mock)[php-mock/php-mock-mockery

Mock built-in PHP functions (e.g. time()) with Mockery. This package relies on PHP's namespace fallback policy. No further extension is needed.

392.1M96](/packages/php-mock-php-mock-mockery)[php-mock/php-mock-phpunit

Mock built-in PHP functions (e.g. time()) with PHPUnit. This package relies on PHP's namespace fallback policy. No further extension is needed.

1718.2M399](/packages/php-mock-php-mock-phpunit)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
