diff options
Diffstat (limited to 'tests/controller/filehandlingcontrollertest.php')
-rw-r--r-- | tests/controller/filehandlingcontrollertest.php | 22 |
1 files changed, 20 insertions, 2 deletions
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 * |