function _wrap($function, $wrapper) { return Underscore::wrap($function, $wrapper); }
/** * @tags functions */ public function testWrap() { // it should execute wrapped function when run $result = false; $fn = function () use(&$result) { $result = true; }; $wrapper = _::wrap($fn, function ($fn) { $fn(); }); $wrapper(); $this->boolean($result)->isTrue(); // it should pass parameters along with wrapped function $result = null; $fn = function ($a, $b, $c) use(&$result) { $result = $a + $b + $c; }; $wrapper = _::wrap($fn, function ($fn, $a, $b, $c) { $fn($a, $b, $c); }); $wrapper(1, 2, 3); $this->integer($result)->isEqualTo(6); // it should forward returned value $fn = function () { return true; }; $wrapper = _::wrap($fn, function ($fn) { return $fn(); }); $this->boolean($wrapper())->isTrue(); }