|
@@ 364-389 (lines=26) @@
|
| 361 |
|
* @expectedException Exception |
| 362 |
|
* @expectedExceptionMessage no ID given for Textnode "someNodeName1" |
| 363 |
|
*/ |
| 364 |
|
public function testRunWithTextnodeWithoutTwineID() |
| 365 |
|
{ |
| 366 |
|
$importfile = $this->getDummyImportfile(); |
| 367 |
|
|
| 368 |
|
$this->fileExtractorMock->expects(self::any()) |
| 369 |
|
->method('extract') |
| 370 |
|
->willReturn('readable.extracted'); |
| 371 |
|
|
| 372 |
|
self::$freadStack = [ |
| 373 |
|
'<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n", |
| 374 |
|
'<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n", |
| 375 |
|
'<tw-passagedata pid="1" name="someNodeName1" tags="Freigegeben" position="104,30">lorem ipsum', |
| 376 |
|
'lorem ipsum</tw-passagedata></tw-storydata>', |
| 377 |
|
]; |
| 378 |
|
|
| 379 |
|
$textnode = new Textnode(); |
| 380 |
|
|
| 381 |
|
$this->textnodeRepository->expects($this->any()) |
| 382 |
|
->method('find') |
| 383 |
|
->will($this->returnValue($textnode)); |
| 384 |
|
|
| 385 |
|
$this->textnodeRepository->expects($this->never()) |
| 386 |
|
->method('save'); |
| 387 |
|
|
| 388 |
|
$this->importTwine->run($importfile); |
| 389 |
|
} |
| 390 |
|
|
| 391 |
|
/** |
| 392 |
|
* @expectedException Exception |
|
@@ 395-420 (lines=26) @@
|
| 392 |
|
* @expectedException Exception |
| 393 |
|
* @expectedExceptionMessage no ID given for Textnode "someNodeName1" |
| 394 |
|
*/ |
| 395 |
|
public function testRunWithTextnodeWithoutAnyTag() |
| 396 |
|
{ |
| 397 |
|
$importfile = $this->getDummyImportfile(); |
| 398 |
|
|
| 399 |
|
$this->fileExtractorMock->expects(self::any()) |
| 400 |
|
->method('extract') |
| 401 |
|
->willReturn('readable.extracted'); |
| 402 |
|
|
| 403 |
|
self::$freadStack = [ |
| 404 |
|
'<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n", |
| 405 |
|
'<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n", |
| 406 |
|
'<tw-passagedata pid="1" name="someNodeName1" tags="" position="104,30">lorem ipsum', |
| 407 |
|
'lorem ipsum</tw-passagedata></tw-storydata>', |
| 408 |
|
]; |
| 409 |
|
|
| 410 |
|
$textnode = new Textnode(); |
| 411 |
|
|
| 412 |
|
$this->textnodeRepository->expects($this->any()) |
| 413 |
|
->method('find') |
| 414 |
|
->will($this->returnValue($textnode)); |
| 415 |
|
|
| 416 |
|
$this->textnodeRepository->expects($this->never()) |
| 417 |
|
->method('save'); |
| 418 |
|
|
| 419 |
|
$this->importTwine->run($importfile); |
| 420 |
|
} |
| 421 |
|
|
| 422 |
|
/** |
| 423 |
|
* tests identifying a textnode by a twine ID |
|
@@ 1100-1127 (lines=28) @@
|
| 1097 |
|
* @expectedException \Exception |
| 1098 |
|
* @expectedExceptionMessageRegExp /Error .* occurred while parsing the Twine archive file 'somefilename_readable'/ |
| 1099 |
|
*/ |
| 1100 |
|
public function testRunWithParserException(): void |
| 1101 |
|
{ |
| 1102 |
|
self::$freadStack = [ |
| 1103 |
|
'<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n", |
| 1104 |
|
'<tw-passagedata pid"1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum', |
| 1105 |
|
'lorem ipsum</tw-passagedata>', |
| 1106 |
|
'</tw-storydata>', |
| 1107 |
|
]; |
| 1108 |
|
|
| 1109 |
|
$textnode1 = new Textnode(); |
| 1110 |
|
$textnode1->setId('someId0'); |
| 1111 |
|
|
| 1112 |
|
$this->textnodeRepository->expects($this->any()) |
| 1113 |
|
->method('findByTwineId') |
| 1114 |
|
->willReturn($textnode1); |
| 1115 |
|
|
| 1116 |
|
$this->textnodeRepository->expects($this->any()) |
| 1117 |
|
->method('find') |
| 1118 |
|
->willReturn($textnode1); |
| 1119 |
|
|
| 1120 |
|
$this->fileExtractorMock->expects(self::any()) |
| 1121 |
|
->method('extract') |
| 1122 |
|
->willReturn('readable.extracted'); |
| 1123 |
|
|
| 1124 |
|
$importfile = $this->getDummyImportfile(); |
| 1125 |
|
|
| 1126 |
|
$this->importTwine->run($importfile); |
| 1127 |
|
} |
| 1128 |
|
|
| 1129 |
|
/** |
| 1130 |
|
* @return void |
|
@@ 1134-1161 (lines=28) @@
|
| 1131 |
|
* @expectedException \Exception |
| 1132 |
|
* @expectedExceptionMessage There is a 'tw-storydata' in the Twine archive file 'somefilename_readable' which is missing its 'name' attribute |
| 1133 |
|
*/ |
| 1134 |
|
public function testRunWithInvalidStoryDataElement(): void |
| 1135 |
|
{ |
| 1136 |
|
self::$freadStack = [ |
| 1137 |
|
'<tw-storydata startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n", |
| 1138 |
|
'<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum', |
| 1139 |
|
'lorem ipsum</tw-passagedata>', |
| 1140 |
|
'</tw-storydata>', |
| 1141 |
|
]; |
| 1142 |
|
|
| 1143 |
|
$textnode1 = new Textnode(); |
| 1144 |
|
$textnode1->setId('someId0'); |
| 1145 |
|
|
| 1146 |
|
$this->textnodeRepository->expects($this->any()) |
| 1147 |
|
->method('findByTwineId') |
| 1148 |
|
->willReturn($textnode1); |
| 1149 |
|
|
| 1150 |
|
$this->textnodeRepository->expects($this->any()) |
| 1151 |
|
->method('find') |
| 1152 |
|
->willReturn($textnode1); |
| 1153 |
|
|
| 1154 |
|
$this->fileExtractorMock->expects(self::any()) |
| 1155 |
|
->method('extract') |
| 1156 |
|
->willReturn('readable.extracted'); |
| 1157 |
|
|
| 1158 |
|
$importfile = $this->getDummyImportfile(); |
| 1159 |
|
|
| 1160 |
|
$this->importTwine->run($importfile); |
| 1161 |
|
} |
| 1162 |
|
|
| 1163 |
|
private function getDummyImportfile(array $data = []): Importfile |
| 1164 |
|
{ |