|
@@ 140-167 (lines=28) @@
|
| 137 |
|
* @param \Exception $exception |
| 138 |
|
* @param string $expectedMessage |
| 139 |
|
*/ |
| 140 |
|
public function testLoadMetadataForRenamedDocumentExceptions(\Exception $exception, $expectedMessage) { |
| 141 |
|
$dir = ''; |
| 142 |
|
$bookID = 'Ra5WnkxImoOE'; |
| 143 |
|
$title = "Borderland City in New India"; |
| 144 |
|
$path = $dir . '/'. $title. '.renamed.paperhive'; |
| 145 |
|
$contents = $this->fakeAll($bookID, $title); |
| 146 |
|
|
| 147 |
|
$this->viewMock->expects($this->once()) |
| 148 |
|
->method('file_exists') |
| 149 |
|
->willReturn(true); |
| 150 |
|
|
| 151 |
|
$this->viewMock->expects($this->any()) |
| 152 |
|
->method('file_get_contents') |
| 153 |
|
->willReturnCallback(function() use ($exception) { |
| 154 |
|
throw $exception; |
| 155 |
|
}); |
| 156 |
|
|
| 157 |
|
$this->viewMock->expects($this->any()) |
| 158 |
|
->method('rename') |
| 159 |
|
->willReturn(false); |
| 160 |
|
|
| 161 |
|
$result = $this->controller->loadMetadata('/', $path, "true"); |
| 162 |
|
$data = $result->getData(); |
| 163 |
|
|
| 164 |
|
$this->assertSame(400, $result->getStatus()); |
| 165 |
|
$this->assertArrayHasKey('message', $data); |
| 166 |
|
$this->assertSame($expectedMessage, $data['message']); |
| 167 |
|
} |
| 168 |
|
|
| 169 |
|
public function testLoadMetadataForRenamedDocumentNoExtension() { |
| 170 |
|
$dir = ''; |
|
@@ 226-251 (lines=26) @@
|
| 223 |
|
$this->assertSame('File is obsolete, incorrectly renamed or cannot be read.', $data['message']); |
| 224 |
|
} |
| 225 |
|
|
| 226 |
|
public function testLoadMetadataForRenamedDocumentFailRename() { |
| 227 |
|
$dir = ''; |
| 228 |
|
$bookID = 'Ra5WnkxImoOE'; |
| 229 |
|
$title = "Borderland City in New India"; |
| 230 |
|
$path = $dir . '/'. $title. '.renamed.paperhive'; |
| 231 |
|
$contents = $this->fakeAll($bookID, $title); |
| 232 |
|
|
| 233 |
|
$this->viewMock->expects($this->once()) |
| 234 |
|
->method('file_exists') |
| 235 |
|
->willReturn(true); |
| 236 |
|
|
| 237 |
|
$this->viewMock->expects($this->once()) |
| 238 |
|
->method('file_get_contents') |
| 239 |
|
->willReturn($contents); |
| 240 |
|
|
| 241 |
|
$this->viewMock->expects($this->once()) |
| 242 |
|
->method('rename') |
| 243 |
|
->willReturn(false); |
| 244 |
|
|
| 245 |
|
$result = $this->controller->loadMetadata('/', $path, "true"); |
| 246 |
|
$data = $result->getData(); |
| 247 |
|
|
| 248 |
|
$this->assertSame(400, $result->getStatus()); |
| 249 |
|
$this->assertArrayHasKey('message', $data); |
| 250 |
|
$this->assertSame('File is obsolete, incorrectly renamed or cannot be read.', $data['message']); |
| 251 |
|
} |
| 252 |
|
|
| 253 |
|
public function testLoadMetadataForRenamedDocument() { |
| 254 |
|
$dir = ''; |