public function testExtend() { $object = new ObjectTest_ExtendTest(); $argument = 'test'; $this->assertEquals($object->extend('extendableMethod'), array('ExtendTest2()')); $this->assertEquals($object->extend('extendableMethod', $argument), array('ExtendTest2(modified)')); $this->assertEquals($argument, 'modified'); $this->assertEquals(array('ExtendTest()', 'ExtendTest2()'), $object->invokeWithExtensions('extendableMethod')); $arg1 = 'test'; $arg2 = 'bob'; $this->assertEquals(array('ExtendTest(test,bob)', 'ExtendTest2(modified,objectmodified)'), $object->invokeWithExtensions('extendableMethod', $arg1, $arg2)); $this->assertEquals('modified', $arg1); $this->assertEquals('objectmodified', $arg2); $object2 = new ObjectTest_Extending(); $first = 1; $second = 2; $third = 3; $result = $object2->getResults($first, $second, $third); $this->assertEquals(array(array('before', 'extension', 'after')), $result); $this->assertEquals(31, $first); $this->assertEquals(32, $second); $this->assertEquals(33, $third); }
public function testExtend() { $object = new ObjectTest_ExtendTest(); $argument = 'test'; $this->assertEquals($object->extend('extendableMethod'), array('ExtendTest2()')); $this->assertEquals($object->extend('extendableMethod', $argument), array('ExtendTest2(modified)')); $this->assertEquals($argument, 'modified'); $this->assertEquals($object->invokeWithExtensions('extendableMethod'), array('ExtendTest()', 'ExtendTest2()')); $this->assertEquals($object->invokeWithExtensions('extendableMethod', 'test'), array('ExtendTest(test)', 'ExtendTest2(modified)')); }