You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by ch...@apache.org on 2008/08/02 16:11:44 UTC

svn commit: r681982 [26/27] - in /incubator/shindig/trunk/php: external/ external/PHPUnit/ external/PHPUnit/Extensions/ external/PHPUnit/Extensions/Database/ external/PHPUnit/Extensions/Database/Constraint/ external/PHPUnit/Extensions/Database/DB/ exte...

Added: incubator/shindig/trunk/php/external/PHPUnit/Util/TestDox/ResultPrinter.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Util/TestDox/ResultPrinter.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Util/TestDox/ResultPrinter.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Util/TestDox/ResultPrinter.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,350 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   * Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in
+ *     the documentation and/or other materials provided with the
+ *     distribution.
+ *
+ *   * Neither the name of Sebastian Bergmann nor the names of his
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    SVN: $Id: ResultPrinter.php 2144 2008-01-17 10:53:25Z sb $
+ * @link       http://www.phpunit.de/
+ * @since      File available since Release 2.3.0
+ */
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/Util/Filter.php';
+require_once 'PHPUnit/Util/TestDox/NamePrettifier.php';
+require_once 'PHPUnit/Util/Printer.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Base class for printers of TestDox documentation.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    Release: 3.2.9
+ * @link       http://www.phpunit.de/
+ * @since      Class available since Release 2.1.0
+ * @abstract
+ */
+abstract class PHPUnit_Util_TestDox_ResultPrinter extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener
+{
+    /**
+     * @var    PHPUnit_Util_TestDox_NamePrettifier
+     * @access protected
+     */
+    protected $prettifier;
+
+    /**
+     * @var    string
+     * @access protected
+     */
+    protected $testClass = '';
+
+    /**
+     * @var    integer
+     * @access protected
+     */
+    protected $testStatus = FALSE;
+
+    /**
+     * @var    array
+     * @access protected
+     */
+    protected $tests = array();
+
+    protected $successful = 0;
+    protected $failed = 0;
+    protected $skipped = 0;
+    protected $incomplete = 0;
+    protected $testTypeOfInterest = 'PHPUnit_Framework_TestCase';
+
+    /**
+     * @var    string
+     * @access protected
+     */
+    protected $currentTestClassPrettified;
+
+    /**
+     * @var    string
+     * @access protected
+     */
+    protected $currentTestMethodPrettified;
+
+    /**
+     * Constructor.
+     *
+     * @param  resource  $out
+     * @access public
+     */
+    public function __construct($out = NULL)
+    {
+        parent::__construct($out);
+
+        $this->prettifier = new PHPUnit_Util_TestDox_NamePrettifier;
+        $this->startRun();
+    }
+
+    /**
+     * Flush buffer and close output.
+     *
+     * @access public
+     */
+    public function flush()
+    {
+        $this->doEndClass();
+        $this->endRun();
+
+        parent::flush();
+    }
+
+    /**
+     * An error occurred.
+     *
+     * @param  PHPUnit_Framework_Test $test
+     * @param  Exception              $e
+     * @param  float                  $time
+     * @access public
+     */
+    public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
+    {
+        if ($test instanceof $this->testTypeOfInterest) {
+            $this->testStatus = PHPUnit_Runner_BaseTestRunner::STATUS_ERROR;
+            $this->failed++;
+        }
+    }
+
+    /**
+     * A failure occurred.
+     *
+     * @param  PHPUnit_Framework_Test                 $test
+     * @param  PHPUnit_Framework_AssertionFailedError $e
+     * @param  float                                  $time
+     * @access public
+     */
+    public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
+    {
+        if ($test instanceof $this->testTypeOfInterest) {
+            $this->testStatus = PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE;
+            $this->failed++;
+        }
+    }
+
+    /**
+     * Incomplete test.
+     *
+     * @param  PHPUnit_Framework_Test $test
+     * @param  Exception              $e
+     * @param  float                  $time
+     * @access public
+     */
+    public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
+    {
+        if ($test instanceof $this->testTypeOfInterest) {
+            $this->testStatus = PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE;
+            $this->incomplete++;
+        }
+    }
+
+    /**
+     * Skipped test.
+     *
+     * @param  PHPUnit_Framework_Test $test
+     * @param  Exception              $e
+     * @param  float                  $time
+     * @access public
+     * @since  Method available since Release 3.0.0
+     */
+    public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
+    {
+        if ($test instanceof $this->testTypeOfInterest) {
+            $this->testStatus = PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED;
+            $this->skipped++;
+        }
+    }
+
+    /**
+     * A testsuite started.
+     *
+     * @param  PHPUnit_Framework_TestSuite $suite
+     * @access public
+     * @since  Method available since Release 2.2.0
+     */
+    public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
+    {
+    }
+
+    /**
+     * A testsuite ended.
+     *
+     * @param  PHPUnit_Framework_TestSuite $suite
+     * @access public
+     * @since  Method available since Release 2.2.0
+     */
+    public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
+    {
+    }
+
+    /**
+     * A test started.
+     *
+     * @param  PHPUnit_Framework_Test $test
+     * @access public
+     */
+    public function startTest(PHPUnit_Framework_Test $test)
+    {
+        if ($test instanceof $this->testTypeOfInterest) {
+            $class = get_class($test);
+
+            if ($this->testClass != $class) {
+                if ($this->testClass != '') {
+                    $this->doEndClass();
+                }
+
+                $this->currentTestClassPrettified = $this->prettifier->prettifyTestClass($class);
+                $this->startClass($class);
+
+                $this->testClass = $class;
+                $this->tests     = array();
+            }
+
+            $this->currentTestMethodPrettified = $this->prettifier->prettifyTestMethod($test->getName());
+            $this->testStatus                  = PHPUnit_Runner_BaseTestRunner::STATUS_PASSED;
+        }
+    }
+
+    /**
+     * A test ended.
+     *
+     * @param  PHPUnit_Framework_Test $test
+     * @param  float                  $time
+     * @access public
+     */
+    public function endTest(PHPUnit_Framework_Test $test, $time)
+    {
+        if ($test instanceof $this->testTypeOfInterest) {
+            if (!isset($this->tests[$this->currentTestMethodPrettified])) {
+                if ($this->testStatus == PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) {
+                    $this->tests[$this->currentTestMethodPrettified]['success'] = 1;
+                    $this->tests[$this->currentTestMethodPrettified]['failure'] = 0;
+                } else {
+                    $this->tests[$this->currentTestMethodPrettified]['success'] = 0;
+                    $this->tests[$this->currentTestMethodPrettified]['failure'] = 1;
+                }
+            } else {
+                if ($this->testStatus == PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) {
+                    $this->tests[$this->currentTestMethodPrettified]['success']++;
+                } else {
+                    $this->tests[$this->currentTestMethodPrettified]['failure']++;
+                }
+            }
+
+            $this->currentTestClassPrettified  = NULL;
+            $this->currentTestMethodPrettified = NULL;
+        }
+    }
+
+    /**
+     * @access protected
+     * @since  Method available since Release 2.3.0
+     */
+    protected function doEndClass()
+    {
+        foreach ($this->tests as $name => $data) {
+            if ($data['failure'] == 0) {
+                $this->onTest($name);
+            }
+        }
+
+        $this->endClass($this->testClass);
+    }
+
+    /**
+     * Handler for 'start run' event.
+     *
+     * @access protected
+     */
+    protected function startRun()
+    {
+    }
+
+    /**
+     * Handler for 'start class' event.
+     *
+     * @param  string $name
+     * @access protected
+     */
+    protected function startClass($name)
+    {
+    }
+
+    /**
+     * Handler for 'on test' event.
+     *
+     * @param  string $name
+     * @access protected
+     */
+    protected function onTest($name)
+    {
+    }
+
+    /**
+     * Handler for 'end class' event.
+     *
+     * @param  string $name
+     * @access protected
+     */
+    protected function endClass($name)
+    {
+    }
+
+    /**
+     * Handler for 'end run' event.
+     *
+     * @access protected
+     */
+    protected function endRun()
+    {
+    }
+}
+
+require_once 'PHPUnit/Util/TestDox/ResultPrinter/HTML.php';
+require_once 'PHPUnit/Util/TestDox/ResultPrinter/Text.php';
+?>

