You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by bh...@apache.org on 2011/12/14 10:22:17 UTC

svn commit: r1214127 - in /shindig/trunk/php: ./ src/apache/shindig/common/sample/ test/ test/common/ test/gadgets/ test/social/

Author: bhofmann
Date: Wed Dec 14 09:22:17 2011
New Revision: 1214127

URL: http://svn.apache.org/viewvc?rev=1214127&view=rev
Log:
fixed phpunit tests after refactoring

Added:
    shindig/trunk/php/src/apache/shindig/common/sample/BasicSecurityTokenException.php   (with props)
Modified:
    shindig/trunk/php/phpunit.xml.dist
    shindig/trunk/php/src/apache/shindig/common/sample/BasicSecurityToken.php
    shindig/trunk/php/test/bootstrap.php
    shindig/trunk/php/test/common/BasicSecurityTokenTest.php
    shindig/trunk/php/test/common/CacheMemcacheTest.php
    shindig/trunk/php/test/gadgets/GadgetContextTest.php
    shindig/trunk/php/test/social/InputPeopleConverterTest.php

Modified: shindig/trunk/php/phpunit.xml.dist
URL: http://svn.apache.org/viewvc/shindig/trunk/php/phpunit.xml.dist?rev=1214127&r1=1214126&r2=1214127&view=diff
==============================================================================
--- shindig/trunk/php/phpunit.xml.dist (original)
+++ shindig/trunk/php/phpunit.xml.dist Wed Dec 14 09:22:17 2011
@@ -24,7 +24,7 @@
          verbose="true">
   <testsuites>
     <testsuite name="shindig-php">
-      <directory>test/gadgets</directory>
+      <directory>test</directory>
     </testsuite>
   </testsuites>
 

Modified: shindig/trunk/php/src/apache/shindig/common/sample/BasicSecurityToken.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/apache/shindig/common/sample/BasicSecurityToken.php?rev=1214127&r1=1214126&r2=1214127&view=diff
==============================================================================
--- shindig/trunk/php/src/apache/shindig/common/sample/BasicSecurityToken.php (original)
+++ shindig/trunk/php/src/apache/shindig/common/sample/BasicSecurityToken.php Wed Dec 14 09:22:17 2011
@@ -143,7 +143,7 @@ class BasicSecurityToken extends Securit
    */
   public function getAppId() {
     if ($this->isAnonymous()) {
-      throw new \Exception("Can't get appId from an anonymous token");
+      throw new BasicSecurityTokenException("Can't get appId from an anonymous token");
     }
     return $this->tokenData[$this->APP_KEY];
   }
@@ -153,7 +153,7 @@ class BasicSecurityToken extends Securit
    */
   public function getDomain() {
     if ($this->isAnonymous()) {
-      throw new \Exception("Can't get domain from an anonymous token");
+      throw new BasicSecurityTokenException("Can't get domain from an anonymous token");
     }
     return $this->tokenData[$this->DOMAIN_KEY];
   }
@@ -163,7 +163,7 @@ class BasicSecurityToken extends Securit
    */
   public function getOwnerId() {
     if ($this->isAnonymous()) {
-      throw new \Exception("Can't get ownerId from an anonymous token");
+      throw new BasicSecurityTokenException("Can't get ownerId from an anonymous token");
     }
     return $this->tokenData[$this->OWNER_KEY];
   }
@@ -173,7 +173,7 @@ class BasicSecurityToken extends Securit
    */
   public function getViewerId() {
     if ($this->isAnonymous()) {
-      throw new \Exception("Can't get viewerId from an anonymous token");
+      throw new BasicSecurityTokenException("Can't get viewerId from an anonymous token");
     }
     return $this->tokenData[$this->VIEWER_KEY];
   }
@@ -183,7 +183,7 @@ class BasicSecurityToken extends Securit
    */
   public function getAppUrl() {
     if ($this->isAnonymous()) {
-      throw new \Exception("Can't get appUrl from an anonymous token");
+      throw new BasicSecurityTokenException("Can't get appUrl from an anonymous token");
     }
     return urldecode($this->tokenData[$this->APPURL_KEY]);
   }
