From b920e61ac52da4c2e80f0005e49ca2653a1b6a44 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 9 May 2024 10:13:48 +0200 Subject: [PATCH] TASK: Remove flow query sort operation test it will be fully migrated via https://github.com/neos/neos-development-collection/pull/5015#issuecomment-2102168505 --- .../Fixtures/SortableNodes.xml | 86 ------ .../FlowQueryOperations/SortOperationTest.php | 244 ------------------ 2 files changed, 330 deletions(-) delete mode 100644 Neos.Neos/Tests/Functional/FlowQueryOperations/Fixtures/SortableNodes.xml delete mode 100755 Neos.Neos/Tests/Functional/FlowQueryOperations/SortOperationTest.php diff --git a/Neos.Neos/Tests/Functional/FlowQueryOperations/Fixtures/SortableNodes.xml b/Neos.Neos/Tests/Functional/FlowQueryOperations/Fixtures/SortableNodes.xml deleted file mode 100644 index 125b5045ecb..00000000000 --- a/Neos.Neos/Tests/Functional/FlowQueryOperations/Fixtures/SortableNodes.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Neos.Neos/Tests/Functional/FlowQueryOperations/SortOperationTest.php b/Neos.Neos/Tests/Functional/FlowQueryOperations/SortOperationTest.php deleted file mode 100755 index 99fea63ef1a..00000000000 --- a/Neos.Neos/Tests/Functional/FlowQueryOperations/SortOperationTest.php +++ /dev/null @@ -1,244 +0,0 @@ -markTestSkipped('Needs to be rewritten with ES CR'); - parent::setUp(); - $workspaceRepository = $this->objectManager->get(\Neos\ContentRepository\Domain\Repository\WorkspaceRepository::class); - $workspaceRepository->add(new Workspace('live')); - $this->persistenceManager->persistAll(); - $this->contextFactory = $this->objectManager->get(\Neos\ContentRepository\Domain\Service\ContextFactoryInterface::class); - $this->context = $this->contextFactory->create(['workspaceName' => 'live']); - - - $siteImportService = $this->objectManager->get(\Neos\Neos\Domain\Service\SiteImportService::class); - $siteImportService->importFromFile(__DIR__ . '/Fixtures/SortableNodes.xml', $this->context); - $this->persistenceManager->persistAll(); - $this->persistenceManager->clearState(); - $this->inject($this->contextFactory, 'contextInstances', []); - - // The context is not important here, just a quick way to get a (live) workspace - // $context = $this->contextFactory->create(); - $this->nodeDataRepository = $this->objectManager->get(\Neos\ContentRepository\Domain\Repository\NodeDataRepository::class); - } - - /** - * @return void - */ - public function tearDown(): void - { - parent::tearDown(); - $this->inject($this->contextFactory, 'contextInstances', []); - } - - /** - * @test+ - */ - public function callWithoutArgumentsCausesException() - { - $this->expectException(FlowQueryException::class); - $flowQuery = new \Neos\Eel\FlowQuery\FlowQuery([]); - $operation = new SortOperation(); - $operation->evaluate($flowQuery, []); - } - - /** - * @test - */ - public function invalidSortDirectionCausesException() - { - $this->expectException(FlowQueryException::class); - $flowQuery = new \Neos\Eel\FlowQuery\FlowQuery([]); - $operation = new SortOperation(); - $operation->evaluate($flowQuery, ['title', 'FOO']); - } - - /** - * @test - */ - public function sortByStringAscending() - { - $nodesToSort = [ - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addd', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115adde', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addf', $this->context->getWorkspace(true), []) - ]; - $correctOrder = [ - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addf', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addd', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115adde', $this->context->getWorkspace(true), []) - ]; - $flowQuery = new \Neos\Eel\FlowQuery\FlowQuery($nodesToSort); - $operation = new SortOperation(); - $operation->evaluate($flowQuery, ['title', 'ASC']); - - self::assertEquals($correctOrder, $flowQuery->getContext()); - } - - /** - * @test - */ - public function sortByStringDescending() - { - $nodesToSort = [ - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addd', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115adde', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addf', $this->context->getWorkspace(true), []) - ]; - $correctOrder = [ - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115adde', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addd', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addf', $this->context->getWorkspace(true), []) - ]; - $flowQuery = new \Neos\Eel\FlowQuery\FlowQuery($nodesToSort); - $operation = new SortOperation(); - $operation->evaluate($flowQuery, ['title', 'DESC']); - - self::assertEquals($correctOrder, $flowQuery->getContext()); - } - - /** - * @test - */ - public function sortByDateTimeAscending() - { - $nodesToSort = [ - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addd', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115adde', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addf', $this->context->getWorkspace(true), []) - ]; - $correctOrder = [ - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115adde', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addf', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addd', $this->context->getWorkspace(true), []) - ]; - $flowQuery = new \Neos\Eel\FlowQuery\FlowQuery($nodesToSort); - $operation = new SortOperation(); - $operation->evaluate($flowQuery, ['_lastPublicationDateTime', 'ASC']); - - self::assertEquals($correctOrder, $flowQuery->getContext()); - } - - /** - * @test - */ - public function sortByDateTimeDescending() - { - $nodesToSort = [ - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addd', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115adde', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addf', $this->context->getWorkspace(true), []) - ]; - $correctOrder = [ - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addd', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addf', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115adde', $this->context->getWorkspace(true), []) - ]; - $flowQuery = new \Neos\Eel\FlowQuery\FlowQuery($nodesToSort); - $operation = new SortOperation(); - $operation->evaluate($flowQuery, ['_lastPublicationDateTime', 'DESC']); - - self::assertEquals($correctOrder, $flowQuery->getContext()); - } - - /** - * @test - */ - public function invalidSortOptionCausesException() - { - $this->expectException(FlowQueryException::class); - $flowQuery = new \Neos\Eel\FlowQuery\FlowQuery([]); - $operation = new SortOperation(); - $operation->evaluate($flowQuery, ['title', 'ASC', 'SORT_BAR']); - } - - /** - * @test - */ - public function sortByStringNaturalCaseAscending() - { - $nodesToSort = [ - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addb', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addc', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addd', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115adde', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addf', $this->context->getWorkspace(true), []) - ]; - $correctOrder = [ - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addc', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addf', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addb', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addd', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115adde', $this->context->getWorkspace(true), []) - ]; - $flowQuery = new \Neos\Eel\FlowQuery\FlowQuery($nodesToSort); - $operation = new SortOperation(); - $operation->evaluate($flowQuery, ['title', 'ASC', ['SORT_NATURAL', 'SORT_FLAG_CASE']]); - - self::assertEquals($correctOrder, $flowQuery->getContext()); - } - - /** - * @test - */ - public function sortByNumericDescending() - { - $nodesToSort = [ - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addc', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addb', $this->context->getWorkspace(true), []), - ]; - $correctOrder = [ - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addb', $this->context->getWorkspace(true), []), - $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addc', $this->context->getWorkspace(true), []), - ]; - $flowQuery = new \Neos\Eel\FlowQuery\FlowQuery($nodesToSort); - $operation = new SortOperation(); - $operation->evaluate($flowQuery, ['text', 'DESC', 'SORT_NUMERIC']); - - self::assertEquals($correctOrder, $flowQuery->getContext()); - } -}