LastTradedPriceTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testBuildResponseData() 0 14 1
1
<?php
2
3
namespace Carpenstar\ByBitAPI\Spot\MarketData\LastTradedPrice\Tests;
4
5
use Carpenstar\ByBitAPI\BybitAPI;
6
use Carpenstar\ByBitAPI\Core\Builders\ResponseDtoBuilder;
7
use Carpenstar\ByBitAPI\Core\Builders\ResponseHandlerBuilder;
8
use Carpenstar\ByBitAPI\Core\Builders\RestBuilder;
9
use Carpenstar\ByBitAPI\Core\Enums\EnumOutputMode;
10
use Carpenstar\ByBitAPI\Core\Objects\Collection\EntityCollection;
11
use Carpenstar\ByBitAPI\Core\Response\CurlResponseDto;
0 ignored issues
show
Bug introduced by
The type Carpenstar\ByBitAPI\Core\Response\CurlResponseDto was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Carpenstar\ByBitAPI\Core\Response\CurlResponseHandler;
13
use Carpenstar\ByBitAPI\Spot\MarketData\Kline\Response\KlineResponse;
14
use Carpenstar\ByBitAPI\Spot\MarketData\LastTradedPrice\LastTradedPrice;
15
use Carpenstar\ByBitAPI\Spot\MarketData\LastTradedPrice\Overrides\TestLastTradedPrice;
0 ignored issues
show
Bug introduced by
The type Carpenstar\ByBitAPI\Spot...des\TestLastTradedPrice was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use Carpenstar\ByBitAPI\Spot\MarketData\LastTradedPrice\Request\LastTradedPriceRequest;
17
use Carpenstar\ByBitAPI\Spot\MarketData\LastTradedPrice\Response\LastTradedPriceResponse;
18
use PHPUnit\Framework\TestCase;
19
20
class LastTradedPriceTest extends TestCase
21
{
22
    /**
23
     * Тестирование сборки объекта ответа
24
     *
25
     * @return void
26
     */
27
    public function testBuildResponseData()
28
    {
29
        $json = '{"retCode":0,"retMsg":"OK","result":{"symbol":"BTCUSDT","price":"26386.61"},"retExtInfo":{},"time":1683982585451}';
30
        $data = (new CurlResponseHandler())->build(json_decode($json, true), LastTradedPriceResponse::class);
31
32
        $this->assertEquals(0, $data->getReturnCode());
33
        $this->assertEquals('OK', $data->getReturnMessage());
34
        $this->assertInstanceOf(LastTradedPriceResponse::class, $data->getResult());
35
36
        /** @var LastTradedPriceResponse $klineInfo */
37
        $klineInfo = $data->getResult();
38
39
        $this->assertEquals('BTCUSDT', $klineInfo->getSymbol());
40
        $this->assertEquals(26386.61, $klineInfo->getPrice());
41
    }
42
}
43