99namespace Ibexa \Tests \Integration \Core \Repository \Filtering ;
1010
1111use function array_map ;
12+ use Ibexa \Contracts \Core \Repository \Values \Content \Content ;
1213use Ibexa \Contracts \Core \Repository \Values \Content \Query ;
1314use Ibexa \Contracts \Core \Repository \Values \Content \Query \Criterion ;
1415use Ibexa \Contracts \Core \Repository \Values \Filter \Filter ;
15- use Ibexa \Contracts \Core \Test \Repository \SetupFactory ;
16- use Ibexa \Tests \Core \Repository \Filtering \TestContentProvider ;
17- use Ibexa \Tests \Integration \Core \Repository \BaseTest ;
1816use Ibexa \Tests \Integration \Core \Repository \Filtering \Fixtures \LegacyLocationSortClause ;
17+ use Ibexa \Tests \Integration \Core \RepositoryTestCase ;
1918use function iterator_to_array ;
2019
2120/**
2221 * Integration BC check for legacy location sort clauses wired through the container.
2322 *
2423 * @group repository
2524 */
26- final class LegacyContentFilteringTest extends BaseTest
25+ final class LegacyContentFilteringTest extends RepositoryTestCase
2726{
28- private TestContentProvider $ contentProvider ;
29-
30- protected function setUp (): void
31- {
32- parent ::setUp ();
33- $ this ->contentProvider = new TestContentProvider ($ this ->getRepository (), $ this );
34- }
35-
3627 public function testLegacyLocationSortClause (): void
3728 {
38- $ parentFolder = $ this ->contentProvider ->createSharedContentStructure ();
29+ $ parentFolder = $ this ->createFolderWithRemoteId ('legacy-parent ' , 'Legacy Parent ' );
30+ $ folder1 = $ this ->createFolderWithRemoteId (
31+ 'legacy-folder-1 ' ,
32+ 'Legacy Folder 1 ' ,
33+ (int )$ parentFolder ->getContentInfo ()->getMainLocationId ()
34+ );
35+ $ folder2 = $ this ->createFolderWithRemoteId (
36+ 'legacy-folder-2 ' ,
37+ 'Legacy Folder 2 ' ,
38+ (int )$ parentFolder ->getContentInfo ()->getMainLocationId ()
39+ );
3940
4041 $ filter = (new Filter ())
4142 ->withCriterion (
@@ -46,7 +47,8 @@ public function testLegacyLocationSortClause(): void
4647 )
4748 ->withSortClause (new LegacyLocationSortClause (Query::SORT_ASC ));
4849
49- $ list = $ this ->getRepository ()->getContentService ()->find ($ filter , []);
50+ $ contentService = self ::getContentService ();
51+ $ list = $ contentService ->find ($ filter , []);
5052
5153 self ::assertCount (2 , $ list );
5254 $ remoteIds = array_map (
@@ -55,15 +57,40 @@ public function testLegacyLocationSortClause(): void
5557 );
5658 self ::assertSame (
5759 [
58- TestContentProvider:: CONTENT_REMOTE_IDS [ ' folder1 ' ] ,
59- TestContentProvider:: CONTENT_REMOTE_IDS [ ' folder2 ' ] ,
60+ $ folder1-> getContentInfo ()-> remoteId ,
61+ $ folder2-> getContentInfo ()-> remoteId ,
6062 ],
6163 $ remoteIds
6264 );
6365 }
6466
65- protected function getSetupFactory (): SetupFactory
67+ protected static function getKernelClass (): string
6668 {
67- return new LegacyFilteringSetupFactory ();
69+ return LegacyTestKernel::class;
70+ }
71+
72+ private function createFolderWithRemoteId (
73+ string $ remoteId ,
74+ string $ name ,
75+ int $ parentLocationId = self ::CONTENT_TREE_ROOT_ID
76+ ): Content {
77+ $ contentService = self ::getContentService ();
78+ $ contentTypeService = self ::getContentTypeService ();
79+ $ locationService = self ::getLocationService ();
80+
81+ /** @var \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType $folderType */
82+ $ folderType = $ contentTypeService ->loadContentTypeByIdentifier ('folder ' );
83+ $ createStruct = $ contentService ->newContentCreateStruct ($ folderType , 'eng-GB ' );
84+ $ createStruct ->setField ('name ' , $ name , 'eng-GB ' );
85+ $ createStruct ->remoteId = $ remoteId ;
86+
87+ $ locationCreateStruct = $ locationService ->newLocationCreateStruct ($ parentLocationId );
88+
89+ $ draft = $ contentService ->createContent (
90+ $ createStruct ,
91+ [$ locationCreateStruct ]
92+ );
93+
94+ return $ contentService ->publishVersion ($ draft ->versionInfo );
6895 }
6996}
0 commit comments