require_once $project_rootdir . '/plugins/sfWebRPCPlugin/lib/vendor/IXR_Library.inc.php'; $client = new IXR_Client($project_baseurl . "/sfWebRPCPluginDemo/RPC2"); // query remote neoip-casti to pull cast_mdata $succeed = $client->query('add', 3, 7); $t->is($client->query('add', 3, 7), true, 'call to sfWebRPCPluginDemo::add succeed'); // if it failed, notify the error //if(! $succeed ) throw new Exception("Error doing xmlrpc to casti_srv_uri due to ".$client->getErrorMessage()); $t->is($client->getResponse(), 10, 'add 3+7 is 10'); $t->is($client->query('fctnamej_which_doesnt_exist'), false, 'call to unexisting function fails as expected'); /************************************************************************/ /* Test handler JSON */ /************************************************************************/ $t->diag('sfWebRPCPlugin JSON'); $b->get($project_baseurl . "/sfWebRPCPluginDemo/JSON?method=add&arg0=3&arg1=2"); $t->is($b->getResponseCode(), 200, 'http code 200 on "add" JSON handler'); $t->is($b->getResponseHeader("Content-Type"), "application/json", "mimetype is application/json on json call"); $t->is($b->getResponseText(), 5, "response is 5 (as expected for add(3,2))"); $b->get($project_baseurl . "/sfWebRPCPluginDemo/JSON?method=add&arg0=3"); $t->isnt($b->getResponseCode(), 200, 'http code NOT 200 "add" when wrong number of parameters'); /************************************************************************/ /* Test handler JSONP */ /************************************************************************/ $t->diag('sfWebRPCPlugin JSONP'); $b->get($project_baseurl . "/sfWebRPCPluginDemo/JSON?callback=cbsample&method=add&arg0=3&arg1=2"); $t->is($b->getResponseCode(), 200, 'http code 200 on "add" JSON handler'); $t->like($b->getResponseHeader("Content-Type"), "/text\\/javascript/", "mimetype is text/javascript on JSONP call"); $t->is($b->getResponseText(), 'cbsample("5")', 'response is cbsample("5")'); /************************************************************************/ /* Test handler XDOMRPC */ /************************************************************************/ $t->diag('sfWebRPCPlugin XDOMRPC');