Fixed phpunit tests

This commit is contained in:
Jan Böhmer 2025-08-31 22:56:10 +02:00
parent 17f123ba8a
commit 0c7aa5e92a

View file

@ -30,6 +30,8 @@ use App\Services\InfoProviderSystem\DTOs\PriceDTO;
use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO;
use App\Services\InfoProviderSystem\Providers\LCSCProvider;
use App\Services\InfoProviderSystem\Providers\ProviderCapabilities;
use App\Settings\InfoProviderSystem\LCSCSettings;
use App\Tests\SettingsTestHelper;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpClient\Response\MockResponse;
@ -37,13 +39,17 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
class LCSCProviderTest extends TestCase
{
private LCSCSettings $settings;
private LCSCProvider $provider;
private MockHttpClient $httpClient;
protected function setUp(): void
{
$this->httpClient = new MockHttpClient();
$this->provider = new LCSCProvider($this->httpClient, 'USD', true);
$this->settings = SettingsTestHelper::createSettingsDummy(LCSCSettings::class);
$this->settings->currency = 'USD';
$this->settings->enabled = true;
$this->provider = new LCSCProvider($this->httpClient, $this->settings);
}
public function testGetProviderInfo(): void
@ -66,14 +72,16 @@ class LCSCProviderTest extends TestCase
public function testIsActiveWhenEnabled(): void
{
$enabledProvider = new LCSCProvider($this->httpClient, 'USD', true);
$this->assertTrue($enabledProvider->isActive());
//Ensure that the settings are enabled
$this->settings->enabled = true;
$this->assertTrue($this->provider->isActive());
}
public function testIsActiveWhenDisabled(): void
{
$disabledProvider = new LCSCProvider($this->httpClient, 'USD', false);
$this->assertFalse($disabledProvider->isActive());
//Ensure that the settings are disabled
$this->settings->enabled = false;
$this->assertFalse($this->provider->isActive());
}
public function testGetCapabilities(): void