Added: incubator/shindig/trunk/php/external/PHPUnit/Util/TestDox/ResultPrinter/HTML.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Util/TestDox/ResultPrinter/HTML.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Util/TestDox/ResultPrinter/HTML.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Util/TestDox/ResultPrinter/HTML.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,125 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   * Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in
+ *     the documentation and/or other materials provided with the
+ *     distribution.
+ *
+ *   * Neither the name of Sebastian Bergmann nor the names of his
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    SVN: $Id: HTML.php 2141 2008-01-17 10:49:39Z sb $
+ * @link       http://www.phpunit.de/
+ * @since      File available since Release 2.3.0
+ */
+
+require_once 'PHPUnit/Util/Filter.php';
+require_once 'PHPUnit/Util/TestDox/ResultPrinter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Prints TestDox documentation in HTML format.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    Release: 3.2.9
+ * @link       http://www.phpunit.de/
+ * @since      Class available since Release 2.1.0
+ */
+class PHPUnit_Util_TestDox_ResultPrinter_HTML extends PHPUnit_Util_TestDox_ResultPrinter
+{
+    /**
+     * @var    boolean
+     * @access protected
+     */
+    protected $printsHTML = TRUE;
+
+    /**
+     * Handler for 'start run' event.
+     *
+     * @access protected
+     */
+    protected function startRun()
+    {
+        $this->write('<html><body>');
+    }
+
+    /**
+     * Handler for 'start class' event.
+     *
+     * @param  string $name
+     * @access protected
+     */
+    protected function startClass($name)
+    {
+        $this->write('<h2>' . $name . '</h2><ul>');
+    }
+
+    /**
+     * Handler for 'on test' event.
+     *
+     * @param  string $name
+     * @access protected
+     */
+    protected function onTest($name)
+    {
+        $this->write('<li>' . $name . '</li>');
+    }
+
+    /**
+     * Handler for 'end class' event.
+     *
+     * @param  string $name
+     * @access protected
+     */
+    protected function endClass($name)
+    {
+        $this->write('</ul>');
+    }
+
+    /**
+     * Handler for 'end run' event.
+     *
+     * @access protected
+     */
+    protected function endRun()
+    {
+        $this->write('</body></html>');
+    }
+}
+?>

Added: incubator/shindig/trunk/php/external/PHPUnit/Util/TestDox/ResultPrinter/Text.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Util/TestDox/ResultPrinter/Text.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Util/TestDox/ResultPrinter/Text.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Util/TestDox/ResultPrinter/Text.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,99 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   * Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in
+ *     the documentation and/or other materials provided with the
+ *     distribution.
+ *
+ *   * Neither the name of Sebastian Bergmann nor the names of his
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    SVN: $Id: Text.php 1985 2007-12-26 18:11:55Z sb $
+ * @link       http://www.phpunit.de/
+ * @since      File available since Release 2.3.0
+ */
+
+require_once 'PHPUnit/Util/Filter.php';
+require_once 'PHPUnit/Util/TestDox/ResultPrinter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Prints TestDox documentation in text format.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    Release: 3.2.9
+ * @link       http://www.phpunit.de/
+ * @since      Class available since Release 2.1.0
+ */
+class PHPUnit_Util_TestDox_ResultPrinter_Text extends PHPUnit_Util_TestDox_ResultPrinter
+{
+    /**
+     * Handler for 'start class' event.
+     *
+     * @param  string $name
+     * @access protected
+     */
+    protected function startClass($name)
+    {
+        $this->write($name . "\n");
+    }
+
+    /**
+     * Handler for 'on test' event.
+     *
+     * @param  string $name
+     * @access protected
+     */
+    protected function onTest($name)
+    {
+        $this->write(' - ' . $name . "\n");
+    }
+
+    /**
+     * Handler for 'end class' event.
+     *
+     * @param  string $name
+     * @access protected
+     */
+    protected function endClass($name)
+    {
+        $this->write("\n");
+    }
+}
+?>

Added: incubator/shindig/trunk/php/external/PHPUnit/Util/TestSuiteIterator.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Util/TestSuiteIterator.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Util/TestSuiteIterator.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Util/TestSuiteIterator.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,163 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 
+ *   * Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in
+ *     the documentation and/or other materials provided with the
+ *     distribution.
+ *
+ *   * Neither the name of Sebastian Bergmann nor the names of his
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    SVN: $Id: TestSuiteIterator.php 1985 2007-12-26 18:11:55Z sb $
+ * @link       http://www.phpunit.de/
+ * @since      File available since Release 3.1.0
+ */
+
+require_once 'PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Iterator for test suites.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    Release: 3.2.9
+ * @link       http://www.phpunit.de/
+ * @since      Class available since Release 3.1.0
+ */
+class PHPUnit_Util_TestSuiteIterator implements RecursiveIterator
+{
+    /**
+     * @var    integer
+     * @access protected
+     */
+    protected $position;
+
+    /**
+     * @var    PHPUnit_Framework_Test[]
+     * @access protected
+     */
+    protected $tests;
+
+    /**
+     * Constructor.
+     *
+     * @param  PHPUnit_Framework_TestSuite $suite
+     * @access public
+     */
+    public function __construct(PHPUnit_Framework_TestSuite $testSuite)
+    {
+        $this->tests = $testSuite->tests();
+    }
+
+    /**
+     * Rewinds the Iterator to the first element.
+     *
+     * @access public
+     */
+    public function rewind()
+    {
+        $this->position = 0;
+    }
+
+    /**
+     * Checks if there is a current element after calls to rewind() or next().
+     *
+     * @return boolean
+     * @access public
+     */
+    public function valid()
+    {
+        return $this->position < count($this->tests);
+    }
+
+    /**
+     * Returns the key of the current element.
+     *
+     * @return integer
+     * @access public
+     */
+    public function key()
+    {
+        return $this->position;
+    }
+
+    /**
+     * Returns the current element.
+     *
+     * @return PHPUnit_Framework_Test
+     * @access public
+     */
+    public function current()
+    {
+        return $this->valid() ? $this->tests[$this->position] : NULL;
+    }
+
+    /**
+     * Moves forward to next element.
+     *
+     * @access public
+     */
+    public function next()
+    {
+        $this->position++;
+    }
+
+    /**
+     * Returns the sub iterator for the current element.
+     *
+     * @return PHPUnit_Util_TestSuiteIterator
+     * @access public
+     */
+    public function getChildren()
+    {
+        return new PHPUnit_Util_TestSuiteIterator($this->tests[$this->position]);
+    }
+
+    /**
+     * Checks whether the current element has children.
+     *
+     * @return boolean
+     * @access public
+     */
+    public function hasChildren()
+    {
+        return $this->tests[$this->position] instanceof PHPUnit_Framework_TestSuite;
+    }
+}
+?>

Added: incubator/shindig/trunk/php/external/PHPUnit/Util/Timer.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Util/Timer.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Util/Timer.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Util/Timer.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,136 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   * Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in
+ *     the documentation and/or other materials provided with the
+ *     distribution.
+ *
+ *   * Neither the name of Sebastian Bergmann nor the names of his
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    SVN: $Id: Timer.php 1985 2007-12-26 18:11:55Z sb $
+ * @link       http://www.phpunit.de/
+ * @since      File available since Release 3.0.0
+ */
+
+require_once 'PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Utility class for timing.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    Release: 3.2.9
+ * @link       http://www.phpunit.de/
+ * @since      Class available since Release 3.0.0
+ */
+class PHPUnit_Util_Timer
+{
+    protected static $startTimes = array();
+
+    /**
+     * Starts the timer.
+     *
+     * @access public
+     * @static
+     */
+    public static function start()
+    {
+        array_push(self::$startTimes, microtime(TRUE));
+    }
+
+    /**
+     * Returns the currently elapsed time.
+     *
+     * @return float
+     * @access public
+     * @static
+     */
+    public static function current()
+    {
+        return microtime(TRUE) - self::$startTimes[count(self::$startTimes)-1];
+    }
+
+    /**
+     * Stops the timer and returns the elapsed time.
+     *
+     * @access public
+     * @static
+     */
+    public static function stop()
+    {
+        return microtime(TRUE) - array_pop(self::$startTimes);
+    }
+
+    /**
+     * Formats elapsed time (in seconds) to a string.
+     *
+     * @param  float $time
+     * @return float
+     * @access public
+     * @static
+     */
+    public static function secondsToTimeString($time)
+    {
+        $buffer = '';
+
+        $hours   = sprintf('%02d', ($time >= 3600) ? floor($time / 3600) : 0);
+        $minutes = sprintf('%02d', ($time >= 60)   ? floor($time /   60) - 60 * $hours : 0);
+        $seconds = sprintf('%02d', $time - 60 * 60 * $hours - 60 * $minutes);
+
+        if ($hours == 0 && $minutes == 0) {
+            $seconds = sprintf('%1d', $seconds);
+
+            $buffer .= $seconds . ' second';
+
+            if ($seconds != '1') {
+                $buffer .= 's';
+            }
+        } else {
+            if ($hours > 0) {
+                $buffer = $hours . ':';
+            }
+
+            $buffer .= $minutes . ':' . $seconds;
+        }
+
+        return $buffer;
+    }
+}
+?>

