|
@@ 1408-1431 (lines=24) @@
|
| 1405 |
|
* @covers \eZ\Publish\Core\Repository\ContentService::updateContent |
| 1406 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException |
| 1407 |
|
*/ |
| 1408 |
|
public function testUpdateContentThrowsContentFieldValidationException() |
| 1409 |
|
{ |
| 1410 |
|
list($content, $contentType) = $this->createTestContent(); |
| 1411 |
|
|
| 1412 |
|
/* BEGIN: Use Case */ |
| 1413 |
|
$contentService = $this->repository->getContentService(); |
| 1414 |
|
|
| 1415 |
|
$versionInfo = $contentService->loadVersionInfoById( |
| 1416 |
|
$content->id, |
| 1417 |
|
$content->getVersionInfo()->versionNo |
| 1418 |
|
); |
| 1419 |
|
|
| 1420 |
|
$contentUpdateStruct = $contentService->newContentUpdateStruct(); |
| 1421 |
|
$contentUpdateStruct->initialLanguageCode = 'eng-US'; |
| 1422 |
|
$contentUpdateStruct->setField( |
| 1423 |
|
'test_required_empty', |
| 1424 |
|
'a string that is too long and will not validate 12345678901234567890123456789012345678901234567890' |
| 1425 |
|
); |
| 1426 |
|
|
| 1427 |
|
// Throws an exception because "test_required_empty" field value is too long and fails |
| 1428 |
|
// field definition's string length validator |
| 1429 |
|
$updatedContent = $contentService->updateContent($versionInfo, $contentUpdateStruct); |
| 1430 |
|
/* END: Use Case */ |
| 1431 |
|
} |
| 1432 |
|
|
| 1433 |
|
/** |
| 1434 |
|
* Test for the updateContent() method. |
|
@@ 1439-1458 (lines=20) @@
|
| 1436 |
|
* @covers \eZ\Publish\Core\Repository\ContentService::updateContent |
| 1437 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\ContentValidationException |
| 1438 |
|
*/ |
| 1439 |
|
public function testUpdateContentThrowsContentValidationExceptionRequiredFieldEmpty() |
| 1440 |
|
{ |
| 1441 |
|
list($content, $contentType) = $this->createTestContent(); |
| 1442 |
|
|
| 1443 |
|
/* BEGIN: Use Case */ |
| 1444 |
|
$contentService = $this->repository->getContentService(); |
| 1445 |
|
|
| 1446 |
|
$versionInfo = $contentService->loadVersionInfoById( |
| 1447 |
|
$content->id, |
| 1448 |
|
$content->getVersionInfo()->versionNo |
| 1449 |
|
); |
| 1450 |
|
|
| 1451 |
|
$contentUpdateStruct = $contentService->newContentUpdateStruct(); |
| 1452 |
|
$contentUpdateStruct->initialLanguageCode = 'eng-GB'; |
| 1453 |
|
$contentUpdateStruct->setField('test_required_empty', ''); |
| 1454 |
|
|
| 1455 |
|
// Throws an exception because required field is being updated with empty value |
| 1456 |
|
$updatedContent = $contentService->updateContent($versionInfo, $contentUpdateStruct); |
| 1457 |
|
/* END: Use Case */ |
| 1458 |
|
} |
| 1459 |
|
|
| 1460 |
|
/** |
| 1461 |
|
* Test for the updateContent() method. |
|
@@ 1466-1486 (lines=21) @@
|
| 1463 |
|
* @covers \eZ\Publish\Core\Repository\ContentService::updateContent |
| 1464 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\ContentValidationException |
| 1465 |
|
*/ |
| 1466 |
|
public function testUpdateContentThrowsContentValidationExceptionFieldDefinitionNonexistent() |
| 1467 |
|
{ |
| 1468 |
|
list($content, $contentType) = $this->createTestContent(); |
| 1469 |
|
|
| 1470 |
|
/* BEGIN: Use Case */ |
| 1471 |
|
$contentService = $this->repository->getContentService(); |
| 1472 |
|
|
| 1473 |
|
$versionInfo = $contentService->loadVersionInfoById( |
| 1474 |
|
$content->id, |
| 1475 |
|
$content->getVersionInfo()->versionNo |
| 1476 |
|
); |
| 1477 |
|
|
| 1478 |
|
$contentUpdateStruct = $contentService->newContentUpdateStruct(); |
| 1479 |
|
$contentUpdateStruct->initialLanguageCode = 'eng-GB'; |
| 1480 |
|
$contentUpdateStruct->setField('nonexistent_field_definition_identifier', 'eng-GB'); |
| 1481 |
|
|
| 1482 |
|
// Throws an exception because field definition with identifier "nonexistent_field_definition_identifier" |
| 1483 |
|
// does not exist in content draft content type |
| 1484 |
|
$updatedContent = $contentService->updateContent($versionInfo, $contentUpdateStruct); |
| 1485 |
|
/* END: Use Case */ |
| 1486 |
|
} |
| 1487 |
|
|
| 1488 |
|
/** |
| 1489 |
|
* Test for the updateContent() method. |
|
@@ 1496-1516 (lines=21) @@
|
| 1493 |
|
* |
| 1494 |
|
* @return array |
| 1495 |
|
*/ |
| 1496 |
|
public function testUpdateContentThrowsContentValidationExceptionUntranslatableField() |
| 1497 |
|
{ |
| 1498 |
|
list($content, $contentType) = $this->createTestContent(); |
| 1499 |
|
|
| 1500 |
|
/* BEGIN: Use Case */ |
| 1501 |
|
$contentService = $this->repository->getContentService(); |
| 1502 |
|
|
| 1503 |
|
$versionInfo = $contentService->loadVersionInfoById( |
| 1504 |
|
$content->id, |
| 1505 |
|
$content->getVersionInfo()->versionNo |
| 1506 |
|
); |
| 1507 |
|
|
| 1508 |
|
$contentUpdateStruct = $contentService->newContentUpdateStruct(); |
| 1509 |
|
$contentUpdateStruct->initialLanguageCode = 'eng-GB'; |
| 1510 |
|
$contentUpdateStruct->setField('test_untranslatable', 'Jabberwock', 'eng-US'); |
| 1511 |
|
|
| 1512 |
|
// Throws an exception because translation was given for a untranslatable field |
| 1513 |
|
// Note that it is still permissible to set untranslatable field with main language |
| 1514 |
|
$updatedContent = $contentService->updateContent($versionInfo, $contentUpdateStruct); |
| 1515 |
|
/* END: Use Case */ |
| 1516 |
|
} |
| 1517 |
|
|
| 1518 |
|
/** |
| 1519 |
|
* Test for the publishVersion() method. |