| @@ 259-283 (lines=25) @@ | ||
| 256 | * |
|
| 257 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
|
| 258 | */ |
|
| 259 | protected function createMultipleLanguageDraftVersion1() |
|
| 260 | { |
|
| 261 | $repository = $this->getRepository(); |
|
| 262 | ||
| 263 | $contentService = $repository->getContentService(); |
|
| 264 | ||
| 265 | /* BEGIN: Inline */ |
|
| 266 | $draft = $this->createContentDraftVersion1(); |
|
| 267 | ||
| 268 | $contentUpdate = $contentService->newContentUpdateStruct(); |
|
| 269 | ||
| 270 | $contentUpdate->initialLanguageCode = 'eng-US'; |
|
| 271 | ||
| 272 | $contentUpdate->setField('name', 'An awesome multi-lang forum²'); |
|
| 273 | ||
| 274 | $contentUpdate->setField('name', 'An awesome multi-lang forum²³', 'eng-GB'); |
|
| 275 | ||
| 276 | $draft = $contentService->updateContent( |
|
| 277 | $draft->getVersionInfo(), |
|
| 278 | $contentUpdate |
|
| 279 | ); |
|
| 280 | /* END: Inline */ |
|
| 281 | ||
| 282 | return $draft; |
|
| 283 | } |
|
| 284 | ||
| 285 | /** |
|
| 286 | * Creates a published content object with versionNo=2 named |
|
| @@ 1522-1545 (lines=24) @@ | ||
| 1519 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 1520 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
|
| 1521 | */ |
|
| 1522 | public function testUpdateContentThrowsBadStateException() |
|
| 1523 | { |
|
| 1524 | $repository = $this->getRepository(); |
|
| 1525 | ||
| 1526 | $contentService = $repository->getContentService(); |
|
| 1527 | ||
| 1528 | /* BEGIN: Use Case */ |
|
| 1529 | $content = $this->createContentVersion1(); |
|
| 1530 | ||
| 1531 | // Now create an update struct and modify some fields |
|
| 1532 | $contentUpdateStruct = $contentService->newContentUpdateStruct(); |
|
| 1533 | $contentUpdateStruct->setField('title', 'An awesome² story about ezp.'); |
|
| 1534 | $contentUpdateStruct->setField('title', 'An awesome²³ story about ezp.', 'eng-GB'); |
|
| 1535 | ||
| 1536 | $contentUpdateStruct->initialLanguageCode = 'eng-US'; |
|
| 1537 | ||
| 1538 | // This call will fail with a "BadStateException", because $publishedContent |
|
| 1539 | // is not a draft. |
|
| 1540 | $contentService->updateContent( |
|
| 1541 | $content->getVersionInfo(), |
|
| 1542 | $contentUpdateStruct |
|
| 1543 | ); |
|
| 1544 | /* END: Use Case */ |
|
| 1545 | } |
|
| 1546 | ||
| 1547 | /** |
|
| 1548 | * Test for the updateContent() method. |
|