Validate error handling when generating a snapshot.
authorGunnar Wrobel <p@rdus.de>
Thu, 11 Nov 2010 12:37:47 +0000 (13:37 +0100)
committerGunnar Wrobel <p@rdus.de>
Thu, 11 Nov 2010 21:31:12 +0000 (22:31 +0100)
components/test/Components/Integration/Components/Module/DevPackageTest.php
components/test/Components/StoryTestCase.php

index 4b5587d..4380eb2 100644 (file)
@@ -38,7 +38,7 @@ extends Components_StoryTestCase
     /**
      * @scenario
      */
-    public function theDevPackageModuleAddsTheDOptionInTheHelpOutput()
+    public function testOption()
     {
         $this->given('the default Components setup')
             ->when('calling the package with the help option')
@@ -48,10 +48,20 @@ extends Components_StoryTestCase
     /**
      * @scenario
      */
-    public function theTheLowerCaseDOptionGeneratesAPackageSnapshot()
+    public function testSnapshotGeneration()
     {
         $this->given('the default Components setup')
             ->when('calling the package with the devpackage option, the archive directory option and a path to a Horde framework component')
             ->then('a package snapshot will be generated at the indicated archive directory');
     }
+
+    /**
+     * @scenario
+     */
+    public function testErrorHandling()
+    {
+        $this->given('the default Components setup')
+            ->when('calling the package with the devpackage option, the archive directory option and a path to an invalid Horde framework component')
+            ->then('the output should indicate an invalid package.xml');
+    }
 }
\ No newline at end of file
index 21c7561..c12bac4 100644 (file)
@@ -265,6 +265,22 @@ extends PHPUnit_Extensions_Story_TestCase
             );
             $world['output'] = $this->_callUnstrictComponents();
             break;
+        case 'calling the package with the devpackage option, the archive directory option and a path to an invalid Horde framework component':
+            $this->_setPearGlobals();
+            $_SERVER['argv'] = array(
+                'horde-components',
+                '--verbose',
+                '--devpackage',
+                '--archivedir=' . $this->_getTemporaryDirectory(),
+                dirname(__FILE__) . '/fixture/simple'
+            );
+            try {
+                $world['output'] = $this->_callUnstrictComponents();
+            } catch (Components_Exception_Pear $e) {
+                ob_end_clean();
+                $world['output'] = (string) $e;
+            }
+            break;
         case 'calling the package with the distribute option and a path to a Horde framework component':
             $_SERVER['argv'] = array(
                 'horde-components',
@@ -582,6 +598,12 @@ extends PHPUnit_Extensions_Story_TestCase
                 )
             );
             break;
+        case 'the output should indicate an invalid package.xml':
+            $this->assertContains(
+                'PEAR_Packagefile_v2::toTgz: invalid package.xml',
+                $world['output']
+            );
+            break;
         default:
             return $this->notImplemented($action);
         }
@@ -649,4 +671,12 @@ extends PHPUnit_Extensions_Story_TestCase
     {
         Components::main($parameters);
     }
+
+    private function _setPearGlobals()
+    {
+        $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK'] = array(
+            '*' => false,
+        );
+        $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER'] = false;
+    }
 }
\ No newline at end of file