Skip to content

Commit

Permalink
Add test for errorArray method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Johnson committed Apr 8, 2016
1 parent 3c202ec commit 9a4b143
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/Integration/ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,27 @@ public function it_can_respond_with_a_wrong_arguments_error()
$this->assertEquals('400', $response->status());
}

/**
* @test
*/
public function it_can_respond_with_an_array_of_errors()
{
$errorArray = $this->getMethod('errorArray');
$testController = new TestController();

$response = $errorArray->invoke($testController, ['field_name' => 'This field_name had an error.']);
$array = json_decode(json_encode($response->getData()), true);

$expectedArray = [
'errors' => [
'field_name' => 'This field_name had an error.'
]
];

$this->assertEquals($expectedArray, $array);
$this->assertEquals('422', $response->status());
}

/**
* @param $methodName
* @return mixed
Expand Down

0 comments on commit 9a4b143

Please sign in to comment.