future-private: add change margin mode request

This commit is contained in:
mahdi msr committed 2025-09-28 16:02:15 +03:30
1 parent ccebbf8f70
commit d561f69ece
7 files changed
+424 -46

No files matched your search

+96
View File
@@ -0,0 +1,96 @@
<?php
use Msr\LaravelBitunixApi\Requests\ChangeMarginModeRequestContract;
beforeEach(function () {
config([
'bitunix-api.future_base_uri' => 'https://fapi.bitunix.com/',
'bitunix-api.api_key' => 'test-api-key',
'bitunix-api.api_secret' => 'test-secret-key',
'bitunix-api.language' => 'en-US',
]);
});
it('can change margin mode successfully', function () {
$api = app(ChangeMarginModeRequestContract::class);
expect(fn() => $api->changeMarginMode('BTCUSDT', 'USDT', 'ISOLATION'))
->not->toThrow(Exception::class)
->and(fn() => $api->changeMarginMode('BTCUSDT', 'USDT', 'CROSS'))
->not->toThrow(Exception::class);
});
it('validates required parameters for change margin mode', function () {
$api = app(ChangeMarginModeRequestContract::class);
expect(fn() => $api->changeMarginMode('BTCUSDT', 'USDT', 'ISOLATION'))
->not->toThrow(Exception::class)
->and(fn() => $api->changeMarginMode('ETHUSDT', 'USDT', 'CROSS'))
->not->toThrow(Exception::class);
});
it('handles different margin modes correctly', function () {
$api = app(ChangeMarginModeRequestContract::class);
$marginModes = ['ISOLATION', 'CROSS'];
foreach ($marginModes as $mode) {
expect(fn () => $api->changeMarginMode('BTCUSDT', 'USDT', $mode))
->not->toThrow(Exception::class);
}
});
it('validates margin mode parameter values', function () {
$api = app(ChangeMarginModeRequestContract::class);
expect(fn() => $api->changeMarginMode('BTCUSDT', 'USDT', 'ISOLATION'))
->not->toThrow(Exception::class)
->and(fn() => $api->changeMarginMode('BTCUSDT', 'USDT', 'CROSS'))
->not->toThrow(Exception::class);
});
it('can handle different trading pairs', function () {
$api = app(ChangeMarginModeRequestContract::class);
$tradingPairs = ['BTCUSDT', 'ETHUSDT', 'ADAUSDT'];
foreach ($tradingPairs as $symbol) {
expect(fn () => $api->changeMarginMode($symbol, 'USDT', 'ISOLATION'))
->not->toThrow(Exception::class);
}
});
it('can handle different margin coins', function () {
$api = app(ChangeMarginModeRequestContract::class);
$marginCoins = ['USDT', 'BTC', 'ETH'];
foreach ($marginCoins as $coin) {
expect(fn () => $api->changeMarginMode('BTCUSDT', $coin, 'ISOLATION'))
->not->toThrow(Exception::class);
}
});
it('validates margin mode constants', function () {
$api = app(ChangeMarginModeRequestContract::class);
$validModes = ['ISOLATION', 'CROSS'];
foreach ($validModes as $mode) {
expect(fn () => $api->changeMarginMode('BTCUSDT', 'USDT', $mode))
->not->toThrow(Exception::class);
}
});
it('handles edge cases for margin mode', function () {
$api = app(ChangeMarginModeRequestContract::class);
expect(fn() => $api->changeMarginMode('BTCUSDT', 'USDT', 'ISOLATION'))
->not->toThrow(Exception::class)
->and(fn() => $api->changeMarginMode('ETHUSDT', 'USDT', 'CROSS'))
->not->toThrow(Exception::class);
});