| @@ 693-710 (lines=18) @@ | ||
| 690 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 691 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 692 | */ |
|
| 693 | public function testInternalLinkValidatorIgnoresMissingRelationOnNotUpdatedField() |
|
| 694 | { |
|
| 695 | $repository = $this->getRepository(); |
|
| 696 | $contentService = $repository->getContentService(); |
|
| 697 | ||
| 698 | list(, $contentB) = $this->prepareInternalLinkValidatorBrokenLinksTestCase($repository); |
|
| 699 | ||
| 700 | // update field w/o erroneous link to trigger validation |
|
| 701 | $contentUpdateStruct = $contentService->newContentUpdateStruct(); |
|
| 702 | $contentUpdateStruct->setField('data', $this->getValidUpdateFieldData(), 'eng-US'); |
|
| 703 | ||
| 704 | $contentDraftB = $contentService->updateContent( |
|
| 705 | $contentService->createContentDraft($contentB->contentInfo)->versionInfo, |
|
| 706 | $contentUpdateStruct |
|
| 707 | ); |
|
| 708 | ||
| 709 | $contentService->publishVersion($contentDraftB->versionInfo); |
|
| 710 | } |
|
| 711 | ||
| 712 | /** |
|
| 713 | * Test updating Content which contains links to deleted Location fails when updating broken field. |
|
| @@ 1406-1429 (lines=24) @@ | ||
| 1403 | * @covers \eZ\Publish\Core\Repository\ContentService::updateContent |
|
| 1404 | * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException |
|
| 1405 | */ |
|
| 1406 | public function testUpdateContentThrowsContentFieldValidationException() |
|
| 1407 | { |
|
| 1408 | list($content, $contentType) = $this->createTestContent(); |
|
| 1409 | ||
| 1410 | /* BEGIN: Use Case */ |
|
| 1411 | $contentService = $this->repository->getContentService(); |
|
| 1412 | ||
| 1413 | $versionInfo = $contentService->loadVersionInfoById( |
|
| 1414 | $content->id, |
|
| 1415 | $content->getVersionInfo()->versionNo |
|
| 1416 | ); |
|
| 1417 | ||
| 1418 | $contentUpdateStruct = $contentService->newContentUpdateStruct(); |
|
| 1419 | $contentUpdateStruct->initialLanguageCode = 'eng-US'; |
|
| 1420 | $contentUpdateStruct->setField( |
|
| 1421 | 'test_required_empty', |
|
| 1422 | 'a string that is too long and will not validate 12345678901234567890123456789012345678901234567890' |
|
| 1423 | ); |
|
| 1424 | ||
| 1425 | // Throws an exception because "test_required_empty" field value is too long and fails |
|
| 1426 | // field definition's string length validator |
|
| 1427 | $updatedContent = $contentService->updateContent($versionInfo, $contentUpdateStruct); |
|
| 1428 | /* END: Use Case */ |
|
| 1429 | } |
|
| 1430 | ||
| 1431 | /** |
|
| 1432 | * Test for the updateContent() method. |
|
| @@ 1437-1456 (lines=20) @@ | ||
| 1434 | * @covers \eZ\Publish\Core\Repository\ContentService::updateContent |
|
| 1435 | * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException |
|
| 1436 | */ |
|
| 1437 | public function testUpdateContentRequiredFieldEmpty() |
|
| 1438 | { |
|
| 1439 | list($content, $contentType) = $this->createTestContent(); |
|
| 1440 | ||
| 1441 | /* BEGIN: Use Case */ |
|
| 1442 | $contentService = $this->repository->getContentService(); |
|
| 1443 | ||
| 1444 | $versionInfo = $contentService->loadVersionInfoById( |
|
| 1445 | $content->id, |
|
| 1446 | $content->getVersionInfo()->versionNo |
|
| 1447 | ); |
|
| 1448 | ||
| 1449 | $contentUpdateStruct = $contentService->newContentUpdateStruct(); |
|
| 1450 | $contentUpdateStruct->initialLanguageCode = 'eng-GB'; |
|
| 1451 | $contentUpdateStruct->setField('test_required_empty', ''); |
|
| 1452 | ||
| 1453 | // Throws an exception because required field is being updated with empty value |
|
| 1454 | $updatedContent = $contentService->updateContent($versionInfo, $contentUpdateStruct); |
|
| 1455 | /* END: Use Case */ |
|
| 1456 | } |
|
| 1457 | ||
| 1458 | /** |
|
| 1459 | * Test for the updateContent() method. |
|
| @@ 1464-1484 (lines=21) @@ | ||
| 1461 | * @covers \eZ\Publish\Core\Repository\ContentService::updateContent |
|
| 1462 | * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentValidationException |
|
| 1463 | */ |
|
| 1464 | public function testUpdateContentThrowsContentValidationExceptionFieldDefinitionNonexistent() |
|
| 1465 | { |
|
| 1466 | list($content, $contentType) = $this->createTestContent(); |
|
| 1467 | ||
| 1468 | /* BEGIN: Use Case */ |
|
| 1469 | $contentService = $this->repository->getContentService(); |
|
| 1470 | ||
| 1471 | $versionInfo = $contentService->loadVersionInfoById( |
|
| 1472 | $content->id, |
|
| 1473 | $content->getVersionInfo()->versionNo |
|
| 1474 | ); |
|
| 1475 | ||
| 1476 | $contentUpdateStruct = $contentService->newContentUpdateStruct(); |
|
| 1477 | $contentUpdateStruct->initialLanguageCode = 'eng-GB'; |
|
| 1478 | $contentUpdateStruct->setField('nonexistent_field_definition_identifier', 'eng-GB'); |
|
| 1479 | ||
| 1480 | // Throws an exception because field definition with identifier "nonexistent_field_definition_identifier" |
|
| 1481 | // does not exist in content draft content type |
|
| 1482 | $updatedContent = $contentService->updateContent($versionInfo, $contentUpdateStruct); |
|
| 1483 | /* END: Use Case */ |
|
| 1484 | } |
|
| 1485 | ||
| 1486 | /** |
|
| 1487 | * Test for the updateContent() method. |
|
| @@ 1494-1514 (lines=21) @@ | ||
| 1491 | * |
|
| 1492 | * @return array |
|
| 1493 | */ |
|
| 1494 | public function testUpdateContentThrowsContentValidationExceptionUntranslatableField() |
|
| 1495 | { |
|
| 1496 | list($content, $contentType) = $this->createTestContent(); |
|
| 1497 | ||
| 1498 | /* BEGIN: Use Case */ |
|
| 1499 | $contentService = $this->repository->getContentService(); |
|
| 1500 | ||
| 1501 | $versionInfo = $contentService->loadVersionInfoById( |
|
| 1502 | $content->id, |
|
| 1503 | $content->getVersionInfo()->versionNo |
|
| 1504 | ); |
|
| 1505 | ||
| 1506 | $contentUpdateStruct = $contentService->newContentUpdateStruct(); |
|
| 1507 | $contentUpdateStruct->initialLanguageCode = 'eng-GB'; |
|
| 1508 | $contentUpdateStruct->setField('test_untranslatable', 'Jabberwock', 'eng-US'); |
|
| 1509 | ||
| 1510 | // Throws an exception because translation was given for a untranslatable field |
|
| 1511 | // Note that it is still permissible to set untranslatable field with main language |
|
| 1512 | $updatedContent = $contentService->updateContent($versionInfo, $contentUpdateStruct); |
|
| 1513 | /* END: Use Case */ |
|
| 1514 | } |
|
| 1515 | ||
| 1516 | /** |
|
| 1517 | * Test for the publishVersion() method. |
|