Skip to content

Commit

Permalink
[TEST] Try to trigger issues on trasnaction islation with 7.5
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerom committed Aug 26, 2019
1 parent 782d8b0 commit 433a26f
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions eZ/Publish/API/Repository/Tests/ContentServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4299,6 +4299,52 @@ public function testUpdateContentMetadataInTransactionWithCommit()
$this->assertNotEquals($remoteId, $remoteIdReloaded);
}

/**
* Test for the updateContentMetadata() method, and how cache + transactions play together.
*
* @see \eZ\Publish\API\Repository\ContentService::updateContentMetadata()
* @depends testUpdateContentMetadata
* @depends testLoadContentInfo
*/
public function testUpdateContentMetadataCheckWithinTransaction()
{
$repository = $this->getRepository();
$contentService = $repository->getContentService();
$contentId = $this->generateId('object', 12);

// Load a ContentInfo object, and warmup cache
$contentInfo = $contentService->loadContentInfo($contentId);

// Store remoteId for later testing
$remoteId = $contentInfo->remoteId;

// Start a transaction
$repository->beginTransaction();

try {
// Get metadata update struct and change remoteId
$metadataUpdate = $contentService->newContentMetadataUpdateStruct();
$metadataUpdate->remoteId = md5(microtime(true));

// Update the metadata of the published content object
$contentService->updateContentMetadata(
$contentInfo,
$metadataUpdate
);

// Check that it's been updated
$remoteIdReloaded = $contentService->loadContentInfo($contentId)->remoteId;
$this->assertNotEquals($remoteId, $remoteIdReloaded);

// Commit all changes.
$repository->commit();
} catch (Exception $e) {
// Cleanup hanging transaction on error
$repository->rollback();
throw $e;
}
}

/**
* Test for the deleteVersion() method.
*
Expand Down

0 comments on commit 433a26f

Please sign in to comment.