mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-06 11:09:29 +00:00
Fixed phpunit tests
This commit is contained in:
parent
17f123ba8a
commit
0c7aa5e92a
1 changed files with 17 additions and 9 deletions
|
|
@ -30,6 +30,8 @@ use App\Services\InfoProviderSystem\DTOs\PriceDTO;
|
||||||
use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO;
|
use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO;
|
||||||
use App\Services\InfoProviderSystem\Providers\LCSCProvider;
|
use App\Services\InfoProviderSystem\Providers\LCSCProvider;
|
||||||
use App\Services\InfoProviderSystem\Providers\ProviderCapabilities;
|
use App\Services\InfoProviderSystem\Providers\ProviderCapabilities;
|
||||||
|
use App\Settings\InfoProviderSystem\LCSCSettings;
|
||||||
|
use App\Tests\SettingsTestHelper;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\HttpClient\MockHttpClient;
|
use Symfony\Component\HttpClient\MockHttpClient;
|
||||||
use Symfony\Component\HttpClient\Response\MockResponse;
|
use Symfony\Component\HttpClient\Response\MockResponse;
|
||||||
|
|
@ -37,13 +39,17 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||||
|
|
||||||
class LCSCProviderTest extends TestCase
|
class LCSCProviderTest extends TestCase
|
||||||
{
|
{
|
||||||
|
private LCSCSettings $settings;
|
||||||
private LCSCProvider $provider;
|
private LCSCProvider $provider;
|
||||||
private MockHttpClient $httpClient;
|
private MockHttpClient $httpClient;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->httpClient = new MockHttpClient();
|
$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
|
public function testGetProviderInfo(): void
|
||||||
|
|
@ -66,14 +72,16 @@ class LCSCProviderTest extends TestCase
|
||||||
|
|
||||||
public function testIsActiveWhenEnabled(): void
|
public function testIsActiveWhenEnabled(): void
|
||||||
{
|
{
|
||||||
$enabledProvider = new LCSCProvider($this->httpClient, 'USD', true);
|
//Ensure that the settings are enabled
|
||||||
$this->assertTrue($enabledProvider->isActive());
|
$this->settings->enabled = true;
|
||||||
|
$this->assertTrue($this->provider->isActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsActiveWhenDisabled(): void
|
public function testIsActiveWhenDisabled(): void
|
||||||
{
|
{
|
||||||
$disabledProvider = new LCSCProvider($this->httpClient, 'USD', false);
|
//Ensure that the settings are disabled
|
||||||
$this->assertFalse($disabledProvider->isActive());
|
$this->settings->enabled = false;
|
||||||
|
$this->assertFalse($this->provider->isActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetCapabilities(): void
|
public function testGetCapabilities(): void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue