$result = $callback(123); $tf->assertEqual($result, 124); }); /** * Check functions are wrapped correctly. */ $tf->test('Function wrapping', function ($tf) { $callback = new \Happen\Callback('\\Happen\\Test\\addOne'); $result = $callback(123); $tf->assertEqual($result, 124); // Check we can't set context on a function. try { $callback->bind((object) array()); $tf->fail(); } catch (\Exception $e) { $tf->pass(); } }); /** * Check methods are wrapped correctly. */ $tf->test('Method wrapping', function ($tf) { $test_obj = new \Happen\Test\TestClass(); // Test dynamic method $callback_a = new \Happen\Callback(array($test_obj, 'addOne')); $result_a = $callback_a(123); $tf->assertEqual($result_a, 124); // Test static method $callback_b = new \Happen\Callback(array('\\Happen\\Test\\TestClass', 'addTwo')); $result_b = $callback_b(123); $tf->assertEqual($result_b, 125);