Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 56d2679

Browse files
committed
Merge pull request zendframework#476 from ThomasWunderlich/475Zend_Server_Exception_Enhancement
Fixes zendframework#475 - Enhance Zend_Server_Exception message
2 parents 52cec2d + 666873c commit 56d2679

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

library/Zend/Json/Server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ protected function _handle()
550550
$orderedParams[ $refParam->getName() ] = $refParam->getDefaultValue();
551551
} else {
552552
throw new Zend_Server_Exception(
553-
'Missing required parameter: ' . $refParam->getName()
553+
'Method ' . $request->getMethod() . ' is missing required parameter: ' . $refParam->getName()
554554
);
555555
}
556556
}

tests/Zend/Json/ServerTest.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
require_once 'Zend/Json/Server/Request.php';
3030
require_once 'Zend/Json/Server/Response.php';
3131
require_once 'Zend/Json.php';
32+
require_once 'Zend/Server/Exception.php';
3233

3334
/**
3435
* Test class for Zend_Json_Server
@@ -308,6 +309,22 @@ public function testHandleValidMethodWithTooFewParamsShouldPassDefaultsOrNullsFo
308309
$this->assertNull($result[2]);
309310
}
310311

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+
311328
public function testHandleValidMethodWithTooManyParamsShouldWork()
312329
{
313330
$this->server->setClass('Zend_Json_ServerTest_Foo')
@@ -478,7 +495,7 @@ static public function staticBar($one, $two = 'two', $three = null)
478495
public function bar($one, $two = 'two', $three = null)
479496
{
480497
return array($one, $two, $three);
481-
}
498+
}
482499

483500
/**
484501
* Baz

0 commit comments

Comments
 (0)