/** * @covers phpDocumentor\Compiler\Linker\Linker::substitute * @depends testSubstituteFqsenInObject */ public function testSubstituteFieldsViaArrayOfChildObjects() { // initialize parameters $result = new \stdClass(); $childFieldName = 'field'; $fieldName = 'child'; list($childObject, $childFqsen) = $this->createMockDescriptorForResult($result); $object = m::mock('stdClass'); $fqsen = get_class($object); $object->shouldReceive('getChild')->atLeast()->once()->andReturn(array($childObject)); $object->shouldReceive('setChild'); // prepare linker $linker = new Linker(array($fqsen => array($fieldName), $childFqsen => array($childFieldName))); $linker->setObjectAliasesList(array($childFqsen => $result)); // execute test. $linker->substitute($object); // mark test as successful due to asserts in Mockery $this->assertTrue(true); }
/** * @covers phpDocumentor\Compiler\Linker\Linker::execute * @covers phpDocumentor\Compiler\Linker\Linker::replacePseudoTypes */ public function testReplaceThisWithCurrentClassInScope() { $fixture = new Linker(array('phpDocumentor\\Descriptor\\ClassDescriptor' => array('methods'), 'phpDocumentor\\Descriptor\\MethodDescriptor' => array('tags'), 'phpDocumentor\\Descriptor\\Tag\\SeeDescriptor' => array('reference'))); $methodName = 'myMethod'; $fqnn = '\\My\\Space'; $className = 'MyClass'; $seeDescriptor = $this->givenASeeDescriptorWithReference('$this::' . $methodName . '()'); $classDescriptor = $this->givenAClassWithNamespaceAndClassName($fqnn, $className); $methodDescriptor = $this->givenAMethodWithClassAndName($classDescriptor, $methodName); $methodDescriptor->getTags()->get($seeDescriptor->getName(), new Collection())->add($seeDescriptor); $classDescriptor->getMethods()->add($methodDescriptor); $fixture->setObjectAliasesList(array($fqnn . '\\' . $className => $classDescriptor, $fqnn . '\\' . $className . '::' . $methodName . '()' => $methodDescriptor)); $fixture->substitute($classDescriptor); $this->assertSame($methodDescriptor, $seeDescriptor->getReference()); }