3030use App \Services \InfoProviderSystem \DTOs \PurchaseInfoDTO ;
3131use App \Services \InfoProviderSystem \Providers \LCSCProvider ;
3232use App \Services \InfoProviderSystem \Providers \ProviderCapabilities ;
33+ use App \Settings \InfoProviderSystem \LCSCSettings ;
34+ use App \Tests \SettingsTestHelper ;
3335use PHPUnit \Framework \TestCase ;
3436use Symfony \Component \HttpClient \MockHttpClient ;
3537use Symfony \Component \HttpClient \Response \MockResponse ;
3638use Symfony \Contracts \HttpClient \HttpClientInterface ;
3739
3840class LCSCProviderTest extends TestCase
3941{
42+ private LCSCSettings $ settings ;
4043 private LCSCProvider $ provider ;
4144 private MockHttpClient $ httpClient ;
4245
4346 protected function setUp (): void
4447 {
4548 $ this ->httpClient = new MockHttpClient ();
46- $ this ->provider = new LCSCProvider ($ this ->httpClient , 'USD ' , true );
49+ $ this ->settings = SettingsTestHelper::createSettingsDummy (LCSCSettings::class);
50+ $ this ->settings ->currency = 'USD ' ;
51+ $ this ->settings ->enabled = true ;
52+ $ this ->provider = new LCSCProvider ($ this ->httpClient , $ this ->settings );
4753 }
4854
4955 public function testGetProviderInfo (): void
5056 {
5157 $ info = $ this ->provider ->getProviderInfo ();
52-
58+
5359 $ this ->assertIsArray ($ info );
5460 $ this ->assertArrayHasKey ('name ' , $ info );
5561 $ this ->assertArrayHasKey ('description ' , $ info );
@@ -66,20 +72,22 @@ public function testGetProviderKey(): void
6672
6773 public function testIsActiveWhenEnabled (): void
6874 {
69- $ enabledProvider = new LCSCProvider ($ this ->httpClient , 'USD ' , true );
70- $ this ->assertTrue ($ enabledProvider ->isActive ());
75+ //Ensure that the settings are enabled
76+ $ this ->settings ->enabled = true ;
77+ $ this ->assertTrue ($ this ->provider ->isActive ());
7178 }
7279
7380 public function testIsActiveWhenDisabled (): void
7481 {
75- $ disabledProvider = new LCSCProvider ($ this ->httpClient , 'USD ' , false );
76- $ this ->assertFalse ($ disabledProvider ->isActive ());
82+ //Ensure that the settings are disabled
83+ $ this ->settings ->enabled = false ;
84+ $ this ->assertFalse ($ this ->provider ->isActive ());
7785 }
7886
7987 public function testGetCapabilities (): void
8088 {
8189 $ capabilities = $ this ->provider ->getCapabilities ();
82-
90+
8391 $ this ->assertIsArray ($ capabilities );
8492 $ this ->assertContains (ProviderCapabilities::BASIC , $ capabilities );
8593 $ this ->assertContains (ProviderCapabilities::PICTURE , $ capabilities );
@@ -495,7 +503,7 @@ public function testEmptyFootprintHandling(): void
495503 'productCode ' => 'C123456 ' ,
496504 'productModel ' => 'Test Component ' ,
497505 'productIntroEn ' => 'Test description ' ,
498- 'brandNameEn ' => 'Test Manufacturer ' ,
506+ 'brandNameEn ' => 'Test Manufacturer ' ,
499507 'encapStandard ' => '- ' ,
500508 'productImageUrl ' => null ,
501509 'productImages ' => [],
@@ -529,4 +537,4 @@ public function testSearchByKeywordsBatchWithException(): void
529537 $ this ->assertArrayHasKey ('error ' , $ results );
530538 $ this ->assertEmpty ($ results ['error ' ]);
531539 }
532- }
540+ }
0 commit comments