Test Failed
Pull Request — master (#20)
by Vladislav
02:49
created

PlaceOrderTest::testSuccessEndpoint()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 15
nc 1
nop 0
dl 0
loc 22
rs 9.7666
c 0
b 0
f 0
1
<?php
2
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Order\PlaceOrder\Tests;
3
4
use Carpenstar\ByBitAPI\BybitAPI;
5
use Carpenstar\ByBitAPI\Core\Enums\EnumOrderType;
6
use Carpenstar\ByBitAPI\Core\Enums\EnumSide;
7
use Carpenstar\ByBitAPI\Core\Interfaces\IResponseInterface;
0 ignored issues
show
Bug introduced by
The type Carpenstar\ByBitAPI\Core...aces\IResponseInterface 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...
8
use Carpenstar\ByBitAPI\Derivatives\Contract\Order\PlaceOrder\PlaceOrder;
9
use Carpenstar\ByBitAPI\Derivatives\Contract\Order\PlaceOrder\Request\PlaceOrderRequest;
10
use Carpenstar\ByBitAPI\Derivatives\Contract\Order\PlaceOrder\Response\PlaceOrderResponse;
11
use PHPUnit\Framework\TestCase;
12
13
class PlaceOrderTest extends TestCase
14
{
15
    public function testSuccessEndpoint()
16
    {
17
        $bybitApi = (new BybitAPI())
0 ignored issues
show
Bug introduced by
The call to Carpenstar\ByBitAPI\BybitAPI::__construct() has too few arguments starting with host. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
        $bybitApi = (/** @scrutinizer ignore-call */ new BybitAPI())

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
18
            ->setCredentials('https://api-testnet.bybit.com', 'fL02oi5qo8i2jDxlum', 'Ne1EE35XTprIWrId9vGEAc1ZYJTmodA4qFzZ');
0 ignored issues
show
Bug introduced by
The method setCredentials() does not exist on Carpenstar\ByBitAPI\BybitAPI. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
            ->/** @scrutinizer ignore-call */ setCredentials('https://api-testnet.bybit.com', 'fL02oi5qo8i2jDxlum', 'Ne1EE35XTprIWrId9vGEAc1ZYJTmodA4qFzZ');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
19
20
        /** @var IResponseInterface $endpointResponse */
21
        $endpointResponse = $bybitApi->privateEndpoint(PlaceOrder::class,
22
            (new PlaceOrderRequest())
23
                ->setSymbol('BTCUSDT')
24
                ->setOrderType(EnumOrderType::LIMIT)
25
                ->setSide(EnumSide::BUY)
26
                ->setQty('0.01')
0 ignored issues
show
Bug introduced by
'0.01' of type string is incompatible with the type double expected by parameter $quantity of Carpenstar\ByBitAPI\Deri...eOrderRequest::setQty(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
                ->setQty(/** @scrutinizer ignore-type */ '0.01')
Loading history...
27
                ->setPrice(68100)
28
        )->execute();
29
30
        echo "Return code: {$endpointResponse->getReturnCode()} \n";
31
        echo "Return message: {$endpointResponse->getReturnMessage()} \n";
32
33
        /** @var PlaceOrderResponse $orderInfo */
34
        $orderInfo = $endpointResponse->getResult();
35
        echo "Order ID: {$orderInfo->getOrderId()}\n";
36
        echo "Order Link ID: {$orderInfo->getOrderLinkId()}\n";
37
38
        /**
39
         * Return code: 0
40
         * Return message: OK
41
         * Order ID: bac5bf12-edf6-433b-8ce4-d4d14de281cd
42
         * Order Link ID:
43
         */
44
    }
45
}