From 6b630d25f3828915f41e39b942852fe8f2406da2 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Fri, 9 Oct 2015 17:29:06 +0200 Subject: if the exception contain a hint what went wrong we display it to the user --- tests/controller/filehandlingcontrollertest.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/controller/filehandlingcontrollertest.php b/tests/controller/filehandlingcontrollertest.php index 3e78c1d..70d7fee 100644 --- a/tests/controller/filehandlingcontrollertest.php +++ b/tests/controller/filehandlingcontrollertest.php @@ -116,14 +116,14 @@ class FileHandlingControllerTest extends TestCase { ); } - public function testLoadException() { + public function testLoadExceptionWithNoHint() { $exceptionHint = 'test exception'; $this->viewMock->expects($this->any()) ->method('file_get_contents') ->willReturnCallback(function() use ($exceptionHint) { - throw new HintException('error message', $exceptionHint); + throw new \Exception(); }); $result = $this->controller->load('/', 'test.txt'); @@ -134,6 +134,24 @@ class FileHandlingControllerTest extends TestCase { $this->assertSame('An internal server error occurred.', $data['message']); } + public function testLoadExceptionWithHint() { + + $exceptionHint = 'test exception'; + + $this->viewMock->expects($this->any()) + ->method('file_get_contents') + ->willReturnCallback(function() use ($exceptionHint) { + throw new HintException('error message', $exceptionHint); + }); + + $result = $this->controller->load('/', 'test.txt'); + $data = $result->getData(); + + $this->assertSame(400, $result->getStatus()); + $this->assertArrayHasKey('message', $data); + $this->assertSame($exceptionHint, $data['message']); + } + /** * @dataProvider dataTestSave * -- cgit v1.2.3