PurchaseRedeemHistoryTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 18
dl 0
loc 30
rs 10
c 2
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testBuildResponseData() 0 23 1
1
<?php
2
3
namespace Carpenstar\ByBitAPI\Spot\LeverageToken\PurchaseRedeemHistory\Tests;
4
5
use Carpenstar\ByBitAPI\Core\Response\CurlResponseHandler;
6
use Carpenstar\ByBitAPI\Spot\LeverageToken\PurchaseRedeemHistory\Response\PurchaseRedeemHistoryResponse;
7
use Carpenstar\ByBitAPI\Spot\LeverageToken\PurchaseRedeemHistory\Response\PurchaseRedeemHistoryResponseItem;
8
use PHPUnit\Framework\TestCase;
9
10
class PurchaseRedeemHistoryTest extends TestCase
11
{
12
    /**
13
     * Тестирование сборки объекта ответа
14
     *
15
     * @return void
16
     */
17
    public function testBuildResponseData()
18
    {
19
        $json = '{"retCode":0,"retMsg":"OK","result":{"list":[{"amount":"","excTime":1662549752000,"fee":"","ltCode":"DOT3L","orderId":"2083","orderStatus":"3","orderTime":1662549752000,"orderType":1,"serialNo":"x003","value":"","valueCoin":"USDT"},{"amount":"","excTime":1662549702000,"fee":"","ltCode":"DOT3L","orderId":"2082","orderStatus":"3","orderTime":1662549702000,"orderType":1,"serialNo":"x002","value":"","valueCoin":"USDT"}]},"retExtInfo":{},"time":1662608374640}';
20
        $data = (new CurlResponseHandler())->build(json_decode($json, true), PurchaseRedeemHistoryResponse::class);
21
22
        $this->assertEquals(0, $data->getReturnCode());
23
        $this->assertEquals('OK', $data->getReturnMessage());
24
        $this->assertInstanceOf(PurchaseRedeemHistoryResponse::class, $data->getResult());
25
26
        /** @var PurchaseRedeemHistoryResponseItem $purchaseHistoryInfo */
27
        $purchaseHistoryInfo = current($data->getResult()->getPurchaseHistory());
0 ignored issues
show
Bug introduced by
The method getPurchaseHistory() 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...seRedeemHistoryResponse. ( Ignorable by Annotation )

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

27
        $purchaseHistoryInfo = current($data->getResult()->/** @scrutinizer ignore-call */ getPurchaseHistory());
Loading history...
28
29
        $this->assertInstanceOf(\DateTime::class, $purchaseHistoryInfo->getExecTime());
30
        $this->assertInstanceOf(\DateTime::class, $purchaseHistoryInfo->getOrderTime());
31
        $this->assertEquals(0.0, $purchaseHistoryInfo->getAmount());
32
        $this->assertEquals(0.0, $purchaseHistoryInfo->getFee());
33
        $this->assertEquals('DOT3L', $purchaseHistoryInfo->getLtCode());
34
        $this->assertEquals(2083, $purchaseHistoryInfo->getOrderId());
35
        $this->assertEquals(3, $purchaseHistoryInfo->getOrderStatus());
36
        $this->assertEquals(1, $purchaseHistoryInfo->getOrderType());
37
        $this->assertEquals('x003', $purchaseHistoryInfo->getSerialNo());
38
        $this->assertEquals(0.0, $purchaseHistoryInfo->getValue());
39
        $this->assertEquals('USDT', $purchaseHistoryInfo->getValueCoin());
40
    }
41
}
42