Skip to content

Commit 8eaf0ea

Browse files
committed
add live tests
1 parent 9f362a9 commit 8eaf0ea

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
]
3030
},
3131
"scripts": {
32-
"test": "phpunit tests/BinanceApiTest.php"
32+
"test": "phpunit tests/BinanceStaticTests.php",
33+
"live-tests": "phpunit tests/BinanceLiveTests.php"
3334
}
3435
}

php-binance-api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ protected function httpRequest(string $url, string $method = "GET", array $param
14581458

14591459
$base = $this->base;
14601460
if ($this->useTestnet) {
1461-
$base = $this->testnet;
1461+
$base = $this->baseTestnet;
14621462
}
14631463

14641464
if (isset($params['wapi'])) {

tests/BinanceLiveTests.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
use Binance\API;
4+
use PHPUnit\Framework\TestCase;
5+
6+
require_once __DIR__ . '/../php-binance-api.php'; // Adjust path if needed
7+
8+
9+
10+
class BinanceLiveTests extends TestCase
11+
{
12+
private Binance\API $binance;
13+
14+
public function setUp(): void {
15+
$this->binance = new API('api_key', 'api_secret');
16+
$this->binance->useTestnet = true;
17+
}
18+
public function testPricesSpot()
19+
{
20+
$res = $this->binance->prices();
21+
$this->assertIsArray($res);
22+
$this->assertArrayHasKey('BTCUSDT', $res);
23+
$this->assertIsString($res['BTCUSDT']);
24+
}
25+
26+
public function testPricesFutures()
27+
{
28+
$res = $this->binance->futuresPrices();
29+
$this->assertIsArray($res);
30+
$this->assertArrayHasKey('BTCUSDT', $res);
31+
$this->assertIsString($res['BTCUSDT']);
32+
}
33+
}

0 commit comments

Comments
 (0)