Added: incubator/shindig/trunk/php/external/PHPUnit/Util/Type.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Util/Type.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Util/Type.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Util/Type.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,197 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   * Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in
+ *     the documentation and/or other materials provided with the
+ *     distribution.
+ *
+ *   * Neither the name of Sebastian Bergmann nor the names of his
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    SVN: $Id: Type.php 1985 2007-12-26 18:11:55Z sb $
+ * @link       http://www.phpunit.de/
+ * @since      File available since Release 3.0.0
+ */
+
+require_once 'PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Utility class for textual type (and value) representation.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    Release: 3.2.9
+ * @link       http://www.phpunit.de/
+ * @since      Class available since Release 3.0.0
+ */
+class PHPUnit_Util_Type
+{
+    public static function isType($type)
+    {
+        return in_array(
+          $type,
+          array(
+            'numeric',
+            'integer',
+            'int',
+            'float',
+            'string',
+            'boolean',
+            'bool',
+            'null',
+            'array',
+            'object',
+            'resource'
+          )
+        );
+    }
+
+    public static function shortenedExport($value)
+    {
+        if (is_string($value)) {
+            return self::shortenedString($value);
+        }
+
+        elseif (is_array($value)) {
+            if (count($value) == 0) {
+                return 'array()';
+            }
+
+            $a1 = array_slice($value, 0, 1, TRUE);
+            $k1 = key($a1);
+            $v1 = $a1[$k1];
+
+            if (is_string($v1)) {
+                $v1 = self::shortenedString($v1);
+            }
+
+            elseif (is_array($v1)) {
+                $v1 = 'array(...)';
+            } else {
+                $v1 = self::toString($v1);
+            }
+
+            $a2 = FALSE;
+
+            if (count($value) > 1) {
+                $a2 = array_slice($value, -1, 1, TRUE);
+                $k2 = key($a2);
+                $v2 = $a2[$k2];
+
+                if (is_string($v2)) {
+                    $v2 = self::shortenedString($v2);
+                }
+
+                elseif (is_array($v2)) {
+                    $v2 = 'array(...)';
+                } else {
+                    $v2 = self::toString($v2);
+                }
+            }
+
+            $text = 'array( ' . self::toString($k1) . ' => ' . $v1;
+
+            if ($a2 !== FALSE) {
+                $text .= ', ..., ' . self::toString($k2) . ' => ' . $v2 . ' )';
+            } else {
+                $text .= ' )';
+            }
+
+            return $text;
+        }
+
+        elseif (is_object($value)) {
+            return get_class($value) . '(...)';
+        }
+
+        return self::toString($value);
+    }
+
+    public static function shortenedString($string)
+    {
+        $string = preg_replace('#\n|\r\n|\r#', ' ', $string);
+
+        if (strlen($string) > 14) {
+            return PHPUnit_Util_Type::toString(
+              substr($string, 0, 7) . '...' . substr($string, -7)
+            );
+        } else {
+            return PHPUnit_Util_Type::toString($string);
+        }
+    }
+
+    public static function toString($value, $short = FALSE)
+    {
+        if (is_array($value) || is_object($value)) {
+            if (!$short) {
+                return "\n" . print_r($value, TRUE);
+            } else {
+                if (is_array($value)) {
+                    return '<array>';
+                } else {
+                    return '<' . get_class($value) . '>';
+                }
+            }
+        }
+
+        if (is_string($value) && strpos($value, "\n") !== FALSE) {
+            return '<text>';
+        }
+
+        if (!is_null($value)) {
+            $type = gettype($value) . ':';
+        } else {
+            $type  = '';
+            $value = 'null';
+        }
+
+        if (is_bool($value)) {
+            if ($value === TRUE) {
+                $value = 'true';
+            }
+
+            else if ($value === FALSE) {
+                $value = 'false';
+            }
+        }
+
+        return '<' . $type . $value . '>';
+    }
+}
+?>

Added: incubator/shindig/trunk/php/external/PHPUnit/Util/XML.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Util/XML.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Util/XML.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Util/XML.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,106 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   * Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in
+ *     the documentation and/or other materials provided with the
+ *     distribution.
+ *
+ *   * Neither the name of Sebastian Bergmann nor the names of his
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    SVN: $Id: XML.php 1985 2007-12-26 18:11:55Z sb $
+ * @link       http://www.phpunit.de/
+ * @since      File available since Release 3.2.0
+ */
+
+require_once 'PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * XML helpers.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    Release: 3.2.9
+ * @link       http://www.phpunit.de/
+ * @since      Class available since Release 3.2.0
+ */
+class PHPUnit_Util_XML
+{
+    public static function load($filename, $html = FALSE)
+    {
+        $document = new DOMDocument;
+
+        if (is_readable($filename)) {
+            libxml_use_internal_errors(TRUE);
+
+            if (!$html) {
+                $loaded = @$document->load($filename);
+            } else {
+                $loaded = @$document->loadHTMLFile($filename);
+            }
+
+            if ($loaded === FALSE) {
+                $message = '';
+
+                foreach (libxml_get_errors() as $error) {
+                    $message .= $error->message;
+                }
+
+                throw new RuntimeException(
+                  sprintf(
+                    'Could not load "%s".%s',
+
+                    $filename,
+                    $message != '' ? "\n" . $message : ''
+                  )
+                );
+            }
+        } else {
+            throw new RuntimeException(
+              sprintf(
+                'Could not read "%s".',
+                $filename
+              )
+            );
+        }
+
+        return $document;
+    }
+}
+?>

Added: incubator/shindig/trunk/php/test/common/CacheFileTest.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/common/CacheFileTest.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/common/CacheFileTest.php (added)
+++ incubator/shindig/trunk/php/test/common/CacheFileTest.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,83 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+require_once 'config.php';
+require_once 'src/common/Cache.php';
+require_once 'src/common/CacheFile.php';
+require_once 'PHPUnit/Framework/TestCase.php';
+
+/**
+ * CacheFile test case.
+ */
+class CacheFileTest extends PHPUnit_Framework_TestCase {
+	
+	/**
+	 * @var CacheFile
+	 */
+	private $CacheFile;
+
+	/**
+	 * Prepares the environment before running a test.
+	 */
+	protected function setUp()
+	{
+		parent::setUp();
+		$this->CacheFile = new CacheFile(/* parameters */);
+	}
+
+	/**
+	 * Cleans up the environment after running a test.
+	 */
+	protected function tearDown()
+	{
+		$this->CacheFile = null;
+		parent::tearDown();
+	}
+
+	/**
+	 * Tests CacheFile->delete()
+	 */
+	public function testDelete()
+	{
+		$cache = new CacheFile();
+		$cache->set("test", "testing");
+		$cache->delete("test");
+		$this->assertEquals("", $cache->get("test"));
+	}
+
+	/**
+	 * Tests CacheFile->get()
+	 */
+	public function testGet()
+	{	
+		$this->CacheFile->set("test", "testing");	
+		$this->assertEquals("testing", $this->CacheFile->get("test"));
+	}
+
+	/**
+	 * Tests CacheFile->set()
+	 */
+	public function testSet()
+	{
+		$this->CacheFile->set("test", "testing");	
+		$this->assertEquals("testing", $this->CacheFile->get("test"));
+	}
+
+}
\ No newline at end of file

Added: incubator/shindig/trunk/php/test/common/HttpServletTest.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/common/HttpServletTest.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/common/HttpServletTest.php (added)
+++ incubator/shindig/trunk/php/test/common/HttpServletTest.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,133 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+require_once 'src/common/HttpServlet.php';
+require_once 'PHPUnit/Framework/TestCase.php';
+
+/**
+ * HttpServlet test case.
+ */
+class HttpServletTest extends PHPUnit_Framework_TestCase {
+	
+	/**
+	 * @var HttpServlet
+	 */
+	private $HttpServlet;
+	
+	private $cacheTime = 60;
+	private $contentType1 = "text/html";
+	private $contentType2 = "text/javascript";
+	private $lastModified = 500;
+	private $noCache = false;
+	public $contentType = 'utf-8';
+
+	/**
+	 * Prepares the environment before running a test.
+	 */
+	protected function setUp()
+	{
+		parent::setUp();
+		$this->HttpServlet = new HttpServlet(/* parameters */);
+		
+		$this->HttpServlet->setLastModified($this->lastModified);
+		$this->HttpServlet->setNoCache($this->noCache);
+		$this->HttpServlet->setContentType($this->contentType);
+		$this->HttpServlet->setCacheTime($this->cacheTime);
+	}
+
+	/**
+	 * Cleans up the environment after running a test.
+	 */
+	
+	protected function tearDown()
+	{
+		$this->HttpServlet = null;
+		parent::tearDown();
+	}
+
+	/**
+	 * Tests HttpServlet->getCacheTime()
+	 */
+	public function testGetCacheTime()
+	{
+		$this->assertEquals($this->cacheTime, $this->HttpServlet->getCacheTime());
+	}
+
+	/**
+	 * Tests HttpServlet->getContentType()
+	 */
+	public function testGetContentType()
+	{
+		$this->assertEquals($this->contentType, $this->HttpServlet->getContentType());
+	}
+
+	/**
+	 * Tests HttpServlet->getLastModified()
+	 */
+	public function testGetLastModified()
+	{
+		$this->assertEquals($this->lastModified, $this->HttpServlet->getLastModified());
+	}
+
+	/**
+	 * Tests HttpServlet->getNoCache()
+	 */
+	public function testGetNoCache()
+	{
+		$this->assertEquals($this->noCache, $this->HttpServlet->getNoCache());
+	}
+
+	/**
+	 * Tests HttpServlet->setCacheTime()
+	 */
+	public function testSetCacheTime()
+	{
+		$this->HttpServlet->setCacheTime($this->cacheTime + 100);
+		$this->assertEquals($this->cacheTime + 100, $this->HttpServlet->getCacheTime());
+	}
+
+	/**
+	 * Tests HttpServlet->setContentType()
+	 */
+	public function testSetContentType()
+	{
+		$this->HttpServlet->setContentType($this->contentType2);
+		$this->assertNotEquals($this->contentType1, $this->HttpServlet->getContentType());
+	}
+
+	/**
+	 * Tests HttpServlet->setLastModified()
+	 */
+	public function testSetLastModified()
+	{
+		$this->HttpServlet->setLastModified($this->lastModified + 100);
+		$this->assertEquals($this->lastModified + 100, $this->HttpServlet->getLastModified());
+	}
+
+	/**
+	 * Tests HttpServlet->setNoCache()
+	 */
+	public function testSetNoCache()
+	{
+		$this->HttpServlet->setNoCache(! $this->noCache);
+		$this->assertNotEquals($this->noCache, $this->HttpServlet->getNoCache());
+	}
+
+}
\ No newline at end of file

