Skip to content

Commit 25775ae

Browse files
authored
most of warnings in tests are handled
1 parent a8b7a22 commit 25775ae

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

tests/BinanceStaticTests.php

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,19 @@ public function testSpotMarketBuyTest()
274274
public function testSpotMarketQuoteSell()
275275
{
276276
try {
277-
$this->binance->marketQuoteSell($this->symbol, 1);
277+
$this->binance->marketQuoteSell($this->symbol, '1');
278278

279279
} catch (\Throwable $e) {
280280

281281
}
282+
// warns here cuz method needs information fetched by exchangeInfo
282283
$this->assertEquals("https://api.binance.com/api/v3/order", self::$capturedUrl);
283284

284285
parse_str(self::$capturedBody, $params);
285286

286287
$this->assertEquals($this->symbol, $params['symbol']);
288+
$this->assertEquals('SELL', $params['side']);
289+
$this->assertEquals('MARKET', $params['type']);
287290
$this->assertEquals(1, $params['quoteOrderQty']);
288291
$this->assertTrue(str_starts_with($params['newClientOrderId'], $this->SPOT_ORDER_PREFIX));
289292
}
@@ -313,12 +316,15 @@ public function testSpotMarketSell()
313316
} catch (\Throwable $e) {
314317

315318
}
319+
// warns here cuz method needs information fetched by exchangeInfo
316320
$this->assertEquals("https://api.binance.com/api/v3/order", self::$capturedUrl);
317321

318322
parse_str(self::$capturedBody, $params);
319323

320324
$this->assertEquals($this->symbol, $params['symbol']);
321325
$this->assertEquals(1, $params['quantity']);
326+
$this->assertEquals('SELL', $params['side']);
327+
$this->assertEquals('MARKET', $params['type']);
322328
$this->assertTrue(str_starts_with($params['newClientOrderId'], $this->SPOT_ORDER_PREFIX));
323329
}
324330

@@ -507,9 +513,15 @@ public function testSpotExchangeInfo()
507513
} catch (\Throwable $e) {
508514

509515
}
510-
$query ='symbols=["' . implode('","', $this->symbols) . '"]';
511-
$endpoint = "https://api.binance.com/api/v3/exchangeInfo?" . $query;
512-
$this->assertEquals(self::$capturedUrl, $endpoint);
516+
$endpoint = "https://api.binance.com/api/v3/exchangeInfo?";
517+
$this->assertTrue(str_starts_with (self::$capturedUrl, $endpoint));
518+
519+
$queryString = substr(self::$capturedUrl, strlen($endpoint));
520+
parse_str($queryString, $params);
521+
$this->assertTrue(!empty($params['symbols']));
522+
$symbols = $params['symbols'];
523+
$this->assertTrue(str_contains($symbols, $this->symbols[0]));
524+
$this->assertTrue(str_contains($symbols, $this->symbols[1]));
513525
}
514526

515527
public function testAssetDetail()
@@ -623,7 +635,6 @@ public function testDepositAddress()
623635

624636
$this->assertEquals($this->asset, $params['coin']);
625637
$this->assertEquals($this->network, $params['network']);
626-
627638
}
628639

629640
public function testDepositHistory()
@@ -641,7 +652,6 @@ public function testDepositHistory()
641652
parse_str($queryString, $params);
642653

643654
$this->assertEquals($this->asset, $params['coin']);
644-
645655
}
646656

647657
public function testWithdrawHistory()
@@ -745,7 +755,6 @@ public function testSpotPrice()
745755
parse_str($queryString, $params);
746756

747757
$this->assertEquals($this->symbol, $params['symbol']);
748-
749758
}
750759

751760
public function testSpotBookPrices()
@@ -861,7 +870,6 @@ public function testSpotDepth()
861870

862871
$this->assertEquals($this->symbol, $params['symbol']);
863872
$this->assertEquals($this->limit, $params['limit']);
864-
865873
}
866874

867875
public function testSpotBalances()
@@ -1046,7 +1054,7 @@ public function testApiTradingStatus()
10461054
public function testOcoOrder()
10471055
{
10481056
try {
1049-
$this->binance->ocoOrder($this->side, $this->symbol, $this->quantity, $this->price, $this->stopprice, $this->stoplimitprice, $this->stoplimittimeinforce);
1057+
$this->binance->ocoOrder($this->side, $this->symbol, $this->quantity, $this->price, $this->stopprice, $this->stoplimitprice);
10501058

10511059
} catch (\Throwable $e) {
10521060

@@ -1062,7 +1070,6 @@ public function testOcoOrder()
10621070
$this->assertEquals($this->stopprice, $params['stopPrice']);
10631071
$this->assertEquals($this->stoplimitprice, $params['stopLimitPrice']);
10641072
$this->assertEquals('GTC', $params['stopLimitTimeInForce']);
1065-
$this->assertTrue(str_starts_with($params['newClientOrderId'], $this->SPOT_ORDER_PREFIX_ORDER_PREFIX));
10661073
}
10671074

10681075
public function testSpotAvgPrice()
@@ -1080,7 +1087,6 @@ public function testSpotAvgPrice()
10801087
parse_str($queryString, $params);
10811088

10821089
$this->assertEquals($this->symbol, $params['symbol']);
1083-
10841090
}
10851091

