|
@@ 66-76 (lines=11) @@
|
| 63 |
|
/** |
| 64 |
|
* @dataProvider setViewWithAllowedViewDataProvider |
| 65 |
|
*/ |
| 66 |
|
public function testSetViewWithAllowedView($view) { |
| 67 |
|
$this->config->expects($this->once()) |
| 68 |
|
->method('setUserValue') |
| 69 |
|
->with('user123', $this->appName, 'currentView', $view); |
| 70 |
|
|
| 71 |
|
$actual = $this->controller->setConfig('view', $view); |
| 72 |
|
|
| 73 |
|
$this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $actual); |
| 74 |
|
$this->assertEquals([], $actual->getData()); |
| 75 |
|
$this->assertEquals(200, $actual->getStatus()); |
| 76 |
|
} |
| 77 |
|
|
| 78 |
|
public function setViewWithAllowedViewDataProvider() { |
| 79 |
|
return [ |
|
@@ 136-146 (lines=11) @@
|
| 133 |
|
/** |
| 134 |
|
* @dataProvider setPopoverWithAllowedValueDataProvider |
| 135 |
|
*/ |
| 136 |
|
public function testSetPopoverWithAllowedValue($value) { |
| 137 |
|
$this->config->expects($this->once()) |
| 138 |
|
->method('setUserValue') |
| 139 |
|
->with('user123', $this->appName, 'skipPopover', $value); |
| 140 |
|
|
| 141 |
|
$actual = $this->controller->setConfig('skipPopover', $value); |
| 142 |
|
|
| 143 |
|
$this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $actual); |
| 144 |
|
$this->assertEquals([], $actual->getData()); |
| 145 |
|
$this->assertEquals(200, $actual->getStatus()); |
| 146 |
|
} |
| 147 |
|
|
| 148 |
|
public function setPopoverWithAllowedValueDataProvider() { |
| 149 |
|
return [ |
|
@@ 202-212 (lines=11) @@
|
| 199 |
|
$this->assertEquals(500, $actual->getStatus()); |
| 200 |
|
} |
| 201 |
|
|
| 202 |
|
public function testSetFirstRun() { |
| 203 |
|
$this->config->expects($this->once()) |
| 204 |
|
->method('setUserValue') |
| 205 |
|
->with('user123', $this->appName, 'firstRun', 'no'); |
| 206 |
|
|
| 207 |
|
$actual = $this->controller->setConfig('firstRun', 'some_random_ignored_value'); |
| 208 |
|
|
| 209 |
|
$this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $actual); |
| 210 |
|
$this->assertEquals([], $actual->getData()); |
| 211 |
|
$this->assertEquals(200, $actual->getStatus()); |
| 212 |
|
} |
| 213 |
|
|
| 214 |
|
public function testSetFirstRunWithException() { |
| 215 |
|
$this->config->expects($this->once()) |
|
@@ 94-105 (lines=12) @@
|
| 91 |
|
$this->assertEquals(422, $actual->getStatus()); |
| 92 |
|
} |
| 93 |
|
|
| 94 |
|
public function testSetViewWithConfigException() { |
| 95 |
|
$this->config->expects($this->once()) |
| 96 |
|
->method('setUserValue') |
| 97 |
|
->with('user123', $this->appName, 'currentView', 'month') |
| 98 |
|
->will($this->throwException(new \Exception)); |
| 99 |
|
|
| 100 |
|
$actual = $this->controller->setConfig('view', 'month'); |
| 101 |
|
|
| 102 |
|
$this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $actual); |
| 103 |
|
$this->assertEquals([], $actual->getData()); |
| 104 |
|
$this->assertEquals(500, $actual->getStatus()); |
| 105 |
|
} |
| 106 |
|
|
| 107 |
|
public function testGetView() { |
| 108 |
|
$this->config->expects($this->once()) |
|
@@ 120-131 (lines=12) @@
|
| 117 |
|
$this->assertEquals(200, $actual->getStatus()); |
| 118 |
|
} |
| 119 |
|
|
| 120 |
|
public function testGetViewWithConfigException() { |
| 121 |
|
$this->config->expects($this->once()) |
| 122 |
|
->method('getUserValue') |
| 123 |
|
->with('user123', $this->appName, 'currentView', 'month') |
| 124 |
|
->will($this->throwException(new \Exception)); |
| 125 |
|
|
| 126 |
|
$actual = $this->controller->getConfig('view'); |
| 127 |
|
|
| 128 |
|
$this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $actual); |
| 129 |
|
$this->assertEquals([], $actual->getData()); |
| 130 |
|
$this->assertEquals(500, $actual->getStatus()); |
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
/** |
| 134 |
|
* @dataProvider setPopoverWithAllowedValueDataProvider |
|
@@ 189-200 (lines=12) @@
|
| 186 |
|
$this->assertEquals(200, $actual->getStatus()); |
| 187 |
|
} |
| 188 |
|
|
| 189 |
|
public function testGetPopoverWithConfigException() { |
| 190 |
|
$this->config->expects($this->once()) |
| 191 |
|
->method('getUserValue') |
| 192 |
|
->with('user123', $this->appName, 'skipPopover', 'no') |
| 193 |
|
->will($this->throwException(new \Exception)); |
| 194 |
|
|
| 195 |
|
$actual = $this->controller->getConfig('skipPopover'); |
| 196 |
|
|
| 197 |
|
$this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $actual); |
| 198 |
|
$this->assertEquals([], $actual->getData()); |
| 199 |
|
$this->assertEquals(500, $actual->getStatus()); |
| 200 |
|
} |
| 201 |
|
|
| 202 |
|
public function testSetFirstRun() { |
| 203 |
|
$this->config->expects($this->once()) |
|
@@ 240-251 (lines=12) @@
|
| 237 |
|
$this->assertEquals(200, $actual->getStatus()); |
| 238 |
|
} |
| 239 |
|
|
| 240 |
|
public function testGetFirstRunWithException() { |
| 241 |
|
$this->config->expects($this->once()) |
| 242 |
|
->method('getUserValue') |
| 243 |
|
->with('user123', $this->appName, 'firstRun', 'yes') |
| 244 |
|
->will($this->throwException(new \Exception)); |
| 245 |
|
|
| 246 |
|
$actual = $this->controller->getConfig('firstRun'); |
| 247 |
|
|
| 248 |
|
$this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $actual); |
| 249 |
|
$this->assertEquals([], $actual->getData()); |
| 250 |
|
$this->assertEquals(500, $actual->getStatus()); |
| 251 |
|
} |
| 252 |
|
|
| 253 |
|
public function testSetTimezone() { |
| 254 |
|
$this->config->expects($this->once()) |
|
@@ 291-302 (lines=12) @@
|
| 288 |
|
$this->assertEquals(200, $actual->getStatus()); |
| 289 |
|
} |
| 290 |
|
|
| 291 |
|
public function testGetTimezoneWithException() { |
| 292 |
|
$this->config->expects($this->once()) |
| 293 |
|
->method('getUserValue') |
| 294 |
|
->with('user123', $this->appName, 'timezone', 'automatic') |
| 295 |
|
->will($this->throwException(new \Exception)); |
| 296 |
|
|
| 297 |
|
$actual = $this->controller->getConfig('timezone'); |
| 298 |
|
|
| 299 |
|
$this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $actual); |
| 300 |
|
$this->assertEquals([], $actual->getData()); |
| 301 |
|
$this->assertEquals(500, $actual->getStatus()); |
| 302 |
|
} |
| 303 |
|
|
| 304 |
|
public function testGetNotExistingConfig() { |
| 305 |
|
$actual = $this->controller->getConfig('foo'); |