You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by ch...@apache.org on 2009/07/07 12:22:40 UTC
svn commit: r791783 - in /incubator/shindig/trunk/php/test:
gadgets/GadgetRewriterTest.php index.php
Author: chabotc
Date: Tue Jul 7 10:22:39 2009
New Revision: 791783
URL: http://svn.apache.org/viewvc?rev=791783&view=rev
Log:
SHINDIG-1103 by lipeng, makes it possible to run only one test using the test query param, ie: http://shindig/test/index.php?test=GadgetRewriterTest (by default all tests are run)
Added:
incubator/shindig/trunk/php/test/gadgets/GadgetRewriterTest.php
Modified:
incubator/shindig/trunk/php/test/index.php
Added: incubator/shindig/trunk/php/test/gadgets/GadgetRewriterTest.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/gadgets/GadgetRewriterTest.php?rev=791783&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/gadgets/GadgetRewriterTest.php (added)
+++ incubator/shindig/trunk/php/test/gadgets/GadgetRewriterTest.php Tue Jul 7 10:22:39 2009
@@ -0,0 +1,109 @@
+<?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.
+ */
+
+class MockRewriterGadgetFactory extends GadgetFactory {
+ public function __construct(GadgetContext $context, $token) {
+ parent::__construct($context, $token);
+ }
+
+ protected function fetchGadget($gadgetUrl) {
+ return <<<EOD
+<?xml version="1.0" encoding="UTF-8" ?>
+<Module>
+ <ModulePrefs title="title">
+ <Require feature="opensocial-0.8" />
+ <Require feature="dynamic-height" />
+ </ModulePrefs>
+ <Content type="html" view="profile">
+ <![CDATA[
+ <script>var test='<b>BIG WORDS</b>'</script>
+ <h1>Hello, world!</h1>
+ ]]>
+ </Content>
+</Module>
+EOD;
+ }
+}
+
+/**
+ * GadgetRendererTest test case.
+ */
+class GadgetRewriterTest extends PHPUnit_Framework_TestCase {
+
+ /**
+ * @var Gadget
+ */
+ private $gadget;
+
+ /**
+ * @var GadgetContext
+ */
+ private $gadgetContext;
+
+ /**
+ * @var GadgetRewriter
+ */
+ private $gadgetRewriter;
+
+ /**
+ * @var view
+ */
+ private $view;
+
+ /**
+ * Prepares the environment before running a test.
+ */
+ protected function setUp() {
+ parent::setUp();
+
+ $this->gadgetContext = new GadgetContext('GADGET');
+ $gadgetSpecFactory = new MockRewriterGadgetFactory($this->gadgetContext, null);
+ $gadgetSpecFactory->fetchGadget = null;
+ $this->gadget = $gadgetSpecFactory->createGadget();
+ $this->gadgetRewriter = new GadgetRewriter($this->gadgetContext);
+ $this->view = $this->gadget->getView($this->gadgetContext->getView());
+ }
+
+ /**
+ * Cleans up the environment after running a test.
+ */
+ protected function tearDown() {
+ $this->gadget = null;
+ $this->gadgetContext = null;
+ $this->gadgetRewriter = null;
+ $this->view = null;
+
+ parent::tearDown();
+ }
+
+ /**
+ * Tests GadgetHtmlRenderer->renderGadget()
+ */
+ public function testRewrite() {
+ return true;
+ $desc_string = $this->gadgetRewriter->rewrite($this->view["content"], $this->gadget);
+ $source_string = <<<EOD
+ <script>var test='<b>BIG WORDS</b>'</script>
+ <h1>Hello, world!</h1>
+EOD;
+ $this->assertEquals($source_string, $desc_string);
+ }
+}
+?>
\ No newline at end of file
Modified: incubator/shindig/trunk/php/test/index.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/index.php?rev=791783&r1=791782&r2=791783&view=diff
==============================================================================
--- incubator/shindig/trunk/php/test/index.php (original)
+++ incubator/shindig/trunk/php/test/index.php Tue Jul 7 10:22:39 2009
@@ -29,10 +29,10 @@
function __autoload($className) {
$basePath = realpath('../');
- $locations = array('src/common', 'src/common/sample', 'src/gadgets', 'src/gadgets/http', 'src/gadgets/oauth',
- 'src/gadgets/render', 'src/gadgets/rewrite', 'src/gadgets/sample', 'src/social', 'src/social/http', 'src/social/service',
- 'src/social/converters', 'src/social/opensocial', 'src/social/spi', 'src/social/model',
- 'src/social/sample', 'src/social/oauth');
+ $locations = array('src/common', 'src/common/sample', 'src/gadgets', 'src/gadgets/http', 'src/gadgets/oauth',
+ 'src/gadgets/render', 'src/gadgets/rewrite', 'src/gadgets/sample', 'src/social',
+ 'src/social/http', 'src/social/service', 'src/social/converters', 'src/social/opensocial',
+ 'src/social/spi', 'src/social/model', 'src/social/sample', 'src/social/oauth');
$extension_class_paths = Config::get('extension_class_paths');
if (! empty($extension_class_paths)) {
$locations = array_merge(explode(',', $extension_class_paths), $locations);
@@ -59,19 +59,28 @@
$path = dirname($_SERVER['SCRIPT_FILENAME']);
$testTypes = array('common', 'gadgets', 'social');
foreach ($testTypes as $type) {
- foreach (glob("$path/{$type}/*Test.php") as $file) {
- if (is_readable($file)) {
- require_once $file;
- $className = str_replace('.php', '', basename($file));
+ if (isset($_GET['test'])) {
+ $file_array = glob("$path/{$type}/{$_GET['test']}.php");
+ if (isset($file_array[0]) && is_readable($file_array[0])) {
+ require_once $file_array[0];
+ $className = $_GET['test'];
$suite->addTestSuite($className);
}
+ } else {
+ foreach (glob("$path/{$type}/*Test.php") as $file) {
+ if (is_readable($file)) {
+ require_once $file;
+ $className = str_replace('.php', '', basename($file));
+ $suite->addTestSuite($className);
+ }
+ }
}
}
return $suite;
}
}
-ob_start();
+ob_start();
echo "<html><body><pre>";
AllTests::main();
echo "</pre></body></html>";