fix: upgrade the exists() market data provider method

This commit is contained in:
hackerESQ
2025-01-28 20:32:43 -06:00
parent 0f135f4024
commit 4ece09368e
7 changed files with 49 additions and 42 deletions
+26
View File
@@ -77,4 +77,30 @@ class FallbackInterfaceTest extends TestCase
Log::shouldHaveReceived('warning')->with('Failed calling method quote (yahoo): Yahoo failed');
Log::shouldHaveReceived('warning')->with('Failed calling method quote (alpha): Alpha failed');
}
public function test_exists_method_fails_without_exception()
{
config()->set('investbrain.provider', 'yahoo,alpha');
config()->set('investbrain.interfaces', [
'yahoo' => YahooMarketData::class,
'alphavantage' => AlphaVantageMarketData::class,
]);
$yahooMock = Mockery::mock(YahooMarketData::class);
$yahooMock->shouldReceive('exists')
->andThrow(new \Exception('Yahoo failed'));
$alphaMock = Mockery::mock(AlphaVantageMarketData::class);
$alphaMock->shouldReceive('exists')
->andThrow(new \Exception('Alpha failed'));
$this->app->instance(YahooMarketData::class, $yahooMock);
$this->app->instance(AlphaVantageMarketData::class, $alphaMock);
$fallbackInterface = new FallbackInterface;
$result = $fallbackInterface->exists('ZZZ');
$this->assertFalse($result);
}
}