| @@ 260-284 (lines=25) @@ | ||
| 257 | * |
|
| 258 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
|
| 259 | */ |
|
| 260 | protected function createMultipleLanguageDraftVersion1() |
|
| 261 | { |
|
| 262 | $repository = $this->getRepository(); |
|
| 263 | ||
| 264 | $contentService = $repository->getContentService(); |
|
| 265 | ||
| 266 | /* BEGIN: Inline */ |
|
| 267 | $draft = $this->createContentDraftVersion1(); |
|
| 268 | ||
| 269 | $contentUpdate = $contentService->newContentUpdateStruct(); |
|
| 270 | ||
| 271 | $contentUpdate->initialLanguageCode = 'eng-US'; |
|
| 272 | ||
| 273 | $contentUpdate->setField('name', 'An awesome multi-lang forum²'); |
|
| 274 | ||
| 275 | $contentUpdate->setField('name', 'An awesome multi-lang forum²³', 'eng-GB'); |
|
| 276 | ||
| 277 | $draft = $contentService->updateContent( |
|
| 278 | $draft->getVersionInfo(), |
|
| 279 | $contentUpdate |
|
| 280 | ); |
|
| 281 | /* END: Inline */ |
|
| 282 | ||
| 283 | return $draft; |
|
| 284 | } |
|
| 285 | ||
| 286 | /** |
|
| 287 | * Creates a published content object with versionNo=2 named |
|
| @@ 1362-1385 (lines=24) @@ | ||
| 1359 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 1360 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
|
| 1361 | */ |
|
| 1362 | public function testUpdateContentThrowsBadStateException() |
|
| 1363 | { |
|
| 1364 | $repository = $this->getRepository(); |
|
| 1365 | ||
| 1366 | $contentService = $repository->getContentService(); |
|
| 1367 | ||
| 1368 | /* BEGIN: Use Case */ |
|
| 1369 | $content = $this->createContentVersion1(); |
|
| 1370 | ||
| 1371 | // Now create an update struct and modify some fields |
|
| 1372 | $contentUpdateStruct = $contentService->newContentUpdateStruct(); |
|
| 1373 | $contentUpdateStruct->setField('title', 'An awesome² story about ezp.'); |
|
| 1374 | $contentUpdateStruct->setField('title', 'An awesome²³ story about ezp.', 'eng-GB'); |
|
| 1375 | ||
| 1376 | $contentUpdateStruct->initialLanguageCode = 'eng-US'; |
|
| 1377 | ||
| 1378 | // This call will fail with a "BadStateException", because $publishedContent |
|
| 1379 | // is not a draft. |
|
| 1380 | $contentService->updateContent( |
|
| 1381 | $content->getVersionInfo(), |
|
| 1382 | $contentUpdateStruct |
|
| 1383 | ); |
|
| 1384 | /* END: Use Case */ |
|
| 1385 | } |
|
| 1386 | ||
| 1387 | /** |
|
| 1388 | * Test for the updateContent() method. |
|