From a0a8a0be58841d1ee05a270b55428fd8db7e3995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Wed, 11 Oct 2023 20:15:32 +0200 Subject: [PATCH] IBX-6738: Fixed content type group deletion when it contains orphaned content type drafts (tests) --- .../Repository/ContentTypeServiceTest.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/integration/Core/Repository/ContentTypeServiceTest.php b/tests/integration/Core/Repository/ContentTypeServiceTest.php index 7f125bedee..d5b1a16f51 100644 --- a/tests/integration/Core/Repository/ContentTypeServiceTest.php +++ b/tests/integration/Core/Repository/ContentTypeServiceTest.php @@ -600,6 +600,40 @@ public function testDeleteContentTypeGroup() $this->fail('Content type group not deleted.'); } + public function testDeleteContentTypeGroupWithOrphanedContentTypeDrafts(): void + { + $this->expectException(NotFoundException::class); + + $repository = $this->getRepository(); + + /* BEGIN: Use Case */ + $contentTypeService = $repository->getContentTypeService(); + + $groupCreate = $contentTypeService->newContentTypeGroupCreateStruct( + 'new-group' + ); + $contentTypeService->createContentTypeGroup($groupCreate); + + $group = $contentTypeService->loadContentTypeGroupByIdentifier('new-group'); + for ($i = 0; $i < 3; ++$i) { + $contentTypeCreateStruct = $contentTypeService->newContentTypeCreateStruct('content_type_draft_' . $i); + $contentTypeCreateStruct->mainLanguageCode = 'eng-GB'; + $contentTypeCreateStruct->names = [ + 'eng-GB' => 'content_type_draft_' . $i, + ]; + + $contentTypeService->createContentType($contentTypeCreateStruct, [$group]); + } + + $contentTypeService->deleteContentTypeGroup($group); + /* END: Use Case */ + + // loadContentTypeGroup should throw NotFoundException + $contentTypeService->loadContentTypeGroup($group->id); + + $this->fail('Content type group not deleted.'); + } + /** * Test for the newContentTypeCreateStruct() method. *