Bug #9364: Components notices and fatal error
authorGunnar Wrobel <p@rdus.de>
Tue, 16 Nov 2010 22:09:35 +0000 (23:09 +0100)
committerGunnar Wrobel <p@rdus.de>
Tue, 16 Nov 2010 22:09:35 +0000 (23:09 +0100)
components/lib/Components/Pear/Package/Contents.php
components/test/Components/Integration/Components/Module/PearPackageXmlTest.php
components/test/Components/StoryTestCase.php
components/test/Components/fixture/changelog/lib/Some.php [new file with mode: 0644]
components/test/Components/fixture/changelog/package.xml [new file with mode: 0644]

index 2c03805..9131a63 100644 (file)
@@ -114,7 +114,10 @@ class Components_Pear_Package_Contents
         $this->getPackage()->_getSimpleDirTag($this->getPackage()->_struc);
 
         $this->_tasks->annotate($this->getPackage(), $taskfiles);
-
+        // Workaround for [#9364] Components notices and fatal error
+        if ($this->getPackage()->_packageInfo['changelog'] == '') {
+            unset($this->getPackage()->_packageInfo['changelog']);
+        }
         $this->_filelist_factory->create($this->getPackage())->update();
     }
 }
\ No newline at end of file
index 8e334bb..b90ac67 100644 (file)
@@ -143,6 +143,16 @@ extends Components_StoryTestCase
             ->and('the new package.xml of the Horde component will contain the file', 'test2');
     }
 
+    /**
+     * @scenario
+     */
+    public function testEmptyChangelog()
+    {
+        $this->given('the default Components setup')
+            ->when('calling the package with the packagexml option and a component with empty changelog')
+            ->then('the new package.xml of the Horde component will have a changelog entry');
+    }
+
 
     /**
      * @todo Test (and fix) the reactions to three more scenarios:
index a92fabd..3706d2f 100644 (file)
@@ -107,6 +107,15 @@ extends PHPUnit_Extensions_Story_TestCase
             );
             $world['output'] = $this->_callUnstrictComponents();
             break;
+        case 'calling the package with the packagexml option and a component with empty changelog':
+            $_SERVER['argv'] = array(
+                'horde-components',
+                '--pearrc=' . $this->_getTemporaryDirectory() . DIRECTORY_SEPARATOR . '.pearrc',
+                '--packagexml',
+                dirname(__FILE__) . '/fixture/changelog'
+            );
+            $world['output'] = $this->_callUnstrictComponents();
+            break;
         case 'calling the package with the packagexml option and the path':
             $_SERVER['argv'] = array(
                 'horde-components',
@@ -393,6 +402,12 @@ extends PHPUnit_Extensions_Story_TestCase
                 file_exists($this->_temp_dir . DIRECTORY_SEPARATOR . 'package.xml')
             );
             break;
+        case 'the new package.xml of the Horde component will have a changelog entry':
+            $this->assertRegExp(
+                '#</changelog>#',
+                $world['output']
+            );
+            break;
         case 'a new PEAR configuration file will be installed':
             $this->assertTrue(
                 file_exists($this->_temp_dir . DIRECTORY_SEPARATOR . '.pearrc')
diff --git a/components/test/Components/fixture/changelog/lib/Some.php b/components/test/Components/fixture/changelog/lib/Some.php
new file mode 100644 (file)
index 0000000..a814366
--- /dev/null
@@ -0,0 +1 @@
+<?php
\ No newline at end of file
diff --git a/components/test/Components/fixture/changelog/package.xml b/components/test/Components/fixture/changelog/package.xml
new file mode 100644 (file)
index 0000000..4429ad5
--- /dev/null
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package packagerversion="1.9.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
+ <name>Fixture</name>
+ <channel>pear.php.net</channel>
+ <summary>Test fixture.</summary>
+ <description>A dummy package.xml used for testing the Components package.</description>
+ <lead>
+  <name>Gunnar Wrobel</name>
+  <user>wrobel</user>
+  <email>p@rdus.de</email>
+  <active>yes</active>
+ </lead>
+ <date>2010-08-22</date>
+ <time>21:12:03</time>
+ <version>
+  <release>0.0.1</release>
+  <api>0.0.1</api>
+ </version>
+ <stability>
+  <release>alpha</release>
+  <api>alpha</api>
+ </stability>
+ <license uri="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL</license>
+ <notes>
+* Initial release
+ </notes>
+ <contents>
+  <dir baseinstalldir="/" name="/">
+   <dir name="lib">
+    <file name="Some.php" role="php" />
+   </dir> <!-- /lib -->
+  </dir> <!-- / -->
+ </contents>
+ <dependencies>
+  <required>
+   <php>
+    <min>5.0.0</min>
+   </php>
+   <pearinstaller>
+    <min>1.7.0</min>
+   </pearinstaller>
+  </required>
+ </dependencies>
+ <phprelease>
+  <filelist>
+   <install as="Some.php" name="lib/Some.php" />
+  </filelist>
+ </phprelease>
+ <changelog/>
+</package>