/** * @covers phpDocumentor\Plugin\Core\Transformer\Writer\Xml::transform */ public function testTransformWithEmptyFileDescriptor() { $transformer = m::mock('phpDocumentor\\Transformer\\Transformer'); $transformer->shouldReceive('getTarget')->andReturn(vfsStream::url('XmlTest')); $transformation = m::mock('phpDocumentor\\Transformer\\Transformation'); $transformation->shouldReceive('getArtifact')->andReturn('artifact.xml'); $transformation->shouldReceive('getTransformer')->andReturn($transformer); $fileDescriptor = m::mock('phpDocumentor\\Descriptor\\FileDescriptor'); $fileDescriptor->shouldReceive('getPath')->andReturn('foo.php'); $fileDescriptor->shouldReceive('getInheritedElement')->andReturn(null); $transformer->shouldReceive('generateFilename')->with('foo.php')->andReturn('generated-foo.php'); $fileDescriptor->shouldReceive('getHash')->andReturn('hash'); $fileDescriptor->shouldReceive('getAllErrors')->andReturn(array()); $this->projectDescriptor->shouldReceive('getFiles')->andReturn(array($fileDescriptor)); $this->projectDescriptor->shouldReceive('getName')->andReturn('project'); $this->projectDescriptor->shouldReceive('getPartials')->andReturn(array()); $this->implementProtectedFinalize($this->projectDescriptor); $this->implementProtectedBuildDocBlock($fileDescriptor); $fileDescriptor->shouldReceive('getNamespaceAliases')->andReturn(array('foo', 'bar')); $fileDescriptor->shouldReceive('getConstants')->andReturn(array()); $fileDescriptor->shouldReceive('getFunctions')->andReturn(array()); $fileDescriptor->shouldReceive('getInterfaces')->andReturn(array()); $fileDescriptor->shouldReceive('getClasses')->andReturn(array()); $fileDescriptor->shouldReceive('getTraits')->andReturn(array()); $fileDescriptor->shouldReceive('getMarkers')->andReturn(array()); $fileDescriptor->shouldReceive('getErrors')->andReturn(array()); $fileDescriptor->shouldReceive('getPartials')->andReturn(array()); $fileDescriptor->shouldReceive('getSource')->andReturn(null); // Call the actual method $this->xml->transform($this->projectDescriptor, $transformation); // Check file exists $this->assertTrue($this->fs->hasChild('artifact.xml')); // Inspect XML $xml = <<<XML <?xml version="1.0" encoding="utf-8"?> <project version="2.0.0b8" title="project"> <partials/> <file path="foo.php" generated-path="generated-foo.php" hash="hash" package="myPackage"> <docblock line="666"> <description>my summary</description> <long-description>my description</long-description> </docblock> <namespace-alias name="0">foo</namespace-alias> <namespace-alias name="1">bar</namespace-alias> </file> <package name="global" full_name="global"/> <package name="myPackage" full_name="myPackage"/> <deprecated count="0"/> </project> XML; $expectedXml = new \DOMDocument(); $expectedXml->loadXML($xml); $actualXml = new \DOMDocument(); $actualXml->load(vfsStream::url('XmlTest/artifact.xml')); $this->assertEqualXMLStructure($expectedXml->firstChild, $actualXml->firstChild, true); }
/** * Test that the lock file is created * * @test */ public function testConstructorCreatesLockFile() { $this->assertFalse($this->vfs->hasChild("test.lock")); $lock = new Lock("test", vfsStream::url("tests")); $this->assertTrue($this->vfs->hasChild("test.lock")); }