function ref_other_class($t) { $obj = new TestClass(); $other = new OtherClass(); $obj->other = $other; $obj->register_hook(); $obj->other->register_hook(); $r = $obj->run_hook(4); $t->is($r, 22); $obj->clear_hook(); $other->clear_hook(); }