PHPackages                             duncan3dc/uopz-expectations - 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. duncan3dc/uopz-expectations

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

duncan3dc/uopz-expectations
===========================

Mock core functions and set up expectations similar to Mockery

1.0.0(4y ago)8254.1k↓34.4%4Apache-2.0PHPPHP ^7.2 || ^8.0

Since May 8Pushed 4y ago1 watchersCompare

[ Source](https://github.com/duncan3dc/uopz-expectations)[ Packagist](https://packagist.org/packages/duncan3dc/uopz-expectations)[ Docs](https://github.com/duncan3dc/uopz-expectations)[ RSS](/packages/duncan3dc-uopz-expectations/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (8)Used By (4)

uopz-expectations
=================

[](#uopz-expectations)

Mock core functions and set up expectations similar to Mockery.

Full documentation is available at
PHPDoc API documentation is also available at [http://duncan3dc.github.io/uopz-expectations/api/](http://duncan3dc.github.io/uopz-expectations/api/namespaces/duncan3dc.Mock.html)

[![release](https://camo.githubusercontent.com/0a5c5a5624d529f3b82238a6b7d85d049491dadc023f343ec851361148cb5359/68747470733a2f2f706f7365722e707567782e6f72672f64756e63616e3364632f756f707a2d6578706563746174696f6e732f76657273696f6e2e737667)](https://packagist.org/packages/duncan3dc/uopz-expectations)[![build](https://github.com/duncan3dc/uopz-expectations/workflows/.github/workflows/buildcheck.yml/badge.svg?branch=master)](https://github.com/duncan3dc/uopz-expectations/actions?query=branch%3Amaster+workflow%3A.github%2Fworkflows%2Fbuildcheck.yml)[![coverage](https://camo.githubusercontent.com/dedf8a10a4612de284a85ac19330607e4e01877676a66fef4c356593baae8234/68747470733a2f2f636f6465636f762e696f2f67682f64756e63616e3364632f756f707a2d6578706563746174696f6e732f67726170682f62616467652e737667)](https://codecov.io/gh/duncan3dc/uopz-expectations)

Introduction
------------

[](#introduction)

The [uopz](https://secure.php.net/manual/en/intro.uopz.php) extension offers an easy to way mock core functions.
The [Mockery](https://github.com/mockery/mockery) library offers a succinct API to declare expectation method calls.
This library combines the two to offer core function mocking with a familiar API.

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

[](#installation)

The recommended method of installing this library is via [Composer](//getcomposer.org/).

Run the following command from your project root:

```
$ composer require --dev duncan3dc/uopz-expectations
```

Getting Started
---------------

[](#getting-started)

```
use duncan3dc\Mock\CoreFunction;

CoreFunction::mock("time")->twice()->with()->andReturn(777);

time(); # 777

/**
 * At this point the expectations will be checked,
 * and an exception will be throw as `time()`
 * should have been called twice.
 */
CoreFunction::close();
```

*Read more at *

Where to get help
-----------------

[](#where-to-get-help)

Found a bug? Got a question? Just not sure how something works?
Please [create an issue](//github.com/duncan3dc/uopz-expectations/issues) and I'll do my best to help out.
Alternatively you can catch me on [Twitter](https://twitter.com/duncan3dc)

duncan3dc/uopz-expectations for enterprise
------------------------------------------

[](#duncan3dcuopz-expectations-for-enterprise)

Available as part of the Tidelift Subscription

The maintainers of duncan3dc/uopz-expectations and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-duncan3dc-uopz-expectations?utm_source=packagist-duncan3dc-uopz-expectations&utm_medium=referral&utm_campaign=readme)

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity73

Established project with proven stability

 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 ~199 days

Recently: every ~227 days

Total

7

Last Release

1738d ago

Major Versions

0.6.0 → 1.0.02021-08-15

PHP version history (3 changes)0.1.0PHP ^7.1

0.3.0PHP ^7.2

1.0.0PHP ^7.2 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/11dc66042513f11d1c99b1e6763f25dca84a3ff31cdbea3972b9b804a3d3d5e9?d=identicon)[duncan3dc](/maintainers/duncan3dc)

---

Top Contributors

[![duncan3dc](https://avatars.githubusercontent.com/u/546811?v=4)](https://github.com/duncan3dc "duncan3dc (40 commits)")

---

Tags

mockerymockingphpphpunittestinguopztestingphpunitmockingmockerymockcoreuopz

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/duncan3dc-uopz-expectations/health.svg)

```
[![Health](https://phpackages.com/badges/duncan3dc-uopz-expectations/health.svg)](https://phpackages.com/packages/duncan3dc-uopz-expectations)
```

###  Alternatives

[mockery/mockery

Mockery is a simple yet flexible PHP mock object framework

10.7k497.0M23.6k](/packages/mockery-mockery)[brain/monkey

Mocking utility for PHP functions and WordPress plugin API

33812.5M350](/packages/brain-monkey)[dg/bypass-finals

Removes final keyword from source code on-the-fly and allows mocking of final methods and classes

57026.3M456](/packages/dg-bypass-finals)[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)[donatj/mock-webserver

Simple mock web server for unit testing

1382.5M80](/packages/donatj-mock-webserver)[blastcloud/guzzler

Supercharge your app or SDK with a testing library specifically for Guzzle.

272419.3k35](/packages/blastcloud-guzzler)

PHPackages © 2026

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