TickersTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testBuildResponseData() 0 22 1
1
<?php
2
3
namespace Carpenstar\ByBitAPI\Spot\MarketData\Tickers\Tests;
4
5
use Carpenstar\ByBitAPI\Core\Builders\ResponseDtoBuilder;
6
use Carpenstar\ByBitAPI\Core\Builders\ResponseHandlerBuilder;
7
use Carpenstar\ByBitAPI\Core\Builders\RestBuilder;
8
use Carpenstar\ByBitAPI\Core\Enums\EnumOutputMode;
9
use Carpenstar\ByBitAPI\Core\Objects\Collection\EntityCollection;
10
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...
11
use Carpenstar\ByBitAPI\Core\Response\CurlResponseHandler;
12
use Carpenstar\ByBitAPI\Spot\MarketData\Tickers\Overrides\TestTickers;
0 ignored issues
show
Bug introduced by
The type Carpenstar\ByBitAPI\Spot...s\Overrides\TestTickers 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...
13
use Carpenstar\ByBitAPI\Spot\MarketData\Tickers\Request\TickersRequest;
14
use Carpenstar\ByBitAPI\Spot\MarketData\Tickers\Response\TickersResponse;
15
use PHPUnit\Framework\TestCase;
16
17
class TickersTest extends TestCase
18
{
19
    /**
20
     * Тестирование сборки объекта ответа
21
     *
22
     * @return void
23
     */
24
    public function testBuildResponseData()
25
    {
26
        $json = '{"retCode":0,"retMsg":"OK","result":{"t":1683986136017,"s":"BTCUSDT","bp":"26799.99","ap":"26810.3","lp":"26810.3","o":"26875.03","h":"28073.41","l":"25992.06","v":"2389.959483","qv":"65100545.90244497"},"retExtInfo":{},"time":1683986136450}';
27
        $data = (new CurlResponseHandler())->build(json_decode($json, true), TickersResponse::class);
28
29
        $this->assertEquals(0, $data->getReturnCode());
30
        $this->assertEquals('OK', $data->getReturnMessage());
31
        $this->assertInstanceOf(TickersResponse::class, $data->getResult());
32
33
        /** @var TickersResponse $tickerInfo */
34
        $tickerInfo = $data->getResult();
35
36
        $this->assertInstanceOf(\DateTime::class, $tickerInfo->getTime());
37
        $this->assertEquals('BTCUSDT', $tickerInfo->getSymbol());
38
        $this->assertEquals(26810.3, $tickerInfo->getLastTradedPrice());
39
        $this->assertEquals(28073.41, $tickerInfo->getHighPrice());
40
        $this->assertEquals(25992.06, $tickerInfo->getLowPrice());
41
        $this->assertEquals(26875.03, $tickerInfo->getOpenPrice());
42
        $this->assertEquals(26799.99, $tickerInfo->getBestBidPrice());
43
        $this->assertEquals(26810.3, $tickerInfo->getBestAskPrice());
44
        $this->assertEquals(2389.959483, $tickerInfo->getTradingVolume());
45
        $this->assertEquals(65100545.90244497, $tickerInfo->getTradingQuoteVolume());
46
    }
47
}
48