|
29 | 29 | require_once 'Zend/Json/Server/Request.php';
|
30 | 30 | require_once 'Zend/Json/Server/Response.php';
|
31 | 31 | require_once 'Zend/Json.php';
|
| 32 | +require_once 'Zend/Server/Exception.php'; |
32 | 33 |
|
33 | 34 | /**
|
34 | 35 | * Test class for Zend_Json_Server
|
@@ -308,6 +309,22 @@ public function testHandleValidMethodWithTooFewParamsShouldPassDefaultsOrNullsFo
|
308 | 309 | $this->assertNull($result[2]);
|
309 | 310 | }
|
310 | 311 |
|
| 312 | + public function testHandleValidMethodWithMissingParamsShouldThrowException() |
| 313 | + { |
| 314 | + $this->server->setClass('Zend_Json_ServerTest_Foo') |
| 315 | + ->setAutoEmitResponse(false); |
| 316 | + $request = $this->server->getRequest(); |
| 317 | + $request->setMethod('bar') |
| 318 | + ->setParams(array('one' => null)) |
| 319 | + ->setId('foo'); |
| 320 | + try { |
| 321 | + $response = $this->server->handle(); |
| 322 | + } catch (Exception $e) { |
| 323 | + $this->assertTrue($e instanceof Zend_Server_Exception); |
| 324 | + $this->assertEquals('Method bar is missing required parameter: one', $e->getMessage()); |
| 325 | + } |
| 326 | + } |
| 327 | + |
311 | 328 | public function testHandleValidMethodWithTooManyParamsShouldWork()
|
312 | 329 | {
|
313 | 330 | $this->server->setClass('Zend_Json_ServerTest_Foo')
|
@@ -478,7 +495,7 @@ static public function staticBar($one, $two = 'two', $three = null)
|
478 | 495 | public function bar($one, $two = 'two', $three = null)
|
479 | 496 | {
|
480 | 497 | return array($one, $two, $three);
|
481 |
| - } |
| 498 | + } |
482 | 499 |
|
483 | 500 | /**
|
484 | 501 | * Baz
|
|
0 commit comments