| @@ 1066-1093 (lines=28) @@ | ||
| 1063 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testNewUserCreateStruct |
|
| 1064 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
|
| 1065 | */ |
|
| 1066 | public function testCreateUserInTransactionWithRollback() |
|
| 1067 | { |
|
| 1068 | $repository = $this->getRepository(); |
|
| 1069 | $userService = $repository->getUserService(); |
|
| 1070 | ||
| 1071 | /* BEGIN: Use Case */ |
|
| 1072 | $repository->beginTransaction(); |
|
| 1073 | ||
| 1074 | try { |
|
| 1075 | $user = $this->createUserVersion1(); |
|
| 1076 | } catch (Exception $e) { |
|
| 1077 | // Cleanup hanging transaction on error |
|
| 1078 | $repository->rollback(); |
|
| 1079 | throw $e; |
|
| 1080 | } |
|
| 1081 | ||
| 1082 | $repository->rollback(); |
|
| 1083 | ||
| 1084 | try { |
|
| 1085 | // Throws exception since creation of user was rolled back |
|
| 1086 | $loadedUser = $userService->loadUser($user->id); |
|
| 1087 | } catch (NotFoundException $e) { |
|
| 1088 | return; |
|
| 1089 | } |
|
| 1090 | /* END: Use Case */ |
|
| 1091 | ||
| 1092 | $this->fail('User object still exists after rollback.'); |
|
| 1093 | } |
|
| 1094 | ||
| 1095 | /** |
|
| 1096 | * Test creating a user throwing NotFoundException. |
|
| @@ 4337-4369 (lines=33) @@ | ||
| 4334 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately |
|
| 4335 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentThrowsNotFoundException |
|
| 4336 | */ |
|
| 4337 | public function testCreateContentWithLocationCreateParameterInTransactionWithRollback() |
|
| 4338 | { |
|
| 4339 | $repository = $this->getRepository(); |
|
| 4340 | ||
| 4341 | $contentService = $repository->getContentService(); |
|
| 4342 | ||
| 4343 | /* BEGIN: Use Case */ |
|
| 4344 | // Start a transaction |
|
| 4345 | $repository->beginTransaction(); |
|
| 4346 | ||
| 4347 | try { |
|
| 4348 | $draft = $this->createContentDraftVersion1(); |
|
| 4349 | } catch (Exception $e) { |
|
| 4350 | // Cleanup hanging transaction on error |
|
| 4351 | $repository->rollback(); |
|
| 4352 | throw $e; |
|
| 4353 | } |
|
| 4354 | ||
| 4355 | $contentId = $draft->id; |
|
| 4356 | ||
| 4357 | // Roleback the transaction |
|
| 4358 | $repository->rollback(); |
|
| 4359 | ||
| 4360 | try { |
|
| 4361 | // This call will fail with a "NotFoundException" |
|
| 4362 | $contentService->loadContent($contentId); |
|
| 4363 | } catch (NotFoundException $e) { |
|
| 4364 | return; |
|
| 4365 | } |
|
| 4366 | /* END: Use Case */ |
|
| 4367 | ||
| 4368 | $this->fail('Can still load content object after rollback.'); |
|
| 4369 | } |
|
| 4370 | ||
| 4371 | /** |
|
| 4372 | * Test for the createContent() method. |
|