start adding repeater tests independent of horde_date_parser
authorChuck Hagenbuch <chuck@horde.org>
Tue, 3 Feb 2009 22:33:29 +0000 (17:33 -0500)
committerChuck Hagenbuch <chuck@horde.org>
Tue, 3 Feb 2009 22:33:37 +0000 (17:33 -0500)
framework/Date_Parser/test/Horde/Date/AllTests.php [new file with mode: 0644]
framework/Date_Parser/test/Horde/Date/Parser/AllTests.php
framework/Date_Parser/test/Horde/Date/Repeater/DayTest.php [new file with mode: 0644]

diff --git a/framework/Date_Parser/test/Horde/Date/AllTests.php b/framework/Date_Parser/test/Horde/Date/AllTests.php
new file mode 100644 (file)
index 0000000..c68efa6
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+/**
+ * @category   Horde
+ * @package    Date
+ * @subpackage UnitTests
+ * @copyright  2008-2009 The Horde Project (http://www.horde.org/)
+ * @license    http://opensource.org/licenses/bsd-license.php
+ */
+
+if (!defined('PHPUnit_MAIN_METHOD')) {
+    define('PHPUnit_MAIN_METHOD', 'Horde_Date_AllTests::main');
+}
+
+require_once 'PHPUnit/Framework/TestSuite.php';
+require_once 'PHPUnit/TextUI/TestRunner.php';
+
+class Horde_Date_AllTests {
+
+    public static function main()
+    {
+        PHPUnit_TextUI_TestRunner::run(self::suite());
+    }
+
+    public static function suite()
+    {
+        set_include_path(dirname(__FILE__) . '/../../../lib' . PATH_SEPARATOR . get_include_path());
+        if (!spl_autoload_functions()) {
+            spl_autoload_register(create_function('$class', '$filename = str_replace(array(\'::\', \'_\'), \'/\', $class); include "$filename.php";'));
+        }
+
+        $suite = new PHPUnit_Framework_TestSuite('Horde Framework - Horde_Date');
+
+        $basedir = dirname(__FILE__);
+        $baseregexp = preg_quote($basedir . DIRECTORY_SEPARATOR, '/');
+
+        foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($basedir)) as $file) {
+            if ($file->isFile() && preg_match('/Test.php$/', $file->getFilename())) {
+                $pathname = $file->getPathname();
+                require $pathname;
+
+                $class = str_replace(DIRECTORY_SEPARATOR, '_',
+                                     preg_replace("/^$baseregexp(.*)\.php/", '\\1', $pathname));
+                $suite->addTestSuite('Horde_Date_' . $class);
+            }
+        }
+
+        return $suite;
+    }
+
+}
+
+if (PHPUnit_MAIN_METHOD == 'Horde_Date_AllTests::main') {
+    Horde_Date_AllTests::main();
+}
index 051cff5..a4d9c8a 100644 (file)
@@ -23,7 +23,7 @@ class Horde_Date_Parser_AllTests {
 
     public static function suite()
     {
-        set_include_path(dirname(__FILE__) . '/../../../lib' . PATH_SEPARATOR . get_include_path());
+        set_include_path(dirname(__FILE__) . '/../../../../lib' . PATH_SEPARATOR . get_include_path());
         if (!spl_autoload_functions()) {
             spl_autoload_register(create_function('$class', '$filename = str_replace(array(\'::\', \'_\'), \'/\', $class); include "$filename.php";'));
         }
diff --git a/framework/Date_Parser/test/Horde/Date/Repeater/DayTest.php b/framework/Date_Parser/test/Horde/Date/Repeater/DayTest.php
new file mode 100644 (file)
index 0000000..99dfd37
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+/**
+ * @category   Horde
+ * @package    Horde_Date
+ * @subpackage UnitTests
+ */
+
+/**
+ * @category   Horde
+ * @package    Horde_Date
+ * @subpackage UnitTests
+ */
+class Horde_Date_Repeater_DayTest extends PHPUnit_Framework_TestCase
+{
+    public function testNext()
+    {
+        $repeater = new Horde_Date_Repeater_Day();
+        $repeater->now = new Horde_Date('2009-01-01');
+        $this->assertEquals('(2009-01-02 00:00:00..2009-01-03 00:00:00)', (string)$repeater->next('future'));
+    }
+
+}