function testAttachedMethod() { $myObject = new MyObject(); try { $this->assertEquals('Hello World!', $myObject->helloWorld()); $this->hasFailed(); } catch (RecessException $e) { // Success } $attachedMethodProvider = new MyNewClassMethodProvider(); MyObject::attachMethod('MyObject', 'helloWorld', $attachedMethodProvider, 'callMe'); try { $this->assertEquals($myObject->helloWorld(), 'Hello World!'); // Success } catch (RecessException $e) { $this->hasFailed(); } }