public function testLoadException() { $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']); }
public function testFileTooBig() { $this->viewMock->expects($this->any())->method('filesize')->willReturn(4194304 + 1); $result = $this->controller->load('/', 'foo.bar'); $data = $result->getData(); $status = $result->getStatus(); $this->assertSame(400, $status); $this->assertArrayHasKey('message', $data); $this->assertSame('This file is too big to be opened. Please download the file instead.', $data['message']); }