Skip to content

Commit 34d284b

Browse files
committed
Do not test against real LCSC provider...
1 parent 6b1e7b3 commit 34d284b

File tree

2 files changed

+78
-2
lines changed

2 files changed

+78
-2
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
/*
3+
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
4+
*
5+
* Copyright (C) 2019 - 2025 Jan Böhmer (https://github.com/jbtronics)
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU Affero General Public License as published
9+
* by the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU Affero General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Affero General Public License
18+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
declare(strict_types=1);
22+
23+
24+
namespace App\Services\InfoProviderSystem\Providers;
25+
26+
use App\Services\InfoProviderSystem\DTOs\FileDTO;
27+
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
28+
use App\Services\InfoProviderSystem\DTOs\SearchResultDTO;
29+
use Symfony\Component\DependencyInjection\Attribute\When;
30+
31+
/**
32+
* This is a provider, which is used during tests. It always returns no results.
33+
*/
34+
#[When(env: 'test')]
35+
class EmptyProvider implements InfoProviderInterface
36+
{
37+
public function getProviderInfo(): array
38+
{
39+
return [
40+
'name' => 'Empty Provider',
41+
'description' => 'This is a test provider',
42+
//'url' => 'https://example.com',
43+
'disabled_help' => 'This provider is disabled for testing purposes'
44+
];
45+
}
46+
47+
public function getProviderKey(): string
48+
{
49+
return 'empty';
50+
}
51+
52+
public function isActive(): bool
53+
{
54+
return true;
55+
}
56+
57+
public function searchByKeyword(string $keyword): array
58+
{
59+
return [
60+
61+
];
62+
}
63+
64+
public function getCapabilities(): array
65+
{
66+
return [
67+
ProviderCapabilities::BASIC,
68+
ProviderCapabilities::FOOTPRINT,
69+
];
70+
}
71+
72+
public function getDetails(string $id): PartDetailDTO
73+
{
74+
throw new \RuntimeException('No part details available');
75+
}
76+
}

tests/Controller/BulkInfoProviderImportControllerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,12 +761,12 @@ public function testBulkInfoProviderServiceBatchProcessing(): void
761761

762762
// Create field mappings with multiple keywords
763763
$fieldMappings = [
764-
new \App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO('name', ['lcsc'], 1)
764+
new \App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO('empty', ['test'], 1)
765765
];
766766

767767
// The service should be able to process the request and throw an exception when no results are found
768768
try {
769-
$bulkService->performBulkSearch([$part], $fieldMappings, false);
769+
$response = $bulkService->performBulkSearch([$part], $fieldMappings, false);
770770
$this->fail('Expected RuntimeException to be thrown when no search results are found');
771771
} catch (\RuntimeException $e) {
772772
$this->assertStringContainsString('No search results found', $e->getMessage());

0 commit comments

Comments
 (0)