Completed
Push — master ( 281da8...5c6217 )
by
unknown
24s queued 10s
created

CouponsTest::testCreateCoupon()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Xsolla\SDK\Tests\Integration\API;
4
5
/**
6
 * @group api
7
 */
8
class CouponsTest extends AbstractAPITest
9
{
10
    public function testCreateCoupon()
11
    {
12
        $response = static::$xsollaClient->CreateCoupon([
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $response is correct as static::$xsollaClient->C...sdk_coupon_', false)))) (which targets Xsolla\SDK\API\XsollaClient::CreateCoupon()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
13
            'campaign_id' => (int) getenv('CAMPAIGN_ID'),
14
            'request' => [
15
                'coupon_code' => uniqid('sdk_coupon_', false),
16
            ],
17
        ]);
18
        static::assertSame(204, $response->getStatusCode());
0 ignored issues
show
Bug introduced by
The method getStatusCode cannot be called on $response (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
19
    }
20
21
    public function testGetCoupon()
22
    {
23
        $actualCouponData = static::$xsollaClient->GetCoupon([
24
            'project_id' => static::$projectId,
25
            'code' => getenv('COUPON_CODE'),
26
        ]);
27
        static::assertInternalType('array', $actualCouponData);
28
    }
29
30
    public function testRedeemCoupon()
31
    {
32
        $actualCouponData = static::$xsollaClient->RedeemCoupon([
33
            'project_id' => static::$projectId,
34
            'code' => getenv('COUPON_CODE'),
35
            'request' => [
36
                'user_id' => static::$userId,
37
            ],
38
        ]);
39
        static::assertInternalType('array', $actualCouponData);
40
    }
41
}
42