From fe7c94bd72fda2cb365cedbb6f94c5c447260074 Mon Sep 17 00:00:00 2001 From: Sebastian Almberg <83243306+Sebbeben@users.noreply.github.com> Date: Thu, 12 Mar 2026 12:12:14 +0100 Subject: [PATCH] Fix tests to match updated bulk search behavior (no more RuntimeException) The bulk search service now returns empty response DTOs instead of throwing RuntimeException when no results are found. Updated tests to use assertFalse(hasAnyResults()) instead of catching exceptions. --- .../BulkInfoProviderImportControllerTest.php | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/tests/Controller/BulkInfoProviderImportControllerTest.php b/tests/Controller/BulkInfoProviderImportControllerTest.php index f35c5f92..4f49d89a 100644 --- a/tests/Controller/BulkInfoProviderImportControllerTest.php +++ b/tests/Controller/BulkInfoProviderImportControllerTest.php @@ -1025,13 +1025,9 @@ final class BulkInfoProviderImportControllerTest extends WebTestCase new BulkSearchFieldMappingDTO('test_supplier_spn', ['test'], 2) ]; - // The service should be able to process the request and throw an exception when no results are found - try { - $bulkService->performBulkSearch([$part], $fieldMappings, false); - $this->fail('Expected RuntimeException to be thrown when no search results are found'); - } catch (\RuntimeException $e) { - $this->assertStringContainsString('No search results found', $e->getMessage()); - } + // The service should return an empty response DTO when no results are found + $response = $bulkService->performBulkSearch([$part], $fieldMappings, false); + $this->assertFalse($response->hasAnyResults()); } public function testBulkInfoProviderServiceBatchProcessing(): void @@ -1055,13 +1051,9 @@ final class BulkInfoProviderImportControllerTest extends WebTestCase new BulkSearchFieldMappingDTO('empty', ['test'], 1) ]; - // The service should be able to process the request and throw an exception when no results are found - try { - $response = $bulkService->performBulkSearch([$part], $fieldMappings, false); - $this->fail('Expected RuntimeException to be thrown when no search results are found'); - } catch (\RuntimeException $e) { - $this->assertStringContainsString('No search results found', $e->getMessage()); - } + // The service should return an empty response DTO when no results are found + $response = $bulkService->performBulkSearch([$part], $fieldMappings, false); + $this->assertFalse($response->hasAnyResults()); } public function testBulkInfoProviderServicePrefetchDetails(): void