@@ -193,10 +193,10 @@ class BasicSecurityToken extends Securit
    */
   public function getModuleId() {
     if ($this->isAnonymous()) {
-      throw new \Exception("Can't get moduleId from an anonymous token");
+      throw new BasicSecurityTokenException("Can't get moduleId from an anonymous token");
     }
     if (! is_numeric($this->tokenData[$this->MODULE_KEY])) {
-      throw new \Exception("Module ID should be an integer");
+      throw new BasicSecurityTokenException("Module ID should be an integer");
     }
     return $this->tokenData[$this->MODULE_KEY];
   }
@@ -206,7 +206,7 @@ class BasicSecurityToken extends Securit
    */
   public function getContainer() {
     if ($this->isAnonymous()) {
-      throw new \Exception("Can't get container from an anonymous token");
+      throw new BasicSecurityTokenException("Can't get container from an anonymous token");
     }
     return $this->tokenData[$this->CONTAINER_KEY];
   }

Added: shindig/trunk/php/src/apache/shindig/common/sample/BasicSecurityTokenException.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/apache/shindig/common/sample/BasicSecurityTokenException.php?rev=1214127&view=auto
==============================================================================
--- shindig/trunk/php/src/apache/shindig/common/sample/BasicSecurityTokenException.php (added)
+++ shindig/trunk/php/src/apache/shindig/common/sample/BasicSecurityTokenException.php Wed Dec 14 09:22:17 2011
@@ -0,0 +1,24 @@
+<?php
+namespace apache\shindig\common\sample;
+
+/*
+ * 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 BasicSecurityTokenException extends \Exception {
+}

Propchange: shindig/trunk/php/src/apache/shindig/common/sample/BasicSecurityTokenException.php
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: shindig/trunk/php/test/bootstrap.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/test/bootstrap.php?rev=1214127&r1=1214126&r2=1214127&view=diff
==============================================================================
--- shindig/trunk/php/test/bootstrap.php (original)
+++ shindig/trunk/php/test/bootstrap.php Wed Dec 14 09:22:17 2011
@@ -21,7 +21,7 @@ use apache\shindig\common\Config;
  * specific language governing permissions and limitations
  * under the License.
  */
-include "src/apache/shindig/bootstrap.php";
+include __DIR__ . "/../src/apache/shindig/bootstrap.php";
 
 // load the test config instead of the production one
-Config::loadConfig('test');
\ No newline at end of file
+Config::loadConfig(__DIR__. '/../config/test.php');
\ No newline at end of file

Modified: shindig/trunk/php/test/common/BasicSecurityTokenTest.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/test/common/BasicSecurityTokenTest.php?rev=1214127&r1=1214126&r2=1214127&view=diff
==============================================================================
--- shindig/trunk/php/test/common/BasicSecurityTokenTest.php (original)
+++ shindig/trunk/php/test/common/BasicSecurityTokenTest.php Wed Dec 14 09:22:17 2011
@@ -87,7 +87,7 @@ class BasicSecurityTokenTest extends \PH
    */
   public function testGetAppId() {
     $this->assertEquals('app', $this->BasicSecurityToken->getAppId());
-    $this->setExpectedException('BasicSecurityTokenException');
+    $this->setExpectedException('apache\shindig\common\sample\BasicSecurityTokenException');
     $this->anonymousToken->getAppId();
   }
 
@@ -96,7 +96,7 @@ class BasicSecurityTokenTest extends \PH
    */
   public function testGetAppUrl() {
     $this->assertEquals('appUrl', $this->BasicSecurityToken->getAppUrl());
-    $this->setExpectedException('BasicSecurityTokenException');
+    $this->setExpectedException('apache\shindig\common\sample\BasicSecurityTokenException');
     $this->anonymousToken->getAppUrl();
   }
 
@@ -105,7 +105,7 @@ class BasicSecurityTokenTest extends \PH
    */
   public function testGetDomain() {
     $this->assertEquals('domain', $this->BasicSecurityToken->getDomain());
-    $this->setExpectedException('BasicSecurityTokenException');
+    $this->setExpectedException('apache\shindig\common\sample\BasicSecurityTokenException');
     $this->anonymousToken->getDomain();
   }
 
@@ -114,7 +114,7 @@ class BasicSecurityTokenTest extends \PH
    */
   public function testGetModuleId() {
     $this->assertEquals(1, $this->BasicSecurityToken->getModuleId());
-    $this->setExpectedException('BasicSecurityTokenException');
+    $this->setExpectedException('apache\shindig\common\sample\BasicSecurityTokenException');
     $this->anonymousToken->getModuleId();
   }
 
