From: Gunnar Wrobel Date: Wed, 27 Oct 2010 18:45:52 +0000 (+0200) Subject: Add a test for creating the package.xml from scratch and fix some notices. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=6a752339ec78c509f4719e5188be425c8a7f7bef;p=horde.git Add a test for creating the package.xml from scratch and fix some notices. --- diff --git a/components/lib/Components/Pear/Factory.php b/components/lib/Components/Pear/Factory.php index 36cbcca2f..ffcbebd75 100644 --- a/components/lib/Components/Pear/Factory.php +++ b/components/lib/Components/Pear/Factory.php @@ -206,11 +206,12 @@ class Components_Pear_Factory ); $pkg->setLicense('REPLACE', 'REPLACE'); $pkg->setNotes('* Initial release.'); - $pkg->clearContents(); + $pkg->clearContents(true); $pkg->clearDeps(); $pkg->setPhpDep('5.2.0'); $pkg->setPearinstallerDep('1.9.0'); $pkg->setPackageType('php'); + $pkg->addFile('', 'something', array('role' => 'php')); new PEAR_Validate(); return Components_Exception_Pear::catchError( $pkg->getDefaultGenerator() diff --git a/components/lib/Components/Pear/Package.php b/components/lib/Components/Pear/Package.php index 0eb12c710..e5e39c333 100644 --- a/components/lib/Components/Pear/Package.php +++ b/components/lib/Components/Pear/Package.php @@ -256,6 +256,9 @@ class Components_Pear_Package $updated = $package->getContents(); $updated = $updated['dir']['file']; foreach ($updated as $file) { + if (!isset($file['attribs'])) { + continue; + } if (isset($taskfiles[$file['attribs']['name']])) { foreach ($taskfiles[$file['attribs']['name']] as $tag => $raw) { $taskname = $package->getTask($tag) . '_rw'; @@ -316,6 +319,9 @@ class Components_Pear_Package $horde_role = false; foreach ($files as $file) { + if (!isset($file['attribs'])) { + continue; + } $components = explode('/', $file['attribs']['name'], 2); switch ($components[0]) { case 'doc': diff --git a/components/test/Components/Integration/Components/Module/PearPackageXmlTest.php b/components/test/Components/Integration/Components/Module/PearPackageXmlTest.php index e579062eb..d69bbb7dd 100644 --- a/components/test/Components/Integration/Components/Module/PearPackageXmlTest.php +++ b/components/test/Components/Integration/Components/Module/PearPackageXmlTest.php @@ -69,6 +69,16 @@ extends Components_StoryTestCase /** * @scenario */ + public function theUOptionWillCreateANewPackageXmlInCaseItIsMissing() + { + $this->given('the default Components setup') + ->when('calling the package with the updatexml option and a path without package.xml') + ->then('a new package.xml will be created.'); + } + + /** + * @scenario + */ public function thePOptionFailsWithoutAValidDirectoryPath() { $this->given('the default Components setup') diff --git a/components/test/Components/StoryTestCase.php b/components/test/Components/StoryTestCase.php index 1d0c5097d..f44fd9ae1 100644 --- a/components/test/Components/StoryTestCase.php +++ b/components/test/Components/StoryTestCase.php @@ -84,6 +84,20 @@ extends PHPUnit_Extensions_Story_TestCase ); $world['output'] = $this->_callUnstrictComponents(); break; + case 'calling the package with the updatexml option and a path without package.xml': + $temp = $this->_getTemporaryDirectory(); + mkdir($temp . DIRECTORY_SEPARATOR . 'test'); + file_put_contents( + $temp . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'test.php', + '_callUnstrictComponents(); + break; case 'calling the package with the pearrc, the packagexml option, and a Horde component': $_SERVER['argv'] = array( 'horde-components', @@ -301,6 +315,11 @@ extends PHPUnit_Extensions_Story_TestCase $world['output'] ); break; + case 'a new package.xml will be created.': + $this->assertTrue( + file_exists($this->_temp_dir . DIRECTORY_SEPARATOR . 'package.xml') + ); + break; case 'a new PEAR configuration file will be installed': $this->assertTrue( file_exists($this->_temp_dir . DIRECTORY_SEPARATOR . '.pearrc')