]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dojo/tests/resources/test_JsonRPCMediator.php
add Dojo 1.1.1
[eow] / static / dojo-release-1.1.1 / dojo / tests / resources / test_JsonRPCMediator.php
1 <?php
2         require_once("./JSON.php");
3         
4         // FIXME: doesn't look like we really need Pear at all
5         // which decreases the testing burden. 
6         // Commenting out.the require and the new File() call.
7
8         // NOTE: File.php is installed via Pear using:
9         //      %> sudo pear install File
10         // Your server will also need the Pear library directory included in PHP's
11         // include_path configuration directive
12         // require_once('File.php');
13
14         // ensure that we don't try to send "html" down to the client
15         header("Content-Type: text/plain");
16
17         $json = new Services_JSON;
18         //$fp = new File();
19
20         $results = array();
21         $results['error'] = null;
22
23         $jsonRequest = file_get_contents('php://input');
24         //$jsonRequest = '{"params":["Blah"],"method":"myecho","id":86}';
25
26         $req = $json->decode($jsonRequest);
27
28         include("./testClass.php");
29         $testObject = new testClass();
30
31         $method = $req->method;
32         if ($method != "triggerRpcError") {
33                 $ret = call_user_func_array(array($testObject,$method),$req->params);
34                 $results['result'] = $ret;
35         } else {
36                 $results['error'] = "Triggered RPC Error test";
37         }
38         $results['id'] = $req->id;
39
40         $encoded = $json->encode($results);
41
42         print $encoded;
43 ?>