@@ -123,7 +123,7 @@ class BasicSecurityTokenTest extends \PH
    */
   public function testGetOwnerId() {
     $this->assertEquals('owner', $this->BasicSecurityToken->getOwnerId());
-    $this->setExpectedException('BasicSecurityTokenException');
+    $this->setExpectedException('apache\shindig\common\sample\BasicSecurityTokenException');
     $this->anonymousToken->getOwnerId();
   }
 
@@ -132,7 +132,7 @@ class BasicSecurityTokenTest extends \PH
    */
   public function testGetViewerId() {
     $this->assertEquals('viewer', $this->BasicSecurityToken->getViewerId());
-    $this->setExpectedException('BasicSecurityTokenException');
+    $this->setExpectedException('apache\shindig\common\sample\BasicSecurityTokenException');
     $this->anonymousToken->getViewerId();
   }
 

Modified: shindig/trunk/php/test/common/CacheMemcacheTest.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/test/common/CacheMemcacheTest.php?rev=1214127&r1=1214126&r2=1214127&view=diff
==============================================================================
--- shindig/trunk/php/test/common/CacheMemcacheTest.php (original)
+++ shindig/trunk/php/test/common/CacheMemcacheTest.php Wed Dec 14 09:22:17 2011
@@ -54,7 +54,7 @@ class CacheMemcacheTest extends \PHPUnit
   protected function setUp() {
     if (!extension_loaded('memcache')) {
       $message = 'memcache requires the memcache extention';
-      throw new \PHPUnit_Framework_SkippedTestSuiteError($message);
+      $this->markTestSkipped($message);
     }
     parent::setUp();
     $this->time = new MockRequestTimeMc();
@@ -62,11 +62,11 @@ class CacheMemcacheTest extends \PHPUnit
       $this->cache = Cache::createCache('apache\shindig\common\sample\CacheStorageMemcache', 'TestCache', $this->time);
     } catch (\Exception $e) {
       $message = 'memcache server can not connect';
-      throw new \PHPUnit_Framework_SkippedTestSuiteError($message);
+      $this->markTestSkipped($message);
     }
     if (! is_resource($this->cache)) {
       $message = 'memcache server can not connect';
-      throw new \PHPUnit_Framework_SkippedTestSuiteError($message);
+      $this->markTestSkipped($message);
     }
   }
 

Modified: shindig/trunk/php/test/gadgets/GadgetContextTest.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/test/gadgets/GadgetContextTest.php?rev=1214127&r1=1214126&r2=1214127&view=diff
==============================================================================
--- shindig/trunk/php/test/gadgets/GadgetContextTest.php (original)
+++ shindig/trunk/php/test/gadgets/GadgetContextTest.php Wed Dec 14 09:22:17 2011
@@ -58,6 +58,9 @@ class GadgetContextTest extends \PHPUnit
     $this->orgServer = $_SERVER;
     
     $_GET = $this->testData;
+    
+    $_SERVER['HTTP_HOST'] = 'localhost';
+    
     $this->GadgetContext = new GadgetContext($this->gadgetRenderingContext);
   
   }
@@ -72,6 +75,8 @@ class GadgetContextTest extends \PHPUnit
     $_POST = $this->orgPost;
     $_SERVER = $this->orgServer;
     
+    unset($_SERVER['HTTP_HOST']);
+    
     parent::tearDown();
   }
 

Modified: shindig/trunk/php/test/social/InputPeopleConverterTest.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/test/social/InputPeopleConverterTest.php?rev=1214127&r1=1214126&r2=1214127&view=diff
==============================================================================
--- shindig/trunk/php/test/social/InputPeopleConverterTest.php (original)
+++ shindig/trunk/php/test/social/InputPeopleConverterTest.php Wed Dec 14 09:22:17 2011
@@ -48,17 +48,17 @@ class InputPeopleConverterTest extends \
   }
 
   public function testConvertAtom() {
-    $this->setExpectedException('SocialSpiException');
+    $this->setExpectedException('apache\shindig\social\service\SocialSpiException');
     $this->inputConverter->convertAtom('');
   }
 
   public function testConvertJson() {
-    $this->setExpectedException('SocialSpiException');
+    $this->setExpectedException('apache\shindig\social\service\SocialSpiException');
     $this->inputConverter->convertJson('');
   }
 
   public function testConvertXml() {
-    $this->setExpectedException('SocialSpiException');
+    $this->setExpectedException('apache\shindig\social\service\SocialSpiException');
     $this->inputConverter->convertXml('');
   }
 }