From f8ca75f87faab720bf68aeb28e0db9d41df4f07c Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Fri, 29 Nov 2024 20:45:29 +0100 Subject: [PATCH] TASK: Improve asset usage test match error --- .../Features/Bootstrap/AssetUsageTrait.php | 35 +++---------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/Neos.Neos/Tests/Behavior/Features/Bootstrap/AssetUsageTrait.php b/Neos.Neos/Tests/Behavior/Features/Bootstrap/AssetUsageTrait.php index 04ebd587f6..d798c5cae9 100644 --- a/Neos.Neos/Tests/Behavior/Features/Bootstrap/AssetUsageTrait.php +++ b/Neos.Neos/Tests/Behavior/Features/Bootstrap/AssetUsageTrait.php @@ -60,37 +60,10 @@ public function iExpectTheAssetUsageServiceToHaveTheFollowingAssetUsages(TableNo } } - // echo json_encode($tableRows, JSON_PRETTY_PRINT); - // echo json_encode($assetUsages, JSON_PRETTY_PRINT); - Assert::assertEmpty($tableRows, "Not all given asset usages where found: " . json_encode($tableRows, JSON_PRETTY_PRINT)); - Assert::assertSame(count($assetUsages), count($table->getHash()), "More asset usages found as given."); - - } - - public function fewfw(TableNode $table) - { - $assetUsageService = $this->getObject(AssetUsageService::class); - $assetUsages = $assetUsageService->findByFilter($this->currentContentRepository->id, AssetUsageFilter::create()); - - $actual = []; - foreach ($assetUsages as $assetUsage) { - $actual[] = [ - 'assetId' => $assetUsage->assetId, - 'propertyName' => $assetUsage->propertyName, - 'workspaceName' => $assetUsage->workspaceName->value, - 'nodeAggregateId' => $assetUsage->nodeAggregateId->value, - 'originDimensionSpacePoint' => str_replace('":"', '": "', $assetUsage->originDimensionSpacePoint->toJson()), - ]; - } - - $expected = $table->getHash(); - - $sorter = fn ($a, $b) => $a <=> $b; - - usort($expected, $sorter); - usort($actual, $sorter); - - Assert::assertSame($expected, $actual, "Not all given asset usages where found."); + Assert::assertTrue( + $tableRows === [] && count($assetUsages) === count($table->getHash()), + sprintf('Mismatch between all actual asset usages %s and leftover asset usages to match %s', json_encode($assetUsages, JSON_PRETTY_PRINT), json_encode($tableRows, JSON_PRETTY_PRINT)) + ); } /**