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

Commit

Permalink
Merge branch 'hotfix/74'
Browse files Browse the repository at this point in the history
Close #75
Fixes #74
  • Loading branch information
weierophinney committed Jun 30, 2015
2 parents 6de6c06 + 39100de commit fbc9843
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/RestController.php
Expand Up @@ -19,6 +19,7 @@
use ZF\ContentNegotiation\ViewModel as ContentNegotiationViewModel;
use ZF\Hal\Collection as HalCollection;
use ZF\Hal\Entity as HalEntity;
use ZF\Rest\Exception\InvalidArgumentException;

/**
* Controller for handling resources.
Expand Down Expand Up @@ -752,6 +753,8 @@ public function replaceList($data)

try {
$collection = $this->getResource()->replaceList($data);
} catch (InvalidArgumentException $e) {
return new ApiProblem(400, $e->getMessage());
} catch (\Exception $e) {
return new ApiProblem($this->getHttpStatusCodeFromException($e), $e);
}
Expand Down
12 changes: 12 additions & 0 deletions test/RestControllerTest.php
Expand Up @@ -1511,4 +1511,16 @@ public function testAllowsReturningResponsesReturnedFromResources($method, $even
$result = call_user_func_array(array($this->controller, $method), $argv);
$this->assertSame($response, $result);
}

/**
* @group 74
*/
public function testNonArrayToReplaceListReturnsApiProblem()
{
/** @var ApiProblem $response */
$response = $this->controller->replaceList(new stdClass());
$this->assertInstanceOf('ZF\ApiProblem\ApiProblem', $response);
$details = $response->toArray();
$this->assertEquals(400, $details['status']);
}
}

0 comments on commit fbc9843

Please sign in to comment.