From 76f5ed0c9e9b442e00f8f790f0ef031c49a3b4b1 Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel
Date: Thu, 11 Nov 2010 13:37:47 +0100 Subject: [PATCH] Validate error handling when generating a snapshot. --- .../Components/Module/DevPackageTest.php | 14 ++++++++-- components/test/Components/StoryTestCase.php | 30 ++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/components/test/Components/Integration/Components/Module/DevPackageTest.php b/components/test/Components/Integration/Components/Module/DevPackageTest.php index 4b5587d35..4380eb2fb 100644 --- a/components/test/Components/Integration/Components/Module/DevPackageTest.php +++ b/components/test/Components/Integration/Components/Module/DevPackageTest.php @@ -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 diff --git a/components/test/Components/StoryTestCase.php b/components/test/Components/StoryTestCase.php index 21c7561cc..c12bac482 100644 --- a/components/test/Components/StoryTestCase.php +++ b/components/test/Components/StoryTestCase.php @@ -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 -- 2.11.0