Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Server/Server.php
Expand Up @@ -366,7 +366,7 @@ protected function _getDefaultParams(array $args, array $params)
if (array_key_exists('default', $param)) {
$value = $param['default'];
}
array_push($args, $value);
$args[$param['name']] = $value;
}
return $args;
}
Expand Down
18 changes: 18 additions & 0 deletions test/ServerTest.php
Expand Up @@ -277,6 +277,24 @@ public function testHandleValidMethodWithTooFewParamsShouldPassDefaultsOrNullsFo
$this->assertNull($result[2]);
}

public function testHandleValidMethodWithTooFewAssociativeParamsShouldPassDefaultsOrNullsForMissingParams()
{
$this->server->setClass('ZendTest\Json\Foo')
->setReturnResponse(true);
$request = $this->server->getRequest();
$request->setMethod('bar')
->setParams(array('one' => true))
->setId('foo');
$response = $this->server->handle();
$this->assertTrue($response instanceof Response);
$this->assertFalse($response->isError());
$result = $response->getResult();
$this->assertTrue(is_array($result));
$this->assertTrue(3 == count($result));
$this->assertEquals('two', $result[1], var_export($result, 1));
$this->assertNull($result[2]);
}

public function testHandleValidMethodWithTooManyParamsShouldWork()
{
$this->server->setClass('ZendTest\Json\Foo')
Expand Down

0 comments on commit 8d06baa

Please sign in to comment.