PHPackages                             hermeslin/mockery-overload-properties - 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. hermeslin/mockery-overload-properties

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

hermeslin/mockery-overload-properties
=====================================

mock instance's properties via Mockery's overload keyword

v1.0.1(8y ago)03.3kBSD-3-ClausePHPPHP &gt;=5.6.0

Since Feb 25Pushed 7y ago1 watchersCompare

[ Source](https://github.com/hermeslin/mockery-overload-properties)[ Packagist](https://packagist.org/packages/hermeslin/mockery-overload-properties)[ Docs](https://github.com/hermeslin/mockery-overload-properties)[ RSS](/packages/hermeslin-mockery-overload-properties/feed)WikiDiscussions master Synced 1mo ago

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

mockery overload properties
===========================

[](#mockery-overload-properties)

mock instance's properties via Mockery's overload keyword

installation
------------

[](#installation)

use composer to install `mockery-overload-properties`

```
$ composer require --dev hermeslin/mockery-overload-properties

```

test legacy sample code
-----------------------

[](#test-legacy-sample-code)

under the `example` folder, you can see the sample code taht we want to test:

1. User.php
2. Vip.php

and you'll find the hard dependencies in `Vip.php`.

hard dependencies are not a big deal, you can use [Mockery's `overload` keyword](http://docs.mockery.io/en/latest/cookbook/mocking_hard_dependencies.html) to mock `User` instance easily, but it difficult to mock `User` instance properties when `User` set the properties on its `__construct` phase.

test case
---------

[](#test-case)

under the `tests` folder, there are two test cases here:

1. LegacyCodeFailTest.php
2. LegacyCodeSuccessTest.php

see `tests\LegacyCodeSuccessTest.php` will show you how to use `mockery-overload-properties` to mock `User`

```
    /**
     * @test
     */
    public function notVipUserBonusShouldCorrect()
    {
        $properties = [
            'id' => 2,
            'isVip' => false,
            'rank' => 99
        ];
        $user = mop::mock('\User', $properties);

        // bounus should be 149
        $bunus = 100 * 0.5 + 99;

        $vip = new Vip;
        $this->assertEquals($bunus, $vip->bonus($userId = 2));
    }
```

when mock instance whith properties, you still can use [`Expectation Declarations ` from `Mockery`](http://docs.mockery.io/en/latest/reference/expectations.html) to test you code.

```
    /**
     * @test
     */
    public function notVipUserBonusShouldCorrect()
    {
        $properties = [
            'id' => 2,
            'isVip' => false,
            'rank' => 99
        ];
        $user = mop::mock('\User', $properties);

        // Expectation
        $user->shouldReceive('name_of_method');
            ->with($arg1, $arg2, ...);
            ->andReturn($value);

        // etc...
    }
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Every ~0 days

Total

2

Last Release

2997d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/eaf9a4fa4b1aa07d0af75a4168803655ab4dabbb9f3213ff0d4baad9cc7a0cd0?d=identicon)[hermes](/maintainers/hermes)

---

Top Contributors

[![hermeslin](https://avatars.githubusercontent.com/u/2077412?v=4)](https://github.com/hermeslin "hermeslin (8 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/hermeslin-mockery-overload-properties/health.svg)

```
[![Health](https://phpackages.com/badges/hermeslin-mockery-overload-properties/health.svg)](https://phpackages.com/packages/hermeslin-mockery-overload-properties)
```

###  Alternatives

[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[jasonmccreary/laravel-test-assertions

A set of helpful assertions when testing Laravel applications.

3513.9M32](/packages/jasonmccreary-laravel-test-assertions)[brain/monkey

Mocking utility for PHP functions and WordPress plugin API

33412.5M350](/packages/brain-monkey)[codeception/mockery-module

Mockery Module for Codeception

344.2M82](/packages/codeception-mockery-module)[lastzero/test-tools

Increases testing productivity by adding a service container and self-initializing fakes to PHPUnit

2244.3k13](/packages/lastzero-test-tools)

PHPackages © 2026

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