1111use MarketDataApp \Endpoints \Responses \Indices \Candle ;
1212use MarketDataApp \Endpoints \Responses \Indices \Candles ;
1313use MarketDataApp \Endpoints \Responses \Indices \Quote ;
14+ use MarketDataApp \Endpoints \Responses \Indices \Quotes ;
1415use MarketDataApp \Exceptions \ApiException ;
1516use MarketDataApp \Tests \Traits \MockResponses ;
1617use PHPUnit \Framework \TestCase ;
@@ -22,6 +23,17 @@ class IndicesTest extends TestCase
2223
2324 private Client $ client ;
2425
26+ private array $ aapl_mocked_response = [
27+ 's ' => 'ok ' ,
28+ 'symbol ' => ['AAPL ' ],
29+ 'last ' => [50.5 ],
30+ 'change ' => [30.2 ],
31+ 'changepct ' => [2.4 ],
32+ '52weekHigh ' => [4023.5 ],
33+ '52weekLow ' => [2035.0 ],
34+ 'updated ' => ['2020-01-01T00:00:00.000000Z ' ],
35+ ];
36+
2537 protected function setUp (): void
2638 {
2739 $ token = "your_api_token " ;
@@ -55,6 +67,46 @@ public function testQuote_success()
5567 $ this ->assertEquals (Carbon::parse ($ mocked_response ['updated ' ][0 ]), $ response ->updated );
5668 }
5769
70+
71+
72+ /**
73+ * @throws GuzzleException
74+ * @throws \Throwable
75+ */
76+ public function testQuotes_success ()
77+ {
78+ $ msft_mocked_response = [
79+ 's ' => 'ok ' ,
80+ 'symbol ' => ['MSFT ' ],
81+ 'last ' => [300.67 ],
82+ 'change ' => [5.2 ],
83+ 'changepct ' => [2.2 ],
84+ '52weekHigh ' => [320.5 ],
85+ '52weekLow ' => [200.0 ],
86+ 'updated ' => ['2020-01-01T00:00:00.000000Z ' ],
87+ ];
88+ $ this ->setMockResponses ([
89+ new Response (200 , [], json_encode ($ this ->aapl_mocked_response )),
90+ new Response (200 , [], json_encode ($ msft_mocked_response )),
91+ ]);
92+
93+ $ quotes = $ this ->client ->indices ->quotes (['AAPL ' , 'MSFT ' ]);
94+ $ this ->assertInstanceOf (Quotes::class, $ quotes );
95+ foreach ($ quotes ->quotes as $ quote ) {
96+ $ this ->assertInstanceOf (Quote::class, $ quote );
97+ $ mocked_response = $ quote ->symbol === "AAPL " ? $ this ->aapl_mocked_response : $ msft_mocked_response ;
98+
99+ $ this ->assertEquals ($ mocked_response ['s ' ], $ quote ->status );
100+ $ this ->assertEquals ($ mocked_response ['symbol ' ][0 ], $ quote ->symbol );
101+ $ this ->assertEquals ($ mocked_response ['last ' ][0 ], $ quote ->last );
102+ $ this ->assertEquals ($ mocked_response ['change ' ][0 ], $ quote ->change );
103+ $ this ->assertEquals ($ mocked_response ['changepct ' ][0 ], $ quote ->change_percent );
104+ $ this ->assertEquals ($ mocked_response ['52weekHigh ' ][0 ], $ quote ->fifty_two_week_high );
105+ $ this ->assertEquals ($ mocked_response ['52weekLow ' ][0 ], $ quote ->fifty_two_week_low );
106+ $ this ->assertEquals (Carbon::parse ($ mocked_response ['updated ' ][0 ]), $ quote ->updated );
107+ }
108+ }
109+
58110 public function testQuote_noData_success ()
59111 {
60112 $ mocked_response = [
0 commit comments