Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/files_texteditor.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-10-09 18:29:06 +0300
committerBjoern Schiessle <schiessle@owncloud.com>2015-10-09 18:39:12 +0300
commit6b630d25f3828915f41e39b942852fe8f2406da2 (patch)
tree62eb926a9ee41d92b18cdb2f4e64c7e2e3e71849 /tests
parent371192a947302884a2c5d8f8d4d1f75bf1d4edd9 (diff)
if the exception contain a hint what went wrong we display it to the user
Diffstat (limited to 'tests')
-rw-r--r--tests/controller/filehandlingcontrollertest.php22
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
*