Author: chabotc
Date: Tue Aug 5 16:14:57 2008
New Revision: 683028
URL: http://svn.apache.org/viewvc?rev=683028&view=rev
Log:
Few extra tests for simple classes
Added:
incubator/shindig/trunk/php/test/gadgets/HttpUtilTest.php
incubator/shindig/trunk/php/test/gadgets/LinkSpecTest.php
incubator/shindig/trunk/php/test/gadgets/LocaleSpecTest.php
Added: incubator/shindig/trunk/php/test/gadgets/HttpUtilTest.php
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/gadgets/HttpUtilTest.php?rev=683028&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/gadgets/HttpUtilTest.php (added)
+++ incubator/shindig/trunk/php/test/gadgets/HttpUtilTest.php Tue Aug 5
16:14:57 2008
@@ -0,0 +1,62 @@
+<?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.
+ *
+ */
+
+/**
+ * HttpUtil test case.
+ */
+class HttpUtilTest extends PHPUnit_Framework_TestCase {
+
+ private $GadgetServer;
+ private $gadget;
+ private $GadgetContext;
+
+ /**
+ * Cleans up the environment after running a test.
+ */
+ protected function tearDown()
+ {
+ $this->GadgetServer = null;
+ $this->gadget = null;
+ parent::tearDown();
+ }
+
+ /**
+ * Tests HttpUtil::getView()
+ */
+ public function testGetView()
+ {
+ $this->GadgetServer = new GadgetServer();
+ // prevent polution from other test cases + make sure we're not
testing
+ // a cached result
+ $_GET = array('nocache' => 1, 'view' => 'profile');
+ $_POST = array();
+ $this->GadgetContext = new GadgetContext('GADGET');
+
$this->GadgetContext->setUrl('http://test.chabotc.com/testGadget.xml');
+ $this->gadget =
$this->GadgetServer->processGadget($this->GadgetContext);
+ $view = HttpUtil::getView($this->gadget, $this->GadgetContext);
+ $this->assertEquals('profile', $view->getName());
+ $this->assertEquals('HTML', $view->getType());
+ $this->assertEquals('', $view->getHref());
+ $this->assertEquals("content", $view->getContent());
+ $this->assertEquals("400", $view->preferedHeight);
+ $this->assertEquals("300", $view->preferedWidth);
+ $this->assertFalse($view->getQuirks());
+ }
+}
Added: incubator/shindig/trunk/php/test/gadgets/LinkSpecTest.php
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/gadgets/LinkSpecTest.php?rev=683028&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/gadgets/LinkSpecTest.php (added)
+++ incubator/shindig/trunk/php/test/gadgets/LinkSpecTest.php Tue Aug 5
16:14:57 2008
@@ -0,0 +1,80 @@
+<?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.
+ */
+
+/**
+ * LinkSpec test case.
+ */
+class LinkSpecTest extends PHPUnit_Framework_TestCase {
+
+ /**
+ * @var LinkSpec
+ */
+ private $LinkSpec;
+
+ /**
+ * Prepares the environment before running a test.
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+ $this->LinkSpec = new LinkSpec('rel', 'href', 'method');
+ }
+
+ /**
+ * Cleans up the environment after running a test.
+ */
+ protected function tearDown()
+ {
+ $this->LinkSpec = null;
+ parent::tearDown();
+ }
+
+ /**
+ * Tests LinkSpec->__construct()
+ */
+ public function test__construct()
+ {
+ $this->LinkSpec = new LinkSpec('rel', 'href', 'method');
+ }
+
+ /**
+ * Tests LinkSpec->getHref()
+ */
+ public function testGetHref()
+ {
+ $this->assertEquals('href', $this->LinkSpec->getHref());
+ }
+
+ /**
+ * Tests LinkSpec->getMethod()
+ */
+ public function testGetMethod()
+ {
+ $this->assertEquals('method', $this->LinkSpec->getMethod());
+ }
+
+ /**
+ * Tests LinkSpec->getRel()
+ */
+ public function testGetRel()
+ {
+ $this->assertEquals('rel', $this->LinkSpec->getRel());
+ }
+}
Added: incubator/shindig/trunk/php/test/gadgets/LocaleSpecTest.php
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/gadgets/LocaleSpecTest.php?rev=683028&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/gadgets/LocaleSpecTest.php (added)
+++ incubator/shindig/trunk/php/test/gadgets/LocaleSpecTest.php Tue Aug 5
16:14:57 2008
@@ -0,0 +1,84 @@
+<?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.
+ *
+ */
+
+/**
+ * LocaleSpec test case.
+ */
+class LocaleSpecTest extends PHPUnit_Framework_TestCase {
+
+ /**
+ * @var LocaleSpec
+ */
+ private $LocaleSpec;
+
+ /**
+ * Prepares the environment before running a test.
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+ $this->LocaleSpec = new LocaleSpec();
+ $this->LocaleSpec->url = 'url';
+ $this->LocaleSpec->locale = 'locale';
+ $this->LocaleSpec->rightToLeft = 'rtl';
+ $this->LocaleSpec->localeMessageBundles = array('foo');
+ }
+
+ /**
+ * Cleans up the environment after running a test.
+ */
+ protected function tearDown()
+ {
+ $this->LocaleSpec = null;
+ parent::tearDown();
+ }
+
+ /**
+ * Tests LocaleSpec->getLocale()
+ */
+ public function testGetLocale()
+ {
+ $this->assertEquals('locale', $this->LocaleSpec->getLocale());
+ }
+
+ /**
+ * Tests LocaleSpec->getLocaleMessageBundles()
+ */
+ public function testGetLocaleMessageBundles()
+ {
+ $this->assertEquals(array('foo'),
$this->LocaleSpec->getLocaleMessageBundles());
+ }
+
+ /**
+ * Tests LocaleSpec->getURI()
+ */
+ public function testGetURI()
+ {
+ $this->assertEquals('url', $this->LocaleSpec->getURI());
+ }
+
+ /**
+ * Tests LocaleSpec->isRightToLeft()
+ */
+ public function testIsRightToLeft()
+ {
+ $this->assertEquals('rtl', $this->LocaleSpec->isRightToLeft());
+ }
+}