public function testProperInstantiation() { global $_SERVER; // emulate client request $_SERVER["REQUEST_METHOD"] = "GET"; $_SERVER["SCRIPT_NAME"] = "/service.php"; $vo_response = new ResponseHTTP(); $vo_request = new RequestHTTP($vo_response, array("dont_create_new_session" => true)); $vo_request->setRawPostData('{"foo" : "bar"}'); $vo_request->setParameter("id", 4711, "GET"); $vo_service = new BaseJSONService($vo_request, "ca_objects"); $this->assertFalse($vo_service->hasErrors()); $this->assertEquals("ca_objects", $vo_service->getTableName()); $this->assertEquals("GET", $vo_service->getRequestMethod()); $this->assertEquals(4711, $vo_service->getIdentifier()); $this->assertEquals(array("foo" => "bar"), $vo_service->getRequestBodyArray()); }
/** * This part of the service is basically a wrapper around BaseModel::get so we don't * need to test that extensively here. We "just" have to make sure the integration works. */ public function testGetSpecificItemInfo() { global $_SERVER; // emulate client request $_SERVER["REQUEST_METHOD"] = "GET"; $_SERVER["SCRIPT_NAME"] = "/service.php"; $vo_response = new ResponseHTTP(); $vo_request = new RequestHTTP($vo_response); $vs_request_body = <<<JSON { \t"bundles" : { \t\t"ca_objects.access" : { \t\t\t"convertCodesToDisplayText" : true \t\t}, \t\t"ca_objects.preferred_labels.name" : { \t\t\t"delimiter" : "; " \t\t}, \t\t"ca_entities.entity_id" : { \t\t\t"returnAsArray" : true \t\t} \t} } JSON; $vo_request->setParameter("id", 27, "GET"); $vo_request->setRawPostData($vs_request_body); $vo_service = new ItemService($vo_request, "ca_objects"); $va_return = $vo_service->dispatch(); $this->assertFalse($vo_service->hasErrors()); $this->assertEquals("Public", $va_return["ca_objects.access"]); $this->assertEquals("Astroland arcade, Surf Avenue", $va_return["ca_objects.preferred_labels.name"]); $this->assertEquals(array("4"), $va_return["ca_entities.entity_id"]); }