Add TestCase for EuropeanCentralBankExchange

This commit is contained in:
2024-05-23 13:27:26 +02:00
parent 17074ae56e
commit 0004f0e89d
@@ -0,0 +1,35 @@
<?php
namespace App\Tests\Library\Economy\Currency;
use App\Library\Economy\Currency\EuropeanCentralBankExchange;
use PHPUnit\Framework\TestCase;
class EuropeanCentralBankExchangeTest extends TestCase
{
public function testGetsData()
{
$exchange = new EuropeanCentralBankExchange;
$exchangeData = $exchange->getData();
$this->assertIsArray($exchangeData);
$this->assertArrayHasKey('Cube', $exchangeData);
$this->assertArrayHasKey('@attributes', $exchangeData);
}
public function testStoresDataInApcuCache()
{
$exchange = new EuropeanCentralBankExchange;
// Data should be available on instantiation
$data = \apcu_fetch($exchange::ECB_DATA);
$this->assertNotFalse($data);
$exchangeData = \json_decode($data, true);
$this->assertIsArray($exchangeData);
$this->assertArrayHasKey('Cube', $exchangeData);
$this->assertArrayHasKey('@attributes', $exchangeData);
}
}