public function testShouldDelegateUndefinedMethodsToAnnotatedProperty() { $r = new c\Registry(); $r['phplombok_debug'] = true; $r['phplombok_cachedir'] = "/tmp/"; $glueCode = new GlueCode(); $phplombokR = $glueCode->getRegistry($r); $obj = new testresources\TestedClass3(); $obj->property1 = $prop1 = m::mock('delegateObj'); $newObj = $phplombokR['childClassGenerator']->generate($obj); $prop1->shouldReceive('undefinedMethod')->with('arg1')->andReturn('someResult')->once(); $this->assertEquals($newObj->property1UndefinedMethod('arg1'), 'someResult'); }
public function testShouldGeneratePropertiesLikeJQuery() { $r = new c\Registry(); $r['phplombok_debug'] = true; $r['phplombok_cachedir'] = "/tmp/"; $glueCode = new GlueCode(); $phplombokR = $glueCode->getRegistry($r); $glueCode1 = new GlueCode(); $phplombokR1 = $glueCode1->getRegistry($r); $obj = new testresources\TestedClass2(); $newObj = $phplombokR['childClassGenerator']->generate($obj); $newObj1 = $phplombokR1['childClassGenerator']->generate($obj); $this->assertTrue($newObj instanceof testresources\TestedClass2); $this->assertEquals(get_class($newObj), get_class($newObj1)); $newObj->testedProperty1(1)->testedProperty2(2); $refObj = new \ReflectionObject($obj); $prop1 = $refObj->getProperty('testedProperty1'); $prop1->setAccessible(true); $this->assertEquals($prop1->getValue($obj), $newObj->testedProperty2(1)->testedProperty1()); $this->assertEquals($newObj->methodToBeOverriden(), $obj->methodToBeOverriden()); }