1.2.1614. ext/uopz¶
Extension UOPZ : User Operations for Zend.
The uopz extension is focused on providing utilities to aid with unit testing PHP code.
It supports the following activities: Intercepting function execution, Intercepting object creation, Hooking into function execution, Manipulation of function statics, Manipulation of function flags, Redefinition of constants, Deletion of constants, Runtime creation of functions and methods,
<?php
// The example is extracted from the UOPZ extension test suite : tests/001.phpt
class Foo {
public function bar(int $arg) : int {
return $arg;
}
}
var_dump(uopz_set_return(Foo::class, 'bar', true));
$foo = new Foo();
var_dump($foo->bar(1));
uopz_set_return(Foo::class, 'bar', function(int $arg) : int {
return $arg * 2;
}, true);
var_dump($foo->bar(2));
try {
uopz_set_return(Foo::class, 'nope', 1);
} catch(Throwable $t) {
var_dump($t->getMessage());
}
class Bar extends Foo {}
try {
uopz_set_return(Bar::class, 'bar', null);
} catch (Throwable $t) {
var_dump($t->getMessage());
}
uopz_set_something(Bar::class, 'bar', null);
?>
See also ext/uopz and User Operations for Zend.
1.2.1614.1. Specs¶
Short name |
Extensions/Extuopz |
Rulesets |
|
Exakat since |
1.1.7 |
PHP Version |
All |
Severity |
|
Time To Fix |
|
Precision |
Very high |
Available in |