/** * Read the package metadata for the given package from the * Package.xml file contained in the package * * @param \F3\FLOW3\Package\PackageInterface $package The package to read metadata for * @return MetaData A package meta data instance with the data from the package's Package.xml file. * @author Christopher Hlubek <*****@*****.**> */ public function readPackageMetaData(\F3\FLOW3\Package\PackageInterface $package) { $packageInfoPath = $package->getMetaPath(); $meta = new \F3\FLOW3\Package\MetaData($package->getPackageKey()); $xml = simplexml_load_file(\F3\FLOW3\Utility\Files::concatenatePaths(array($packageInfoPath, 'Package.xml'))); if ($xml === FALSE) { $meta->setDescription('[Package.xml could not be read.]'); } else { $meta->setVersion((string) $xml->version); $meta->setTitle((string) $xml->title); $meta->setDescription((string) $xml->description); $this->readCategories($xml, $meta); $this->readParties($xml, $meta); $this->readConstraints($xml, $meta); } return $meta; }
/** * @test * @author Christopher Hlubek <*****@*****.**> * @author Robert Lemke <*****@*****.**> */ public function testWritePackageMetaDataCreatesXml() { $packageMetaDataPath = \vfsStream::url('testDirectory') . '/'; $mockPackage = $this->getMock('F3\\FLOW3\\Package\\PackageInterface'); $mockPackage->expects($this->once())->method('getMetaPath')->will($this->returnValue($packageMetaDataPath)); $meta = new \F3\FLOW3\Package\MetaData('YetAnotherTestPackage'); $meta->setTitle('Yet another test package'); $meta->setDescription('A test package to test the creation of the Package.xml by the Package Manager'); $meta->setVersion('0.1.1'); $meta->addCategory('Testing'); $meta->addCategory('System'); $meta->addParty(new \F3\FLOW3\Package\MetaData\Person('LeadDeveloper', 'Robert Lemke', '*****@*****.**', 'http://www.flow3.org', 'TYPO3 Association', 'robert')); $meta->addParty(new \F3\FLOW3\Package\MetaData\Company(null, 'Acme Inc.', '*****@*****.**', 'http://www.acme.com')); $meta->addConstraint(new \F3\FLOW3\Package\MetaData\PackageConstraint('depends', 'FLOW3', '1.0.0', '1.9.9')); $meta->addConstraint(new \F3\FLOW3\Package\MetaData\SystemConstraint('depends', 'PHP', NULL, '5.3.0')); $meta->addConstraint(new \F3\FLOW3\Package\MetaData\SystemConstraint('suggests', 'Memory', '16M')); $metaWriter = new \F3\FLOW3\Package\MetaData\XmlWriter(); $metaWriter->writePackageMetaData($mockPackage, $meta); $this->assertXmlFileEqualsXmlFile($packageMetaDataPath . 'Package.xml', __DIR__ . '/../Fixtures/XmlWriterTest/Package.xml'); }