|
1
|
|
|
<?php |
|
2
|
|
|
namespace Carpenstar\ByBitAPI\Spot\LeverageToken\MarketInfo\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; |
|
10
|
|
|
use Carpenstar\ByBitAPI\Core\Response\CurlResponseHandler; |
|
11
|
|
|
use Carpenstar\ByBitAPI\Spot\Account\WalletBalance\Overrides\TestWalletBalance; |
|
12
|
|
|
use Carpenstar\ByBitAPI\Spot\Account\WalletBalance\Response\WalletBalanceResponse; |
|
13
|
|
|
use Carpenstar\ByBitAPI\Spot\LeverageToken\MarketInfo\Overrides\TestMarketInfo; |
|
14
|
|
|
use Carpenstar\ByBitAPI\Spot\LeverageToken\MarketInfo\Request\MarketInfoRequest; |
|
15
|
|
|
use Carpenstar\ByBitAPI\Spot\LeverageToken\MarketInfo\Response\MarketInfoResponse; |
|
16
|
|
|
use PHPUnit\Framework\TestCase; |
|
17
|
|
|
|
|
18
|
|
|
class MarketInfoTest extends TestCase |
|
19
|
|
|
{ |
|
20
|
|
|
static private string $marketInfoResponse = '{"retCode":0,"retMsg":"OK","result":{"basket":"230666.700009559600667216","circulation":"24999.840207851103706443","leverage": "2.302545313639639446","ltCode":"EOS2L","nav":"3.790797803797135639","navTime":1673346095226},"retExtInfo":{},"time":1673346095239}'; |
|
21
|
|
|
|
|
22
|
|
|
public function testMarketInfoDTOBuilder() |
|
23
|
|
|
{ |
|
24
|
|
|
$dto = ResponseDtoBuilder::make(MarketInfoResponse::class, json_decode(self::$marketInfoResponse, true)['result']); |
|
25
|
|
|
$this->assertInstanceOf(MarketInfoResponse::class, $dto); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function testMarketInfoResponseHandlerBuilder() |
|
29
|
|
|
{ |
|
30
|
|
|
$handler = ResponseHandlerBuilder::make(self::$marketInfoResponse, CurlResponseHandler::class, MarketInfoResponse::class); |
|
31
|
|
|
$this->assertInstanceOf(EntityCollection::class, $handler->getBody()); |
|
32
|
|
|
$this->assertGreaterThan(0, $handler->getBody()->count()); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function testMarketInfoEndpoint() |
|
36
|
|
|
{ |
|
37
|
|
|
$endpoint = RestBuilder::make(TestMarketInfo::class, (new MarketInfoRequest())); |
|
38
|
|
|
|
|
39
|
|
|
$entityResponse = $endpoint->execute(EnumOutputMode::MODE_ENTITY, self::$marketInfoResponse); |
|
40
|
|
|
$this->assertInstanceOf(CurlResponseDto::class, $entityResponse); |
|
41
|
|
|
$body = $entityResponse->getBody(); |
|
42
|
|
|
$this->assertInstanceOf(EntityCollection::class, $body); |
|
43
|
|
|
|
|
44
|
|
|
foreach ($body->fetch() as $wallet) { |
|
45
|
|
|
$dto = ResponseDtoBuilder::make(MarketInfoResponse::class, $wallet); |
|
46
|
|
|
$this->assertInstanceOf(MarketInfoResponse::class, $dto); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
} |