Author: chabotc
Date: Thu Oct 9 13:57:01 2008
New Revision: 703256
URL: http://svn.apache.org/viewvc?rev=703256&view=rev
Log:
Implemented a bit of an ugly hack to prevent Enum class not found errors in the
unit tests, and restored the enums in the person model
Modified:
incubator/shindig/trunk/php/src/social/model/Person.php
incubator/shindig/trunk/php/test/common/BasicRemoteContentTest.php
incubator/shindig/trunk/php/test/social/PersonTest.php
Modified: incubator/shindig/trunk/php/src/social/model/Person.php
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/social/model/Person.php?rev=703256&r1=703255&r2=703256&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/social/model/Person.php (original)
+++ incubator/shindig/trunk/php/src/social/model/Person.php Thu Oct 9 13:57:01
2008
@@ -17,6 +17,10 @@
* specific language governing permissions and limitations under the License.
*/
+if (!class_exists('Enum')) {
+ require 'Enum.php';
+}
+
/**
* see
* http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Person
Modified: incubator/shindig/trunk/php/test/common/BasicRemoteContentTest.php
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/common/BasicRemoteContentTest.php?rev=703256&r1=703255&r2=703256&view=diff
==============================================================================
--- incubator/shindig/trunk/php/test/common/BasicRemoteContentTest.php
(original)
+++ incubator/shindig/trunk/php/test/common/BasicRemoteContentTest.php Thu Oct
9 13:57:01 2008
@@ -41,7 +41,7 @@
$context = new TestContext();
$ret = $this->BasicRemoteContent->fetch($request, $context);
$content = $ret->getResponseContent();
- $this->assertEquals("OK\n", $content);
+ $this->assertEquals("OK", trim($content));
}
/**
@@ -54,4 +54,73 @@
$ret = $this->BasicRemoteContent->fetch($request, $context);
$this->assertEquals('404', $ret->getHttpCode());
}
+
+ /**
+ * Tests BasicRemoteContent->fetch() 200, 200 and 200 responses
+ */
+ public function testMultiFetch()
+ {
+ $requests = array();
+ $contexts = array();
+ $requests[] = new
RemoteContentRequest('http://test.chabotc.com/ok.html');
+ $requests[] = new
RemoteContentRequest('http://test.chabotc.com/ok.html');
+ $requests[] = new
RemoteContentRequest('http://test.chabotc.com/ok.html');
+ $contexts[] = new TestContext();
+ $contexts[] = new TestContext();
+ $contexts[] = new TestContext();
+
+ $rets = $this->BasicRemoteContent->multiFetch($requests,
$contexts);
+ $content_0 = $rets[0]->getResponseContent();
+ $content_1 = $rets[1]->getResponseContent();
+ $content_2 = $rets[2]->getResponseContent();
+ $this->assertEquals("OK", trim($content_0));
+ $this->assertEquals("OK", trim($content_1));
+ $this->assertEquals("OK", trim($content_2));
+ $this->assertEquals('200', $rets[0]->getHttpCode());
+ $this->assertEquals('200', $rets[1]->getHttpCode());
+ $this->assertEquals('200', $rets[2]->getHttpCode());
+ }
+
+ /**
+ * Tests BasicRemoteContent->Multifetch() 200, 200 and 404 responses
+ */
+ public function testMultiFetchMix()
+ {
+ $requests = array();
+ $contexts = array();
+ $requests[] = new
RemoteContentRequest('http://test.chabotc.com/ok.html');
+ $requests[] = new
RemoteContentRequest('http://test.chabotc.com/ok.html');
+ $requests[] = new
RemoteContentRequest('http://test.chabotc.com/fail.html');
+ $contexts[] = new TestContext();
+ $contexts[] = new TestContext();
+ $contexts[] = new TestContext();
+
+ $rets = $this->BasicRemoteContent->multiFetch($requests,
$contexts);
+ $content_0 = $rets[0]->getResponseContent();
+ $content_1 = $rets[1]->getResponseContent();
+ $this->assertEquals("OK", trim($content_0));
+ $this->assertEquals("OK", trim($content_1));
+ $this->assertEquals('200', $rets[0]->getHttpCode());
+ $this->assertEquals('200', $rets[1]->getHttpCode());
+ $this->assertEquals('404', $rets[2]->getHttpCode());
+ }
+
+ /**
+ * Tests BasicRemoteContent->Multifetch() 404, 404 and 404 responses
+ */
+ public function testMultiFetch404()
+ {
+ $requests = array();
+ $contexts = array();
+ $requests[] = new
RemoteContentRequest('http://test.chabotc.com/fail.html');
+ $requests[] = new
RemoteContentRequest('http://test.chabotc.com/fail.html');
+ $requests[] = new
RemoteContentRequest('http://test.chabotc.com/fail.html');
+ $contexts[] = new TestContext();
+ $contexts[] = new TestContext();
+ $contexts[] = new TestContext();
+ $rets = $this->BasicRemoteContent->multiFetch($requests,
$contexts);
+ $this->assertEquals('404', $rets[0]->getHttpCode());
+ $this->assertEquals('404', $rets[1]->getHttpCode());
+ $this->assertEquals('404', $rets[2]->getHttpCode());
+ }
}
Modified: incubator/shindig/trunk/php/test/social/PersonTest.php
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/social/PersonTest.php?rev=703256&r1=703255&r2=703256&view=diff
==============================================================================
--- incubator/shindig/trunk/php/test/social/PersonTest.php (original)
+++ incubator/shindig/trunk/php/test/social/PersonTest.php Thu Oct 9 13:57:01
2008
@@ -354,8 +354,9 @@
*/
public function testGetNetworkPresence()
{
+ $presence = new EnumPresence('DND');
$this->Person->setNetworkPresence('DND');
- $this->assertEquals('DND', $this->Person->getNetworkPresence());
+ $this->assertEquals($presence,
$this->Person->getNetworkPresence());
}
/**
@@ -468,8 +469,9 @@
*/
public function testGetSmoker()
{
+ $smoker = new EnumSmoker('OCCASIONALLY');
$this->Person->setSmoker('OCCASIONALLY');
- $this->assertEquals('OCCASIONALLY', $this->Person->getSmoker());
+ $this->assertEquals($smoker, $this->Person->getSmoker());
}
/**
@@ -775,8 +777,9 @@
*/
public function testSetLookingFor()
{
+ $lookingFor = new EnumLookingFor('FRIENDS');
$this->Person->setLookingFor('FRIENDS');
- $this->assertEquals('FRIENDS', $this->Person->getLookingFor());
+ $this->assertEquals($lookingFor,
$this->Person->getLookingFor());
}
/**