Test Failed
Pull Request — master (#13)
by Vladislav
09:26 queued 01:13
created

InstrumentInfoTest::testInstrumentInfoEndpoint()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 27
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 23
c 2
b 0
f 0
nc 2
nop 0
dl 0
loc 27
rs 9.552
1
<?php
2
namespace Carpenstar\ByBitAPI\Spot\MarketData\InstrumentInfo\Tests;
3
4
use Carpenstar\ByBitAPI\Core\Response\CurlResponseHandler;
5
use Carpenstar\ByBitAPI\Spot\MarketData\InstrumentInfo\Response\InstrumentInfoResponse;
6
use Carpenstar\ByBitAPI\Spot\MarketData\InstrumentInfo\Response\InstrumentInfoResponseItem;
7
use PHPUnit\Framework\TestCase;
8
9
class InstrumentInfoTest extends TestCase
10
{
11
    /**
12
     * Тестирование сборки объекта ответа
13
     *
14
     * @return void
15
     */
16
    public function testBuildResponseData()
17
    {
18
        $json = '{"retCode":0,"retMsg":"OK","result":{"list":[{"name":"BTCUSDT","alias":"BTCUSDT","baseCoin":"BTC","quoteCoin":"USDT","basePrecision":"0.000001","quotePrecision":"0.00000001","minTradeQty":"0.00004","minTradeAmt":"1","maxTradeQty":"500","maxTradeAmt":"1200000","minPricePrecision":"0.01","category":"1","showStatus":"1","innovation":"0"},{"name":"ETHUSDT","alias":"ETHUSDT","baseCoin":"ETH","quoteCoin":"USDT","basePrecision":"0.00001","quotePrecision":"0.0000001","minTradeQty":"0.0005","minTradeAmt":"1","maxTradeQty":"100000000","maxTradeAmt":"1200000","minPricePrecision":"0.01","category":"1","showStatus":"1","innovation":"0"},{"name":"EOSUSDT","alias":"EOSUSDT","baseCoin":"EOS","quoteCoin":"USDT","basePrecision":"0.01","quotePrecision":"0.000001","minTradeQty":"0.01","minTradeAmt":"0.01","maxTradeQty":"90909.090909","maxTradeAmt":"10000","minPricePrecision":"0.0001","category":"1","showStatus":"1","innovation":"0"}]},"retExtInfo":{},"time":1683980087416}';;
19
        $data = (new CurlResponseHandler())->build(json_decode($json, true), InstrumentInfoResponse::class);
20
21
        $this->assertEquals(0, $data->getReturnCode());
22
        $this->assertEquals('OK', $data->getReturnMessage());
23
        $this->assertInstanceOf(InstrumentInfoResponse::class, $data->getResult());
24
25
        /** @var InstrumentInfoResponseItem $instrumentInfo */
26
        $instrumentInfo = current($data->getResult()->getInstrumentInfoList());
0 ignored issues
show
Bug introduced by
The method getInstrumentInfoList() does not exist on Carpenstar\ByBitAPI\Core\Objects\AbstractResponse. It seems like you code against a sub-type of Carpenstar\ByBitAPI\Core\Objects\AbstractResponse such as Carpenstar\ByBitAPI\Spot...\InstrumentInfoResponse. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        $instrumentInfo = current($data->getResult()->/** @scrutinizer ignore-call */ getInstrumentInfoList());
Loading history...
27
28
        $this->assertEquals('BTCUSDT', $instrumentInfo->getName());
29
        $this->assertEquals('BTCUSDT', $instrumentInfo->getAlias());
30
        $this->assertEquals('BTC', $instrumentInfo->getBaseCoin());
31
        $this->assertEquals('USDT', $instrumentInfo->getQuoteCoin());
32
        $this->assertEquals(0.000001, $instrumentInfo->getBasePrecision());
33
        $this->assertEquals(0.00000001, $instrumentInfo->getQuotePrecision());
34
        $this->assertEquals(0.00004, $instrumentInfo->getMinTradeQty());
35
        $this->assertEquals(1, $instrumentInfo->getMinTradeAmt());
36
        $this->assertEquals(500, $instrumentInfo->getMaxTradeQty());
37
        $this->assertEquals(1200000, $instrumentInfo->getMaxTradeAmt());
38
        $this->assertEquals(0.01, $instrumentInfo->getMinPricePrecision());
39
        $this->assertEquals(1, $instrumentInfo->getCategory());
40
        $this->assertEquals(1, $instrumentInfo->getShowStatus());
41
        $this->assertEquals(0, $instrumentInfo->getInnovation());
42
    }
43
}