Passed
Push — master ( f32712...07732c )
by Vladislav
04:33 queued 01:39
created

FundingRateHistoryTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
c 0
b 0
f 0
dl 0
loc 19
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A testFundingRateHistoryResponse() 0 15 2
1
<?php
2
namespace Carpenstar\ByBitAPI\Derivatives\MarketData\FundingRateHistory\Tests;
3
4
use Carpenstar\ByBitAPI\Core\Builders\ResponseHandlerBuilder;
5
use Carpenstar\ByBitAPI\Core\Enums\EnumOutputMode;
6
use Carpenstar\ByBitAPI\Core\Objects\Collection\EntityCollection;
7
use Carpenstar\ByBitAPI\Core\Response\CurlResponseHandler;
8
use Carpenstar\ByBitAPI\Derivatives\MarketData\FundingRateHistory\Response\FundingRateHistoryResponse;
9
use PHPUnit\Framework\TestCase;
10
11
class FundingRateHistoryTest extends TestCase
12
{
13
    private static string $fundingRateHistory = '{"retCode":0,"retMsg":"OK","result":{"category":"linear","list":[{"symbol":"BTCUSDT","fundingRate":"0.0001","fundingRateTimestamp":"1683993600000"},{"symbol":"BTCUSDT","fundingRate":"0.00009144","fundingRateTimestamp":"1683964800000"},{"symbol":"BTCUSDT","fundingRate":"0.0008453","fundingRateTimestamp":"1683936000000"}]},"retExtInfo":{},"time":1684004110974}';
14
15
    public function testFundingRateHistoryResponse()
16
    {
17
        $fundingRateHistoryData = ResponseHandlerBuilder::make(self::$fundingRateHistory,
18
            CurlResponseHandler::class, FundingRateHistoryResponse::class, EnumOutputMode::MODE_ENTITY);
19
20
        $this->assertInstanceOf(EntityCollection::class, $fundingRateHistoryData->getBody());
21
22
        $this->assertNotEmpty($fundingRateHistoryData->getBody()->count());
23
24
        /** @var FundingRateHistoryResponse $historyItem */
25
        while(!empty($historyItem = $fundingRateHistoryData->getBody()->fetch())) {
26
            $this->assertInstanceOf(FundingRateHistoryResponse::class, $historyItem);
27
            $this->assertIsString($historyItem->getSymbol());
28
            $this->assertIsFloat($historyItem->getFundingRate());
29
            $this->assertInstanceOf(\DateTime::class, $historyItem->getFundingRateTimestamp());
30
        }
31
    }
32
33
}