Feat: Adds multi currency support (#88)

This commit is contained in:
hackerESQ
2025-04-09 19:25:15 -05:00
committed by GitHub
parent 6d6f968f42
commit eae345f243
100 changed files with 17735 additions and 35761 deletions
+19 -6
View File
@@ -8,11 +8,14 @@ use App\Interfaces\MarketData\AlphaVantageMarketData;
use App\Interfaces\MarketData\FallbackInterface;
use App\Interfaces\MarketData\Types\Quote;
use App\Interfaces\MarketData\YahooMarketData;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Log;
use Mockery;
class FallbackInterfaceTest extends TestCase
{
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
@@ -34,7 +37,12 @@ class FallbackInterfaceTest extends TestCase
$alphaMock = Mockery::mock(AlphaVantageMarketData::class);
$alphaMock->shouldReceive('quote')
->andReturn(new Quote(['market_value' => 10]));
->andReturn(new Quote([
'name' => 'Test Quote',
'symbol' => 'ACME',
'currency' => 'USD',
'market_value' => 10,
]));
$this->app->instance(YahooMarketData::class, $yahooMock);
$this->app->instance(AlphaVantageMarketData::class, $alphaMock);
@@ -43,9 +51,14 @@ class FallbackInterfaceTest extends TestCase
$result = $fallbackInterface->quote('ACME');
$this->assertEquals(new Quote(['market_value' => 10]), $result);
$this->assertEquals(new Quote([
'name' => 'Test Quote',
'symbol' => 'ACME',
'currency' => 'USD',
'market_value' => 10,
]), $result);
Log::shouldHaveReceived('warning')->with('Failed calling method quote (yahoo): Yahoo failed');
Log::shouldHaveReceived('error')->with('Failed calling method quote for ACME (yahoo): Yahoo failed');
}
public function test_all_providers_fail()
@@ -70,12 +83,12 @@ class FallbackInterfaceTest extends TestCase
$fallbackInterface = new FallbackInterface;
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Could not get market data: Provider [alpha] is not a valid market data interface.');
$this->expectExceptionMessage('Could not get market data calling method quote: Provider [alpha] is not a valid market data interface.');
$fallbackInterface->quote('AAPL');
Log::shouldHaveReceived('warning')->with('Failed calling method quote (yahoo): Yahoo failed');
Log::shouldHaveReceived('warning')->with('Failed calling method quote (alpha): Alpha failed');
Log::shouldHaveReceived('error')->with('Failed calling method quote for AAPL (yahoo): Yahoo failed');
Log::shouldHaveReceived('error')->with('Failed calling method quote for AAPL (alpha): Alpha failed');
}
public function test_exists_method_fails_without_exception()