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

TickersTest::testTickersEndpoint()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 18
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 23
rs 9.6666
1
<?php
2
namespace Carpenstar\ByBitAPI\Spot\MarketData\Tickers\Tests;
3
4
use Carpenstar\ByBitAPI\Core\Builders\ResponseDtoBuilder;
5
use Carpenstar\ByBitAPI\Core\Builders\ResponseHandlerBuilder;
6
use Carpenstar\ByBitAPI\Core\Builders\RestBuilder;
7
use Carpenstar\ByBitAPI\Core\Enums\EnumOutputMode;
8
use Carpenstar\ByBitAPI\Core\Objects\Collection\EntityCollection;
9
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...
10
use Carpenstar\ByBitAPI\Core\Response\CurlResponseHandler;
11
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...
12
use Carpenstar\ByBitAPI\Spot\MarketData\Tickers\Request\TickersRequest;
13
use Carpenstar\ByBitAPI\Spot\MarketData\Tickers\Response\TickersResponse;
14
use PHPUnit\Framework\TestCase;
15
16
class TickersTest extends TestCase
17
{
18
    /**
19
     * Тестирование сборки объекта ответа
20
     *
21
     * @return void
22
     */
23
    public function testBuildResponseData()
24
    {
25
        $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}';
26
        $data = (new CurlResponseHandler())->build(json_decode($json, true), TickersResponse::class);
27
28
        $this->assertEquals(0, $data->getReturnCode());
29
        $this->assertEquals('OK', $data->getReturnMessage());
30
        $this->assertInstanceOf(TickersResponse::class, $data->getResult());
31
32
        /** @var TickersResponse $tickerInfo */
33
        $tickerInfo = $data->getResult();
34
35
        $this->assertInstanceOf(\DateTime::class, $tickerInfo->getTime());
36
        $this->assertEquals('BTCUSDT', $tickerInfo->getSymbol());
37
        $this->assertEquals(26810.3, $tickerInfo->getLastTradedPrice());
38
        $this->assertEquals(28073.41, $tickerInfo->getHighPrice());
39
        $this->assertEquals(25992.06, $tickerInfo->getLowPrice());
40
        $this->assertEquals(26875.03, $tickerInfo->getOpenPrice());
41
        $this->assertEquals(26799.99, $tickerInfo->getBestBidPrice());
42
        $this->assertEquals(26810.3, $tickerInfo->getBestAskPrice());
43
        $this->assertEquals(2389.959483, $tickerInfo->getTradingVolume());
44
        $this->assertEquals(65100545.90244497, $tickerInfo->getTradingQuoteVolume());
45
    }
46
}