PHPackages                             jced-artem/uopz - 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. jced-artem/uopz

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

jced-artem/uopz
===============

Wrapper for php uopz library's functions. Useful for unit testing for changing function's behavior in runtime

1.0.6(9y ago)31.1k1MITPHPPHP &gt;=5.6.0

Since Nov 30Pushed 9y ago2 watchersCompare

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

READMEChangelog (7)DependenciesVersions (8)Used By (0)

uopz
====

[](#uopz)

Wrapper for php uopz library's functions. Very useful for unit testing for changing function's behavior in runtime.

### Requirements

[](#requirements)

```
oupz library

```

You can install it:

- for `php-7`: `pecl install uopz`
- for `php-5.6`: `pecl install uopz-2.0.7`

### Install

[](#install)

```
composer require jced-artem/uopz

```

### Usage

[](#usage)

```
class yourClass
{
    use Jced\UopzTrait;
    // ...
}

```

### Hook non-return third-party-called function to get return from it

[](#hook-non-return-third-party-called-function-to-get-return-from-it)

```
public function foo($data) {
    return Database::insert($data);
}
public function bar() {
    $data = ['field' => 'value'];
    foo($data);
}

```

Sometime when you testing bar() you may want to know what happend in foo()

```
public function testBar() {
    $this->uopzFunctionHook(
        'foo',
        function ($data) {
            return $data;
        },
        $fooResult
    );
    bar();
    $this->assertEqual(['field' => 'value'], $fooResult);
}

```

### Replace function's return value using list of conditions.

[](#replace-functions-return-value-using-list-of-conditions)

Source function cant be redefined or defined as closure before using this method.

```
public function selectAll($table) {
    return $db->select()->from($table)->fetchAll();
}
public function foo() {
    $result1 = $this->selectAll('user');
    // do something
    $result2 = $this->selectAll('article');
    // do something
    $result3 = $this->selectAll('post');
}

```

You can mock all calls just doing:

```
public function testFoo() {
    $this->uopzFunctionConditionReturn(
        'selectAll',
        [
            ['table', 'user', [0 => 'user1', 2 => 'user3']],
            ['table', 'post', function () { return 'some other result here'; }],
        ],
        null // for all other queries
    );
}

```

### Consistent return

[](#consistent-return)

```
public function testFoo() {
    $this->uopzFunctionConditionReturn(
        'selectAll',
        [
            [0 => 'user1', 2 => 'user3'],
            'some other result here',
        ]
    );
}

```

### Replace one function with another

[](#replace-one-function-with-another)

```
$this->uopzFunctionReplace(['mysqli', 'query'], 'mysql_query'); // downgrade :)

```

### Simple return

[](#simple-return)

Just return something, nothing more

```
$this->uopzFunctionSimpleReturn('functionName', 'return string');

```

### Backup function

[](#backup-function)

```
$this->uopzBackup('functionName');

```

### Restore function

[](#restore-function)

```
$this->uopzRestore('functionName');

```

### Mute function

[](#mute-function)

Ask function to do nothing :)

```
$this->uopzMuteFunction('functionName');

```

### Aliases

[](#aliases)

```
// uops_function
    public function uopzFunction($function, Closure $closure, $backup = false);
// uops_redefine
    public function uopzRedefine($constant, $value);
// uops_flags
    public function uopzFlags($function, $flags);

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

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

Total

7

Last Release

3440d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.3.0

1.0.3PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/694933bfd2d85dd295280dff0c339061f3652f3c65ad2a5427e429462b33e295?d=identicon)[jced\_artem](/maintainers/jced_artem)

---

Top Contributors

[![jced-artem](https://avatars.githubusercontent.com/u/1507915?v=4)](https://github.com/jced-artem "jced-artem (16 commits)")

---

Tags

phptestingunitruntimeuopz

### Embed Badge

![Health badge](/badges/jced-artem-uopz/health.svg)

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

###  Alternatives

[php-vfs/php-vfs

Virtual file system implementation for use with PHP unit testing.

572.7M24](/packages/php-vfs-php-vfs)[quizlet/hammock

Hammock is a stand-alone mocking library for Hacklang.

27445.5k](/packages/quizlet-hammock)[doppiogancio/mocked-client

A simple way to mock a client

2174.9k3](/packages/doppiogancio-mocked-client)[robiningelbrecht/phpunit-coverage-tools

PHPUnit coverage tools

1783.0k33](/packages/robiningelbrecht-phpunit-coverage-tools)

PHPackages © 2026

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