Added: incubator/shindig/trunk/php/test/common/UrlGeneratorTest.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/common/UrlGeneratorTest.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/common/UrlGeneratorTest.php (added)
+++ incubator/shindig/trunk/php/test/common/UrlGeneratorTest.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,101 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+require_once 'src/common/UrlGenerator.php';
+require_once 'src/common/Locale.php';
+require_once 'src/gadgets/Substitutions.php';
+require_once 'src/gadgets/UserPrefs.php';
+require_once 'src/gadgets/ViewSpec.php';
+require_once 'src/gadgets/HttpUtil.php';
+require_once 'src/gadgets/GadgetException.php';
+require_once 'src/gadgets/Gadget.php';
+require_once 'src/gadgets/GadgetContext.php';
+require_once 'PHPUnit/Framework/TestCase.php';
+
+/**
+ * UrlGenerator test case.
+ */
+class UrlGeneratorTest extends PHPUnit_Framework_TestCase {
+	
+	private $UrlGenerator;
+	private $context;
+	private $gadget;
+	private $gadgetXML;
+
+	protected function setUp()
+	{
+		parent::setUp();
+		
+		$this->gadgetXML = simplexml_load_string('<?xml version="1.0" encoding="UTF-8" ?>
+<Module>
+  <ModulePrefs title="Test" />
+  <Content type="html">
+  <![CDATA[
+    <h1>Hello, test case!</h1>
+  ]]>
+  </Content>
+</Module>');
+		
+		$this->UrlGenerator = new UrlGenerator(/* parameters */);
+		$this->context = new GadgetContext('GADGET');
+		$this->gadget = new Gadget(false, $this->context);
+		$this->gadget->views = array(
+				DEFAULT_VIEW => new ViewSpec('test', $this->gadgetXML->Content));
+	
+	}
+
+	/**
+	 * Cleans up the environment after running a test.
+	 */
+	protected function tearDown()
+	{
+		
+		$this->UrlGenerator = null;
+		$this->context = null;
+		$this->gadget = null;
+		
+		parent::tearDown();
+	}
+
+	public function testGetIframeURL()
+	{
+		
+		$uri = UrlGenerator::getIframeURL($this->gadget, $this->context);
+		
+		$query = parse_url($uri, PHP_URL_QUERY);
+		
+		$query = explode('&', $query);
+		
+		$args = array();
+		
+		foreach ($query as $param) {
+			$param = explode('=', $param);
+			list($key, $value) = $param;
+			$args[$key] = $value ? $value : '';
+		}
+		
+		$this->assertArrayHasKey('container', $args);
+		$this->assertArrayHasKey('lang', $args);
+		$this->assertArrayHasKey('country', $args);
+		$this->assertArrayHasKey('view', $args);
+		$this->assertArrayHasKey('url', $args);
+	}
+
+}

Added: incubator/shindig/trunk/php/test/gadgets/GadgetContextTest.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/gadgets/GadgetContextTest.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/gadgets/GadgetContextTest.php (added)
+++ incubator/shindig/trunk/php/test/gadgets/GadgetContextTest.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,231 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ * 
+ */
+
+require_once 'src/gadgets/GadgetContext.php';
+require_once 'PHPUnit/Framework/TestCase.php';
+
+require_once 'src/gadgets/GadgetId.php';
+require_once 'config.php';
+require_once 'src/common/Cache.php';
+require_once 'src/common/CacheFile.php';
+require_once 'src/gadgets/samplecontainer/BasicGadgetBlacklist.php';
+require_once 'src/common/RemoteContent.php';
+require_once 'src/common/samplecontainer/BasicRemoteContent.php';
+require_once 'src/gadgets/UserPrefs.php';
+require_once 'src/common/Locale.php';
+require_once 'src/gadgets/JsFeatureLoader.php';
+require_once 'src/gadgets/GadgetFeatureRegistry.php';
+
+/**
+ * GadgetContext test case.
+ */
+class GadgetContextTest extends PHPUnit_Framework_TestCase {
+	
+	/**
+	 * @var GadgetContext
+	 */
+	private $GadgetContext;
+	
+	/**
+	 * @var testData
+	 */
+	private $testData = array('url' => 'http://www.google.com/gadget', 'libs' => '', 
+			'synd' => 'default', 'nocache' => '', 'container' => 'default', 'view' => 'default', 
+			'mid' => '123', 'bcp' => '');
+	
+	/**
+	 * @var gadgetRenderingContext
+	 */
+	private $gadgetRenderingContext = 'GADGET';
+
+	/**
+	 * Prepares the environment before running a test.
+	 */
+	protected function setUp()
+	{
+		parent::setUp();
+		
+		$_GET = $this->testData;
+		$this->GadgetContext = new GadgetContext($this->gadgetRenderingContext);
+	
+	}
+
+	/**
+	 * Cleans up the environment after running a test.
+	 */
+	protected function tearDown()
+	{
+		$this->GadgetContext = null;
+		
+		parent::tearDown();
+	}
+
+	/**
+	 * Tests GadgetContext->getBlacklist()
+	 */
+	public function testGetBlacklist()
+	{
+		$this->assertTrue(is_object($this->GadgetContext->getBlackList()));
+	
+	}
+
+	/**
+	 * Tests GadgetContext->getCache()
+	 */
+	public function testGetCache()
+	{
+		$this->assertTrue(is_object($this->GadgetContext->getCache()));
+	
+	}
+
+	/**
+	 * Tests GadgetContext->getContainer()
+	 */
+	public function testGetContainer()
+	{
+		$this->assertEquals($this->testData['container'], $this->GadgetContext->getContainer());
+	
+	}
+
+	/**
+	 * Tests GadgetContext->getForcedJsLibs()
+	 */
+	public function testGetForcedJsLibs()
+	{
+		$this->assertEquals($this->testData['libs'], $this->GadgetContext->getForcedJsLibs());
+	
+	}
+
+	/**
+	 * Tests GadgetContext->getGadgetId()
+	 */
+	public function testGetGadgetId()
+	{
+		$this->assertNotNull($this->GadgetContext->getGadgetId());
+	
+	}
+
+	/**
+	 * Tests GadgetContext->getHttpFetcher()
+	 */
+	public function testGetHttpFetcher()
+	{
+		$this->assertNotNull($this->GadgetContext->getHttpFetcher());
+	
+	}
+
+	/**
+	 * Tests GadgetContext->getLocale()
+	 */
+	public function testGetLocale()
+	{
+		$this->assertNotNull($this->GadgetContext->getLocale());
+	
+	}
+
+	/**
+	 * Tests GadgetContext->getModuleId()
+	 */
+	public function testGetModuleId()
+	{
+		$this->assertEquals($this->testData['mid'], $this->GadgetContext->getModuleId());
+	
+	}
+
+	/**
+	 * Tests GadgetContext->getRegistry()
+	 */
+	public function testGetRegistry()
+	{
+		$this->assertNotNull($this->GadgetContext->getRegistry());
+	
+	}
+
+	/**
+	 * Tests GadgetContext->getRenderingContext()
+	 */
+	public function testGetRenderingContext()
+	{
+		$this->assertEquals($this->gadgetRenderingContext, $this->GadgetContext->getRenderingContext());
+	
+	}
+
+	/**
+	 * Tests GadgetContext->getUrl()
+	 */
+	public function testGetUrl()
+	{
+		$this->assertEquals($this->testData['url'], $this->GadgetContext->getUrl());
+	
+	}
+
+	/**
+	 * Tests GadgetContext->getUserPrefs()
+	 */
+	public function testGetUserPrefs()
+	{
+		$this->assertNotNull($this->GadgetContext->getUserPrefs());
+	
+	}
+
+	/**
+	 * Tests GadgetContext->getView()
+	 */
+	public function testGetView()
+	{
+		$this->assertEquals($this->testData['view'], $this->GadgetContext->getView());
+	
+	}
+
+	/**
+	 * Tests GadgetContext->setRenderingContext()
+	 */
+	public function testSetRenderingContext()
+	{
+		$redering_context = 'Dummie_rendering_context';
+		$this->GadgetContext->setRenderingContext($redering_context);
+		$this->assertAttributeEquals($redering_context, 'renderingContext', $this->GadgetContext);
+	
+	}
+
+	/**
+	 * Tests GadgetContext->setUrl()
+	 */
+	public function testSetUrl()
+	{
+		$url = 'Dummie_url';
+		$this->GadgetContext->setUrl($url);
+		$this->assertAttributeEquals($url, 'url', $this->GadgetContext);
+	
+	}
+
+	/**
+	 * Tests GadgetContext->setView()
+	 */
+	public function testSetView()
+	{
+		$view = 'Dummie_view';
+		$this->GadgetContext->setView($view);
+		$this->assertAttributeEquals($view, 'view', $this->GadgetContext);
+	
+	}
+
+}
+

Added: incubator/shindig/trunk/php/test/gadgets/GadgetIdTest.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/gadgets/GadgetIdTest.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/gadgets/GadgetIdTest.php (added)
+++ incubator/shindig/trunk/php/test/gadgets/GadgetIdTest.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,93 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ * 
+ */
+
+require_once 'src/gadgets/GadgetId.php';
+
+require_once 'PHPUnit/Framework/TestCase.php';
+
+/**
+ * GadgetId test case.
+ */
+class GadgetIdTest extends PHPUnit_Framework_TestCase {
+	
+	/**
+	 * @var GadgetId
+	 */
+	private $GadgetId = 'ID';
+	
+	/**
+	 * 
+	 * @var uri
+	 */
+	private $uri = 'http://www.example.com/xml.xml';
+	
+	/**
+	 *
+	 * @var moduleId
+	 */
+	private $moduleId = 'MID';
+
+	/**
+	 * Prepares the environment before running a test.
+	 */
+	protected function setUp()
+	{
+		parent::setUp();
+		$this->GadgetId = new GadgetId($this->uri, $this->moduleId);
+	
+	}
+
+	/**
+	 * Cleans up the environment after running a test.
+	 */
+	protected function tearDown()
+	{
+		$this->GadgetId = null;
+		
+		parent::tearDown();
+	}
+
+	/**
+	 * Tests GadgetId->getKey()
+	 */
+	public function testGetKey()
+	{
+		$this->assertEquals($this->uri, $this->GadgetId->getKey());
+	}
+
+	/**
+	 * Tests GadgetId->getModuleId()
+	 */
+	public function testGetModuleId()
+	{
+		$this->assertEquals($this->moduleId, $this->GadgetId->getModuleId());
+	}
+
+	/**
+	 * Tests GadgetId->getURI()
+	 */
+	public function testGetURI()
+	{
+		$this->assertEquals($this->uri, $this->GadgetId->getURI());
+	
+	}
+
+}
+

Added: incubator/shindig/trunk/php/test/gadgets/GadgetServerTest.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/gadgets/GadgetServerTest.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/gadgets/GadgetServerTest.php (added)
+++ incubator/shindig/trunk/php/test/gadgets/GadgetServerTest.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,63 @@
+<?php
+
+require_once 'src/gadgets/GadgetException.php';
+require_once 'src/gadgets/GadgetServer.php';
+require_once 'src/gadgets/GadgetContext.php';
+
+require_once 'src/common/RemoteContentFetcher.php';
+require_once 'src/common/RemoteContentRequest.php';
+require_once 'src/gadgets/JsFeatureLoader.php';
+require_once 'src/gadgets/GadgetFeatureRegistry.php';
+require_once 'src/gadgets/JsLibrary.php';
+require_once 'src/gadgets/GadgetFeatureFactory.php';
+require_once 'src/gadgets/GadgetFeature.php';
+require_once 'src/gadgets/JsLibraryFeatureFactory.php';
+
+require_once 'src/common/samplecontainer/BasicRemoteContentFetcher.php';
+
+require_once 'PHPUnit/Framework/TestCase.php';
+
+/**
+ * GadgetServer test case.
+ */
+class GadgetServerTest extends PHPUnit_Framework_TestCase {
+	
+	/**
+	 * @var GadgetServer
+	 */
+	private $GadgetServer;
+
+	/**
+	 * Prepares the environment before running a test.
+	 */
+	protected function setUp()
+	{
+		parent::setUp();
+		$this->GadgetServer = new GadgetServer();
+	}
+
+	/**
+	 * Cleans up the environment after running a test.
+	 */
+	protected function tearDown()
+	{
+		$this->GadgetServer = null;
+		parent::tearDown();
+	}
+
+	/**
+	 * Tests GadgetServer->processGadget()
+	 */
+	public function testProcessGadget()
+	{
+		
+		$GadgetContext = new GadgetContext('GADGET');
+		$GadgetContext->setUrl('http://' . $_SERVER["HTTP_HOST"] . Config::get('web_prefix') . '/test/gadgets/example.xml');
+		
+		$gadget = $this->GadgetServer->processGadget($GadgetContext);
+		
+		$this->assertTrue($gadget instanceof Gadget);
+	
+	}
+
+}

Added: incubator/shindig/trunk/php/test/gadgets/GadgetSpecParserTest.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/gadgets/GadgetSpecParserTest.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/gadgets/GadgetSpecParserTest.php (added)
+++ incubator/shindig/trunk/php/test/gadgets/GadgetSpecParserTest.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,95 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ * 
+ */
+
+require_once 'src/gadgets/GadgetSpecParser.php';
+require_once 'PHPUnit/Framework/TestCase.php';
+
+require_once 'src/gadgets/Gadget.php';
+require_once 'src/gadgets/ViewSpec.php';
+
+/**
+ * GadgetSpecParser test case.
+ */
+class GadgetSpecParserTest extends PHPUnit_Framework_TestCase {
+	
+	/**
+	 * @var GadgetSpecParser
+	 */
+	private $GadgetSpecParser;
+	
+	/**
+	 * @var Gadget
+	 */
+	private $Gadget = '<?xml version="1.0" encoding="UTF-8" ?>
+<Module>
+  <ModulePrefs title="Test" />
+  <Content type="html">
+  <![CDATA[
+    <h1>Hello, world!</h1>
+  ]]>
+  </Content>
+</Module>';
+	
+	/**
+	 * @var Context
+	 */
+	private $Context;
+
+	/**
+	 * Prepares the environment before running a test.
+	 */
+	protected function setUp()
+	{
+		parent::setUp();
+		
+		$this->GadgetSpecParser = new GadgetSpecParser();
+		$this->Context = new GadgetContext('GADGET');
+	}
+
+	/**
+	 * Cleans up the environment after running a test.
+	 */
+	protected function tearDown()
+	{
+		$this->GadgetSpecParser = null;
+		
+		parent::tearDown();
+	}
+
+	/**
+	 * Tests GadgetSpecParser->parse()
+	 */
+	public function testParseExeption()
+	{
+		$this->setExpectedException('SpecParserException');
+		$this->assertTrue($this->GadgetSpecParser->parse('', $this->Context));
+	}
+
+	/**
+	 * Tests GadgetSpecParser->parse()
+	 */
+	public function testParse()
+	{
+		$gadgetParsed = $this->GadgetSpecParser->parse($this->Gadget, $this->Context);
+		$views = $gadgetParsed->getViews();
+		$this->assertEquals('<h1>Hello, world!</h1>', trim($views[DEFAULT_VIEW]->getContent()));
+	}
+}
+

Added: incubator/shindig/trunk/php/test/gadgets/GadgetTest.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/gadgets/GadgetTest.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/gadgets/GadgetTest.php (added)
+++ incubator/shindig/trunk/php/test/gadgets/GadgetTest.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,523 @@
+<?php
+
+require_once 'src/gadgets/GadgetContext.php';
+require_once 'src/gadgets/UserPrefs.php';
+require_once 'src/gadgets/Substitutions.php';
+
+require_once 'src/gadgets/Gadget.php';
+
+require_once 'PHPUnit/Framework/TestCase.php';
+
+/**
+ * Gadget test case.
+ */
+class GadgetTest extends PHPUnit_Framework_TestCase {
+	
+	/**
+	 * @var Gadget
+	 */
+	private $Gadget;
+	private $context;
+
+	/**
+	 * Prepares the environment before running a test.
+	 */
+	protected function setUp()
+	{
+		parent::setUp();
+		
+		$this->context = new GadgetContext('GADGET');
+		$this->Gadget = new Gadget(false, $this->context);
+	
+	}
+
+	/**
+	 * Cleans up the environment after running a test.
+	 */
+	protected function tearDown()
+	{
+		
+		$this->Gadget = null;
+		
+		parent::tearDown();
+	}
+
+	/**
+	 * Tests Gadget->addJsLibrary()
+	 */
+	public function testAddJsLibrary()
+	{
+		
+		$this->Gadget->addJsLibrary('A');
+		$this->Gadget->addJsLibrary('B');
+		$this->Gadget->addJsLibrary('C');
+		$this->Gadget->addJsLibrary('D');
+		
+		$string = implode('', $this->Gadget->getJsLibraries());
+		
+		$this->assertEquals($string, 'ABCD');
+	
+	}
+
+	/**
+	 * Tests Gadget->getAuthor()
+	 */
+	public function testGetAuthor()
+	{
+		
+		$this->Gadget->author = 'authorTest';
+		
+		$this->assertEquals('authorTest', $this->Gadget->getAuthor());
+	
+	}
+
+	/**
+	 * Tests Gadget->getAuthorAboutme()
+	 */
+	public function testGetAuthorAboutme()
+	{
+		
+		$this->Gadget->authorAboutMe = 'authorAboutMeTest';
+		
+		$this->assertEquals('authorAboutMeTest', $this->Gadget->getAuthorAboutme());
+	
+	}
+
+	/**
+	 * Tests Gadget->getAuthorAffiliation()
+	 */
+	public function testGetAuthorAffiliation()
+	{
+		
+		$this->Gadget->authorAffiliation = 'authorAffiliation';
+		
+		$this->assertEquals('authorAffiliation', $this->Gadget->getAuthorAffiliation());
+	
+	}
+
+	/**
+	 * Tests Gadget->getAuthorEmail()
+	 */
+	public function testGetAuthorEmail()
+	{
+		
+		$this->Gadget->authorEmail = 'authorEmail';
+		
+		$this->assertEquals('authorEmail', $this->Gadget->getAuthorEmail());
+	
+	}
+
+	/**
+	 * Tests Gadget->getAuthorLink()
+	 */
+	public function testGetAuthorLink()
+	{
+		$this->Gadget->authorLink = 'authorLink';
+		$this->assertEquals('authorLink', $this->Gadget->getAuthorLink());
+	}
+
+	/**
+	 * Tests Gadget->getAuthorLocation()
+	 */
+	public function testGetAuthorLocation()
+	{
+		$this->Gadget->authorLocation = 'authorLocation';	
+		$this->assertEquals('authorLocation', $this->Gadget->getAuthorLocation());
+	}
+
+	/**
+	 * Tests Gadget->getAuthorPhoto()
+	 */
+	public function testGetAuthorPhoto()
+	{
+		$this->Gadget->authorPhoto = 'authorPhoto';	
+		$this->assertEquals('authorPhoto', $this->Gadget->getAuthorPhoto());
+	}
+
+	/**
+	 * Tests Gadget->getAuthorQuote()
+	 */
+	public function testGetAuthorQuote()
+	{
+		
+		$this->Gadget->authorQuote = 'authorQuote';
+		
+		$this->assertEquals('authorQuote', $this->Gadget->getAuthorQuote());
+	
+	}
+
+	/**
+	 * Tests Gadget->getCategory()
+	 */
+	public function testGetCategory()
+	{
+		
+		$this->Gadget->category = 'category';
+		
+		$this->assertEquals('category', $this->Gadget->getCategory());
+	
+	}
+
+	/**
+	 * Tests Gadget->getCategory2()
+	 */
+	public function testGetCategory2()
+	{
+		
+		$this->Gadget->category2 = 'category2';
+		
+		$this->assertEquals('category2', $this->Gadget->getCategory2());
+	
+	}
+
+	/**
+	 * Tests Gadget->getDescription()
+	 */
+	public function testGetDescription()
+	{
+		
+		$this->Gadget->description = 'description';
+		
+		$this->assertEquals('description', $this->Gadget->getDescription());
+	
+	}
+
+	/**
+	 * Tests Gadget->getDirectoryTitle()
+	 */
+	public function testGetDirectoryTitle()
+	{
+		
+		$this->Gadget->directoryTitle = 'directoryTitle';
+		
+		$this->assertEquals('directoryTitle', $this->Gadget->getDirectoryTitle());
+	
+	}
+
+	/**
+	 * Tests Gadget->getHeight()
+	 */
+	public function testGetHeight()
+	{
+		
+		$this->Gadget->height = 'height';
+		
+		$this->assertEquals('height', $this->Gadget->getHeight());
+	
+	}
+
+	/**
+	 * Tests Gadget->getId()
+	 */
+	public function testGetId()
+	{
+		
+		$this->Gadget->id = 'id';
+		
+		$this->assertEquals('id', $this->Gadget->getId());
+	
+	}
+
+	/**
+	 * Tests Gadget->getJsLibraries()
+	 */
+	public function testGetJsLibraries()
+	{
+		
+		$this->Gadget->addJsLibrary('A');
+		$this->Gadget->addJsLibrary('B');
+		$this->Gadget->addJsLibrary('C');
+		$this->Gadget->addJsLibrary('D');
+		
+		$string = implode('', $this->Gadget->getJsLibraries());
+		
+		$this->assertEquals('ABCD', $string);
+	
+	}
+
+	/**
+	 * Tests Gadget->getLocaleSpecs()
+	 */
+	public function testGetLocaleSpecs()
+	{
+		
+		$this->Gadget->localeSpecs = 'localeSpecs';
+		
+		$this->assertEquals('localeSpecs', $this->Gadget->getLocaleSpecs());
+	
+	}
+
+	/**
+	 * Tests Gadget->getMessageBundle()
+	 */
+	public function testGetMessageBundle()
+	{
+		
+		$this->Gadget->setMessageBundle('messageBundle');
+		
+		$this->assertEquals('messageBundle', $this->Gadget->getMessageBundle());
+	
+	}
+
+	/**
+	 * Tests Gadget->getPreloads()
+	 */
+	public function testGetPreloads()
+	{
+		
+		$this->Gadget->preloads = array(0 => 'A', 1 => 'B');
+		
+		$this->assertEquals(array(0 => 'A', 1 => 'B'), $this->Gadget->getPreloads());
+	
+	}
+
+	/**
+	 * Tests Gadget->getRenderInline()
+	 */
+	public function testGetRenderInline()
+	{
+		
+		$this->Gadget->renderInline = true;
+		
+		$this->assertTrue($this->Gadget->getRenderInline());
+	
+	}
+
+	/**
+	 * Tests Gadget->getRequires()
+	 */
+	public function testGetRequires()
+	{
+		
+		$this->Gadget->requires = 'requires';
+		
+		$this->assertEquals('requires', $this->Gadget->getRequires());
+	
+	}
+
+	/**
+	 * Tests Gadget->getScaling()
+	 */
+	public function testGetScaling()
+	{
+		
+		$this->Gadget->scaling = true;
+		
+		$this->assertTrue($this->Gadget->getScaling());
+	
+	}
+
+	/**
+	 * Tests Gadget->getScreenshot()
+	 */
+	public function testGetScreenshot()
+	{
+		
+		$this->Gadget->screenshot = 'screenshot';
+		
+		$this->assertEquals('screenshot', $this->Gadget->getScreenshot());
+	
+	}
+
+	/**
+	 * Tests Gadget->getScrolling()
+	 */
+	public function testGetScrolling()
+	{
+		
+		$this->Gadget->scrolling = true;
+		
+		$this->assertTrue($this->Gadget->getScrolling());
+	
+	}
+
+	/**
+	 * Tests Gadget->getShowInDirectory()
+	 */
+	public function testGetShowInDirectory()
+	{
+		
+		$this->Gadget->showInDirectory = true;
+		
+		$this->assertTrue($this->Gadget->getShowInDirectory());
+	
+	}
+
+	/**
+	 * Tests Gadget->getShowStats()
+	 */
+	public function testGetShowStats()
+	{
+		
+		$this->Gadget->showStats = true;
+		
+		$this->assertTrue($this->Gadget->getShowStats());
+	
+	}
+
+	/**
+	 * Tests Gadget->getSingleton()
+	 */
+	public function testGetSingleton()
+	{
+		
+		$this->Gadget->singleton = 'singleton';
+		
+		$this->assertEquals('singleton', $this->Gadget->getSingleton());
+	
+	}
+
+	/**
+	 * Tests Gadget->getString()
+	 */
+	public function testGetString()
+	{
+		
+		$this->Gadget->string = 'string';
+		
+		$this->assertEquals('string', $this->Gadget->getString());
+	
+	}
+
+	/**
+	 * Tests Gadget->getSubstitutions()
+	 */
+	public function testGetSubstitutions()
+	{
+		
+		$this->assertTrue($this->Gadget->getSubstitutions() instanceof Substitutions);
+	
+	}
+
+	/**
+	 * Tests Gadget->getThumbnail()
+	 */
+	public function testGetThumbnail()
+	{
+		
+		$this->Gadget->thumbnail = 'thumbnail';
+		
+		$this->assertEquals('thumbnail', $this->Gadget->getThumbnail());
+	
+	}
+
+	/**
+	 * Tests Gadget->getTitle()
+	 */
+	public function testGetTitle()
+	{
+		
+		$this->Gadget->title = 'title';
+		
+		$this->assertEquals('title', $this->Gadget->getTitle());
+	
+	}
+
+	/**
+	 * Tests Gadget->getTitleUrl()
+	 */
+	public function testGetTitleUrl()
+	{
+		
+		$this->Gadget->titleUrl = 'titleUrl';
+		
+		$this->assertEquals('titleUrl', $this->Gadget->getTitleUrl());
+	
+	}
+
+	/**
+	 * Tests Gadget->getUserPrefs()
+	 */
+	public function testGetUserPrefs()
+	{
+		
+		$this->Gadget->userPrefs = array(0 => 'A', 1 => 'B');
+		
+		$this->assertEquals(array(0 => 'A', 1 => 'B'), $this->Gadget->getUserPrefs());
+	
+	}
+
+	/**
+	 * Tests Gadget->getUserPrefValues()
+	 */
+	public function testGetUserPrefValues()
+	{
+		
+		$this->Gadget->setPrefs(array(0 => 'A', 1 => 'B'));
+		
+		$this->assertEquals(array(0 => 'A', 1 => 'B'), $this->Gadget->getUserPrefValues());
+	
+	}
+
+	/**
+	 * Tests Gadget->getView()
+	 */
+	public function testGetView()
+	{
+		
+		$this->Gadget->views = array(0 => 'A', 1 => 'B');
+		
+		$this->assertEquals('B', $this->Gadget->getView(1));
+	
+	}
+
+	/**
+	 * Tests Gadget->getViews()
+	 */
+	public function testGetViews()
+	{
+		
+		$this->Gadget->views = array(0 => 'A', 1 => 'B');
+		
+		$this->assertEquals(array(0 => 'A', 1 => 'B'), $this->Gadget->getViews());
+	
+	}
+
+	/**
+	 * Tests Gadget->getWidth()
+	 */
+	public function testGetWidth()
+	{
+		
+		$this->Gadget->width = 100;
+		
+		$this->assertEquals(100, $this->Gadget->getWidth());
+	
+	}
+
+	/**
+	 * Tests Gadget->setId()
+	 */
+	public function testSetId()
+	{
+		
+		$this->Gadget->setId('id');
+		
+		$this->assertEquals('id', $this->Gadget->id);
+	
+	}
+
+	/**
+	 * Tests Gadget->setMessageBundle()
+	 */
+	public function testSetMessageBundle()
+	{
+		
+		$this->Gadget->setMessageBundle('messageBundle');
+		
+		$this->assertEquals('messageBundle', $this->Gadget->getMessageBundle());
+	
+	}
+
+	/**
+	 * Tests Gadget->setPrefs()
+	 */
+	public function testSetPrefs()
+	{
+		
+		$this->Gadget->setPrefs('prefs');
+		
+		$this->assertEquals('prefs', $this->Gadget->getUserPrefValues());
+	
+	}
+}
\ No newline at end of file

Added: incubator/shindig/trunk/php/test/gadgets/JsFeatureLoaderInvalid.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/gadgets/JsFeatureLoaderInvalid.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/gadgets/JsFeatureLoaderInvalid.php (added)
+++ incubator/shindig/trunk/php/test/gadgets/JsFeatureLoaderInvalid.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,105 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ * 
+ */
+
+require_once 'PHPUnit/Framework/TestCase.php';
+require_once 'src/gadgets/JsFeatureLoader.php';
+require_once 'src/gadgets/GadgetFeatureRegistry.php';
+require_once 'src/gadgets/JsLibrary.php';
+require_once 'src/gadgets/GadgetFeatureFactory.php';
+require_once 'src/gadgets/GadgetFeature.php';
+require_once 'src/gadgets/JsLibraryFeatureFactory.php';
+
+/**
+ * JsFeatureLoader test case.
+ */
+class JsFeatureLoaderTest extends PHPUnit_Framework_TestCase {
+	
+	/**
+	 * @var JsFeatureLoader
+	 */
+	private $JsFeatureLoader;
+	
+	/**
+	 * @var FeatureName
+	 */
+	private $FeatureName = 'Dummie';
+	
+	/**
+	 * @var FeatureScript
+	 */
+	private $FeatureScript = 'dummie_script.js';
+	
+	/**
+	 * @var JsFeaturesFileContent
+	 */
+	private $JsFeaturesFileContent = '';
+
+	/**
+	 * Prepares the environment before running a test.
+	 */
+	protected function setUp()
+	{
+		parent::setUp();
+		$this->JsFeatureLoader = new JsFeatureLoader('');
+	
+	}
+
+	/**
+	 * Cleans up the environment after running a test.
+	 */
+	protected function tearDown()
+	{
+		$this->JsFeatureLoader = null;
+		parent::tearDown();
+	}
+
+	public function __construct()
+	{
+		$this->JsFeaturesFileContent = '<?xml version="1.0"?>	
+<feature>
+  <name>' . $this->FeatureName . '</name>
+  <gadget>
+    <script src="' . $this->FeatureScript . '"/>
+  </gadget>
+</feature>
+		';
+	}
+
+	/**
+	 * Tests JsFeatureLoader->loadFeatures()
+	 */
+	public function testLoadFeatures()
+	{
+		$registry = new GadgetFeatureRegistry('');
+		if (file_put_contents($this->FeatureScript, $this->JsFeaturesFileContent)) {
+			if (file_exists($this->FeatureScript) && is_readable($this->FeatureScript)) {
+				$features = $this->JsFeatureLoader->loadFeatures($this->FeatureScript, $registry);
+				foreach ($features as $feature) {
+					$this->assertTrue($feature->name == $this->FeatureName);
+				}
+			}
+		} else {
+			$this->fail('Error creating the dummie fail');
+		}
+	
+	}
+
+}
+

Added: incubator/shindig/trunk/php/test/gadgets/JsLibraryTest.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/gadgets/JsLibraryTest.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/gadgets/JsLibraryTest.php (added)
+++ incubator/shindig/trunk/php/test/gadgets/JsLibraryTest.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,71 @@
+<?php
+
+require_once 'src/gadgets/JsLibrary.php';
+
+require_once 'PHPUnit/Framework/TestCase.php';
+
+/**
+ * JsLibrary test case.
+ */
+class JsLibraryTest extends PHPUnit_Framework_TestCase {
+	
+	/**
+	 * @var JsLibrary
+	 */
+	private $JsLibrary;
+	
+	/**
+	 * @var type
+	 */
+	private $type = 'URL';
+	
+	/**
+	 * @var content
+	 */
+	private $content = '';
+	
+	/**
+	 * @var featureName
+	 */
+	private $featureName = '';
+
+	/**
+	 * Prepares the environment before running a test.
+	 */
+	protected function setUp()
+	{
+		parent::setUp();
+		$this->JsLibrary = new JsLibrary($this->type, $this->content, $this->featureName);
+	
+	}
+
+	/**
+	 * Cleans up the environment after running a test.
+	 */
+	protected function tearDown()
+	{
+		$this->JsLibrary = null;
+		parent::tearDown();
+	}
+
+	/**
+	 * Tests JsLibrary->getContent()
+	 */
+	public function testGetContent()
+	{
+		$content = trim($this->JsLibrary->getContent());
+		$this->assertEquals($this->content, $content);
+	}
+
+	/**
+	 * Tests JsLibrary->toString()
+	 */
+	public function testToString()
+	{
+		$output = $this->JsLibrary->toString();
+		$this->assertEquals("<script src=\"" . $this->JsLibrary->getContent() . "\"></script>", $output);
+	
+	}
+
+}
+

Added: incubator/shindig/trunk/php/test/gadgets/MessageBundleParserTest.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/gadgets/MessageBundleParserTest.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/gadgets/MessageBundleParserTest.php (added)
+++ incubator/shindig/trunk/php/test/gadgets/MessageBundleParserTest.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,63 @@
+<?php
+
+require_once 'src/gadgets/MessageBundle.php';
+require_once 'src/gadgets/MessageBundleParser.php';
+
+require_once 'PHPUnit/Framework/TestCase.php';
+
+/**
+ * MessageBundleParser test case.
+ */
+class MessageBundleParserTest extends PHPUnit_Framework_TestCase {
+	
+	/**
+	 * @var MessageBundleParser
+	 */
+	private $MessageBundleParser;
+	private $MessageBundle;
+
+	/**
+	 * Prepares the environment before running a test.
+	 */
+	protected function setUp()
+	{
+		parent::setUp();
+		
+		$this->MessageBundleParser = new MessageBundleParser(/* parameters */);
+	
+	}
+
+	/**
+	 * Cleans up the environment after running a test.
+	 */
+	protected function tearDown()
+	{
+		
+		$this->MessageBundleParser = null;
+		$this->MessageBundle = null;
+		
+		parent::tearDown();
+	}
+
+	/**
+	 * Tests MessageBundleParser->parse()
+	 */
+	public function testParse()
+	{
+		
+		$xml = '<?xml version="1.0" encoding="UTF-8" ?>
+<doc>
+	<msg name="name1">Message 1</msg>
+	<msg name="name2">Message 2</msg>
+	<msg name="name3">Message 3</msg>
+	<msg name="name4">Message 4</msg>
+</doc>';
+		
+		$this->MessageBundle = $this->MessageBundleParser->parse($xml);
+		
+		$this->assertTrue($this->MessageBundle instanceof MessageBundle);
+	
+	}
+
+}
+

Added: incubator/shindig/trunk/php/test/gadgets/MessageBundleTest.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/gadgets/MessageBundleTest.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/gadgets/MessageBundleTest.php (added)
+++ incubator/shindig/trunk/php/test/gadgets/MessageBundleTest.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,51 @@
+<?php
+
+require_once 'src/gadgets/MessageBundle.php';
+
+require_once 'PHPUnit/Framework/TestCase.php';
+
+/**
+ * MessageBundle test case.
+ */
+class MessageBundleTest extends PHPUnit_Framework_TestCase {
+	
+	/**
+	 * @var MessageBundle
+	 */
+	private $MessageBundle;
+	
+	/**
+	 * @var Message
+	 */
+	private $Messages = array('Dummie Message', 'Hello World');
+
+	/**
+	 * Prepares the environment before running a test.
+	 */
+	protected function setUp()
+	{
+		parent::setUp();
+		$this->MessageBundle = new MessageBundle($this->Messages);
+	
+	}
+
+	/**
+	 * Cleans up the environment after running a test.
+	 */
+	protected function tearDown()
+	{
+		$this->MessageBundle = null;
+		parent::tearDown();
+	}
+
+	/**
+	 * Tests MessageBundle->getMessages()
+	 */
+	public function testGetMessages()
+	{
+		$this->assertEquals($this->Messages, $this->MessageBundle->getMessages());
+	
+	}
+
+}
+

Added: incubator/shindig/trunk/php/test/gadgets/ProxyHandlerTest.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/gadgets/ProxyHandlerTest.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/gadgets/ProxyHandlerTest.php (added)
+++ incubator/shindig/trunk/php/test/gadgets/ProxyHandlerTest.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,140 @@
+<?php
+
+require_once 'PHPUnit/Framework/TestCase.php';
+require_once 'src/gadgets/ProxyHandler.php';
+require_once 'src/gadgets/SigningFetcherFactory.php';
+require_once 'src/gadgets/GadgetContext.php';
+require_once 'src/common/RemoteContentFetcher.php';
+require_once 'src/common/RemoteContentRequest.php';
+require_once 'src/common/samplecontainer/BasicRemoteContentFetcher.php';
+
+/**
+ * ProxyHandler test case.
+ */
+class ProxyHandlerTest extends PHPUnit_Framework_TestCase {
+	
+	/**
+	 * @var ProxyHandler
+	 */
+	private $ProxyHandler;
+	
+	/**
+	 * @var context
+	 */
+	private $context;
+	
+	/**
+	 * @var signingFetcherFactory
+	 */
+	private $signingFetcherFactory;
+	
+	/**
+	 * @var signingFetcherFactory
+	 */
+	private $url;
+	
+	/**
+	 * @var original_content
+	 */
+	private $original_content;
+	
+	/**
+	 * @var proxy
+	 */
+	private $proxy;
+
+	/**
+	 * Prepares the environment before running a test.
+	 */
+	protected function setUp()
+	{
+		parent::setUp();
+		$this->context = new GadgetContext('GADGET');
+		$this->url = 'http://' . $_SERVER["HTTP_HOST"] . Config::get('web_prefix') . '/test/gadgets/example.xml';
+		$this->proxy = 'http://' . $_SERVER["HTTP_HOST"] . Config::get('web_prefix') . '/gadgets/proxy/';
+		$this->original_content = file_get_contents($this->url);
+		$this->ProxyHandler = new ProxyHandler($this->context);
+	}
+
+	/**
+	 * Cleans up the environment after running a test.
+	 */
+	protected function tearDown()
+	{
+		$this->ProxyHandler = null;
+		parent::tearDown();
+	}
+
+	private function getRemoteFile($url, $IfNoneMatch = null, $IfModifiedSince = null)
+	{
+		// get the host name and url path
+		$parsedUrl = parse_url($url);
+		$host = $parsedUrl['host'];
+		if (isset($parsedUrl['path'])) {
+			$path = $parsedUrl['path'];
+		} else {
+			// the url is pointing to the host like http://www.mysite.com
+			$path = '/';
+		}
+		
+		if (isset($parsedUrl['query'])) {
+			$path .= '?' . $parsedUrl['query'];
+		}
+		
+		if (isset($parsedUrl['port'])) {
+			$port = $parsedUrl['port'];
+		} else {
+			$port = 80;
+		}
+		
+		$timeout = 5;
+		$response = '';
+		
+		// connect to the remote server
+		$fp = @fsockopen($host, $port, $errno, $errstr, $timeout);
+		
+		if (! $fp) {
+			echo "Cannot retrieve $url";
+		} else {
+			// send the necessary headers to get the file
+			fputs($fp, "GET $path HTTP/1.0\r\n" . "Host: $host\r\n" . "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3\r\n" . "Accept: */*\r\n" . ($IfNoneMatch !== null ? "If-None-Match: $IfNoneMatch\r\n" : '') . ($IfNoneMatch !== null ? "If-Modified-Since: $IfModifiedSince\r\n" : '') . "Keep-Alive: 300\r\n" . "Connection: keep-alive\r\n" . "Referer: http://$host\r\n\r\n");
+			// retrieve the response from the remote server
+			while ($line = fread($fp, 4096)) {
+				$response .= $line;
+			}
+			
+			fclose($fp);
+		
+		}
+		
+		// return the file content
+		return $response;
+	}
+
+	private function getHTTPStatus($strHeaders)
+	{
+		return intval(substr($strHeaders, 8, 5));
+	}
+
+	/**
+	 * Tests ProxyHandler->fetch()
+	 */
+	public function testFetch()
+	{
+		$out = file_get_contents($this->proxy . '?url=' . $this->url . '');
+		$this->assertEquals($out, $this->original_content);
+		$this->assertNotEquals($this->getHTTPStatus($this->getRemoteFile($this->proxy . '?url=' . $this->url . '')), $this->getHTTPStatus($this->getRemoteFile($this->proxy . '?url=' . $this->url . '', 'd9e124952eee27820768b8fadb0f0b78', gmdate("D, d M Y H:i:s", time() + 10000) . " GMT")), 'Checking HTTP 304 support');
+	}
+
+	/**
+	 * Tests ProxyHandler->fetchJson()
+	 */
+	public function testFetchJson()
+	{
+		// FIXME we need a better test here 
+		$out = file_get_contents($this->proxy . '?url=' . $this->url . '&output=js');
+		$this->assertTrue(strpos($out, UNPARSEABLE_CRUFT) == 0);
+	}
+
+}
+

Added: incubator/shindig/trunk/php/test/gadgets/SubstitutionsTest.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/gadgets/SubstitutionsTest.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/gadgets/SubstitutionsTest.php (added)
+++ incubator/shindig/trunk/php/test/gadgets/SubstitutionsTest.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,71 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ * 
+ */
+
+require_once 'src/gadgets/Substitutions.php';
+
+require_once 'PHPUnit/Framework/TestCase.php';
+
+/**
+ * Substitutions test case.
+ */
+class SubstitutionsTest extends PHPUnit_Framework_TestCase {
+	
+	/**
+	 * @var Substitutions
+	 */
+	private $Substitutions;
+
+	/**
+	 * Prepares the environment before running a test.
+	 */
+	protected function setUp()
+	{
+		parent::setUp();
+		$this->Substitutions = new Substitutions();
+	}
+
+	/**
+	 * Cleans up the environment after running a test.
+	 */
+	protected function tearDown()
+	{
+		$this->Substitutions = null;
+		parent::tearDown();
+	}
+
+	/**
+	 * Tests Substitutions->substitute()
+	 * Substitutions->addSubstitution()
+	 * Substitutions->substituteType()
+	 */
+	public function testSubstitute()
+	{
+		
+		$type = 'MSG';
+		$key = 'DMSG';
+		$value = 'success';
+		$input = 'Test: __MSG_DMSG__';
+		$this->Substitutions->addSubstitution($type, $key, $value);
+		$this->assertEquals('Test: success', $this->Substitutions->substitute($input));
+	
+	}
+
+}
+