Start collecting stubs of general use in the Horde_Test package.
authorGunnar Wrobel <p@rdus.de>
Fri, 10 Dec 2010 05:02:16 +0000 (06:02 +0100)
committerGunnar Wrobel <p@rdus.de>
Mon, 13 Dec 2010 10:17:20 +0000 (11:17 +0100)
Added test stubs for testing command line tools (Argv, Cli). Both
classes tend to exit unconditionally in certain situations. The stubs
disable this.

components/package.xml
components/test/Components/Autoload.php
components/test/Components/StoryTestCase.php
components/test/Components/Stub/Cli.php [deleted file]
components/test/Components/Stub/Parser.php [deleted file]
framework/Test/lib/Horde/Test/Stub/Cli.php [new file with mode: 0644]
framework/Test/lib/Horde/Test/Stub/Parser.php [new file with mode: 0644]
framework/Test/package.xml

index a201f90..7d195d9 100644 (file)
@@ -1,5 +1,5 @@
 <?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">
+<package packagerversion="1.9.1" 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>Components</name>
  <channel>pear.horde.org</channel>
  <summary>A package for handling Horde components.</summary>
@@ -24,8 +24,8 @@
   <email>jan@horde.org</email>
   <active>yes</active>
  </lead>
- <date>2010-11-15</date>
- <time>18:30:05</time>
+ <date>2010-12-10</date>
+ <time>05:54:35</time>
  <version>
   <release>0.0.1</release>
   <api>0.0.1</api>
    <dir name="test">
     <dir name="Components">
      <dir name="fixture">
+      <dir name="changelog">
+       <dir name="lib">
+        <file name="Some.php" role="test" />
+       </dir> <!-- /test/Components/fixture/changelog/lib -->
+      </dir> <!-- /test/Components/fixture/changelog -->
       <dir name="channels">
        <file name="pear.horde.org.channel.xml" role="test" />
        <file name="pear.php.net.channel.xml" role="test" />
       </dir> <!-- /test/Components/Integration/Components -->
       <file name="ComponentsTest.php" role="test" />
      </dir> <!-- /test/Components/Integration -->
-     <dir name="Stub">
-      <file name="Cli.php" role="test" />
-      <file name="Parser.php" role="test" />
-     </dir> <!-- /test/Components/Stub -->
      <dir name="Unit">
       <dir name="Components">
        <dir name="Pear">
    <install as="Components/Autoload.php" name="test/Components/Autoload.php" />
    <install as="Components/phpunit.xml" name="test/Components/phpunit.xml" />
    <install as="Components/StoryTestCase.php" name="test/Components/StoryTestCase.php" />
+   <install as="Components/fixture/changelog/lib/Some.php" name="test/Components/fixture/changelog/lib/Some.php" />
    <install as="Components/fixture/channels/pear.horde.org.channel.xml" name="test/Components/fixture/channels/pear.horde.org.channel.xml" />
    <install as="Components/fixture/channels/pear.php.net.channel.xml" name="test/Components/fixture/channels/pear.php.net.channel.xml" />
    <install as="Components/fixture/channels/pear.phpunit.de.channel.xml" name="test/Components/fixture/channels/pear.phpunit.de.channel.xml" />
    <install as="Components/Integration/Components/Module/DistributeTest.php" name="test/Components/Integration/Components/Module/DistributeTest.php" />
    <install as="Components/Integration/Components/Module/InstallerTest.php" name="test/Components/Integration/Components/Module/InstallerTest.php" />
    <install as="Components/Integration/Components/Module/PearPackageXmlTest.php" name="test/Components/Integration/Components/Module/PearPackageXmlTest.php" />
-   <install as="Components/Stub/Cli.php" name="test/Components/Stub/Cli.php" />
-   <install as="Components/Stub/Parser.php" name="test/Components/Stub/Parser.php" />
    <install as="Components/Unit/Components/Pear/Package/Filelist/DefaultTest.php" name="test/Components/Unit/Components/Pear/Package/Filelist/DefaultTest.php" />
    <install as="COPYING" name="COPYING" />
    <install as="TODO" name="TODO" />
     <release>alpha</release>
     <api>alpha</api>
    </stability>
-   <date>2010-11-15</date>
+   <date>2010-12-10</date>
    <license uri="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL</license>
    <notes>
 * Initial release