10861092
public function testBswapQuote()
@@ -1141,7 +1147,6 @@ public function testFuturesDepth()
11411147

11421148
$this->assertEquals($this->symbol, $params['symbol']);
11431149
$this->assertEquals($this->limit, $params['limit']);
1144-
11451150
}
11461151

11471152
public function testFuturesRecentTrades()
@@ -1313,7 +1318,6 @@ public function testFuturesPremiumIndexCandlesticks()
13131318
$this->assertEquals($this->limit, $params['limit']);
13141319
$this->assertEquals($this->startTime, $params['startTime']);
13151320
$this->assertEquals($this->endTime, $params['endTime']);
1316-
13171321
}
13181322

13191323
public function testFuturesMarkPrice()
@@ -1428,7 +1432,6 @@ public function testFuturesPriceV2()
14281432
parse_str($queryString, $params);
14291433

14301434
$this->assertEquals($this->symbol, $params['symbol']);
1431-
14321435
}
14331436

14341437
public function testFuturesSymbolOrderBookTicker()
@@ -1837,8 +1840,8 @@ public function testFuturesEditOrder()
18371840
$this->assertEquals($this->side, $params['side']);
18381841
$this->assertEquals($this->quantity, $params['quantity']);
18391842
$this->assertEquals($this->price, $params['price']);
1840-
$this->assertEquals($this->paramsId, $params['paramsId']);
1841-
$this->assertEquals("GTC", $params['timeInForce']);
1843+
$this->assertEquals($this->orderId, $params['orderId']);
1844+
$this->assertEquals('GTC', $params['timeInForce']);
18421845
}
18431846

18441847
public function testFuturesEditOrders()
@@ -1855,7 +1858,7 @@ public function testFuturesEditOrders()
18551858
$this->binance->futuresEditOrders([ $order ], $this->recvWindow);
18561859

18571860
} catch (\Throwable $e) {
1858-
print_r($e);
1861+
18591862
}
18601863
$endpoint = "https://fapi.binance.com/fapi/v1/batchOrders?";
18611864
$this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint));
@@ -1923,7 +1926,7 @@ public function testFuturesCancelBatchOrdersByOrderIds()
19231926
} catch (\Throwable $e) {
19241927

19251928
}
1926-
$endpoint = "https://fapi.binance.com/fapi/v1/batchOrders?" . $query;
1929+
$endpoint = "https://fapi.binance.com/fapi/v1/batchOrders?";
19271930
$this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint));
19281931

19291932
$queryString = substr(self::$capturedUrl, strlen($endpoint));
@@ -1942,7 +1945,7 @@ public function testFuturesCancelBatchOrdersByClientOrderIds()
19421945
} catch (\Throwable $e) {
19431946

19441947
}
1945-
$endpoint = "https://fapi.binance.com/fapi/v1/batchOrders?" . $query;
1948+
$endpoint = "https://fapi.binance.com/fapi/v1/batchOrders?";
19461949
$this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint));
19471950

19481951
$queryString = substr(self::$capturedUrl, strlen($endpoint));
@@ -2205,12 +2208,11 @@ public function testFuturesPositionMode()
22052208
} catch (\Throwable $e) {
22062209

22072210
}
2208-
$endpoint = "https://fapi.binance.com/fapi/v1/positionSide/dual?" . $query;
2211+
$endpoint = "https://fapi.binance.com/fapi/v1/positionSide/dual?";
22092212
$this->assertTrue(str_starts_with(self::$capturedUrl, $endpoint));
22102213

22112214
$queryString = substr(self::$capturedUrl, strlen($endpoint));
22122215
parse_str($queryString, $params);
2213-
22142216
$this->assertEquals($this->recvWindow, $params['recvWindow']);
22152217
}
22162218

@@ -2822,7 +2824,7 @@ public function testConvertSend()
28222824
$this->binance->convertSend($this->fromAsset, $this->toAsset, $this->fromAmount, null, $this->validTime, $this->recvWindow);
28232825

28242826
} catch (\Throwable $e) {
2825-
print_r ($e);
2827+
28262828
}
28272829
$this->assertEquals("https://fapi.binance.com/fapi/v1/convert/getQuote", self::$capturedUrl);
28282830

@@ -2849,7 +2851,6 @@ public function testConvertAccept()
28492851

28502852
$this->assertEquals($this->quoteId, $params['quoteId']);
28512853
$this->assertEquals($this->recvWindow, $params['recvWindow']);
2852-
$this->assertEquals($this->params, $params['params']);
28532854
}
28542855

28552856
public function testConvertStatusByOrderId()

0 commit comments

Comments
 (0)