index 6ec9896..10cdc35 100644 (file)
@@ -27,8 +27,4 @@ if (!class_exists('Components')) {
 error_reporting(E_ALL | E_STRICT);
 
 /** Load the basic test definition */
-require_once dirname(__FILE__) . '/StoryTestCase.php';
-
-/** Load stubs */
-require_once dirname(__FILE__) . '/Stub/Cli.php';
-require_once dirname(__FILE__) . '/Stub/Parser.php';
+require_once dirname(__FILE__) . '/StoryTestCase.php';
\ No newline at end of file
index 9ba58e5..2b35925 100644 (file)
@@ -671,11 +671,11 @@ extends PHPUnit_Extensions_Story_TestCase
     private function _callComponents(array $parameters, $callback)
     {
         ob_start();
-        $parameters['cli']['parser']['class'] = 'Components_Stub_Parser';
+        $parameters['cli']['parser']['class'] = 'Horde_Test_Stub_Parser';
         $parameters['dependencies'] = new Components_Dependencies_Injector();
         $parameters['dependencies']->setInstance(
             'Horde_Cli',
-            new Components_Stub_Cli()
+            new Horde_Test_Stub_Cli()
         );
         call_user_func_array($callback, array($parameters));
         $output = ob_get_contents();
diff --git a/components/test/Components/Stub/Cli.php b/components/test/Components/Stub/Cli.php
deleted file mode 100644 (file)
index f6564d1..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-class Components_Stub_Cli
-extends Horde_Cli
-{
-    /**
-     * Displays a fatal error message.
-     *
-     * @param mixed $error  The error text to display, an exception or an
-     *                      object with a getMessage() method.
-     */
-    public function fatal($error)
-    {
-        if ($error instanceof Exception) {
-            $trace = $error;
-        } else {
-            $trace = debug_backtrace();
-        }
-        $backtrace = new Horde_Support_Backtrace($trace);
-        if (is_object($error) && method_exists($error, 'getMessage')) {
-            $error = $error->getMessage();
-        }
-        $this->writeln($this->red('===================='));
-        $this->writeln();
-        $this->writeln($this->red(_("Fatal Error:")));
-        $this->writeln($this->red($error));
-        $this->writeln();
-        $this->writeln((string)$backtrace);
-        $this->writeln($this->red('===================='));
-    }
-}
\ No newline at end of file
diff --git a/components/test/Components/Stub/Parser.php b/components/test/Components/Stub/Parser.php
deleted file mode 100644 (file)
index b8efead..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-class Components_Stub_Parser
-extends Horde_Argv_Parser
-{
-    /**
-     * Print a usage message incorporating $msg to stderr and exit.
-     * If you override this in a subclass, it should not return -- it
-     * should either exit or raise an exception.
-     *
-     * @param string $msg
-     */
-    public function parserError($msg)
-    {
-        $this->printUsage();
-        $this->parserExit(2, sprintf("%s: error: %s\n", $this->getProgName(), $msg));
-    }
-
-    public function parserExit($status = 0, $msg = null)
-    {
-        if ($msg)
-            echo $msg;
-    }
-}
\ No newline at end of file
diff --git a/framework/Test/lib/Horde/Test/Stub/Cli.php b/framework/Test/lib/Horde/Test/Stub/Cli.php
new file mode 100644 (file)
index 0000000..ce394af
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+class Horde_Test_Stub_Cli
+extends Horde_Cli
+{
+    /**
+     * Displays a fatal error message.
+     *
+     * @param mixed $error  The error text to display, an exception or an
+     *                      object with a getMessage() method.
+     */
+    public function fatal($error)
+    {
+        if ($error instanceof Exception) {
+            $trace = $error;
+        } else {
+            $trace = debug_backtrace();
+        }
+        $backtrace = new Horde_Support_Backtrace($trace);
+        if (is_object($error) && method_exists($error, 'getMessage')) {
+            $error = $error->getMessage();
+        }
+        $this->writeln($this->red('===================='));
+        $this->writeln();
+        $this->writeln($this->red(_("Fatal Error:")));
+        $this->writeln($this->red($error));
+        $this->writeln();
+        $this->writeln((string)$backtrace);
+        $this->writeln($this->red('===================='));
+    }
+}
\ No newline at end of file
diff --git a/framework/Test/lib/Horde/Test/Stub/Parser.php b/framework/Test/lib/Horde/Test/Stub/Parser.php
new file mode 100644 (file)
index 0000000..3527b09
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+class Horde_Test_Stub_Parser
+extends Horde_Argv_Parser
+{
+    /**
+     * Print a usage message incorporating $msg to stderr and exit.
+     * If you override this in a subclass, it should not return -- it
+     * should either exit or raise an exception.
+     *
+     * @param string $msg
+     */
+    public function parserError($msg)
+    {
+        $this->printUsage();
+        $this->parserExit(2, sprintf("%s: error: %s\n", $this->getProgName(), $msg));
+    }
+
+    public function parserExit($status = 0, $msg = null)
+    {
+        if ($msg) {
+            echo $msg;
+        }
+    }
+}
\ No newline at end of file
index 43c4517..98767aa 100644 (file)
@@ -1,5 +1,5 @@
 <?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">
+<package packagerversion="1.9.1" 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>Test</name>
  <channel>pear.horde.org</channel>
  <summary>Horde testing base classes</summary>
@@ -10,8 +10,8 @@
   <email>chuck@horde.org</email>
   <active>yes</active>
  </lead>
- <date>2010-02-11</date>
- <time>19:46:38</time>
+ <date>2010-12-10</date>
+ <time>05:54:30</time>
  <version>
   <release>0.1.0</release>
   <api>0.1.0</api>
    <dir name="lib">
     <dir name="Horde">
      <dir name="Test">
+      <dir name="Stub">
+       <file name="Cli.php" role="php" />
+       <file name="Parser.php" role="php" />
+      </dir> <!-- /lib/Horde/Test/Stub -->
       <file name="AllTests.php" role="php" />
       <file name="Autoload.php" role="php" />
       <file name="Case.php" role="php" />
@@ -59,6 +63,8 @@
    <install as="Horde/Test/Autoload.php" name="lib/Horde/Test/Autoload.php" />
    <install as="Horde/Test/Case.php" name="lib/Horde/Test/Case.php" />
    <install as="Horde/Test/Functional.php" name="lib/Horde/Test/Functional.php" />
+   <install as="Horde/Test/Stub/Cli.php" name="lib/Horde/Test/Stub/Cli.php" />
+   <install as="Horde/Test/Stub/Parser.php" name="lib/Horde/Test/Stub/Parser.php" />
   </filelist>
  </phprelease>
  <changelog>
@@ -71,7 +77,7 @@
     <release>alpha</release>
     <api>alpha</api>
    </stability>
-   <date>2010-02-11</date>
+   <date>2010-12-10</date>
    <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
    <notes>
 * Initial testing package.