CreatePaymentUITokenTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 36
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreateCommonPaymentUIToken() 0 5 1
A testCreatePaymentUITokenFromRequest() 0 12 1
A testCreatePaymentUIToken() 0 14 2
1
<?php
2
3
namespace Xsolla\SDK\Tests\Integration\API;
4
5
use Xsolla\SDK\API\PaymentUI\TokenRequest;
6
7
/**
8
 * @group api
9
 */
10
class CreatePaymentUITokenTest extends AbstractAPITest
11
{
12
    public function testCreateCommonPaymentUIToken()
13
    {
14
        $token = static::$xsollaClient->createCommonPaymentUIToken(static::$projectId, static::$userId, true);
15
        static::assertInternalType('string', $token);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit\Framework\Assert::assertInternalType() has been deprecated with message: https://github.com/sebastianbergmann/phpunit/issues/3369

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
16
    }
17
18
    public function testCreatePaymentUITokenFromRequest()
19
    {
20
        $tokenRequest = new TokenRequest(static::$projectId, static::$userId);
21
        $tokenRequest->setUserEmail('[email protected]')
22
            ->setCustomParameters(['a' => 1, 'b' => 2])
23
            ->setCurrency('USD')
24
            ->setSandboxMode(true)
25
            ->setUserName('USER_NAME')
26
            ->setPurchase(1.5, 'EUR');
27
        $token = static::$xsollaClient->createPaymentUITokenFromRequest($tokenRequest);
28
        static::assertInternalType('string', $token);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit\Framework\Assert::assertInternalType() has been deprecated with message: https://github.com/sebastianbergmann/phpunit/issues/3369

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
29
    }
30
31
    public function testCreatePaymentUIToken()
32
    {
33
        $requestJsonFileName = __DIR__.'/../../Resources/Fixtures/token.json';
34
        $tokenPayload = file_get_contents($requestJsonFileName);
35
        if (false === $tokenPayload) {
36
            static::fail('Could not read token request from tests/resources/token.json');
37
        }
38
        $request = json_decode($tokenPayload, true);
39
        $request['settings']['project_id'] = static::$projectId;
40
        $request['user']['id']['value'] = static::$userId;
41
        $tokenResponse = static::$xsollaClient->CreatePaymentUIToken(['request' => $request]);
42
        static::assertArrayHasKey('token', $tokenResponse);
43
        static::assertInternalType('string', $tokenResponse['token']);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit\Framework\Assert::assertInternalType() has been deprecated with message: https://github.com/sebastianbergmann/phpunit/issues/3369

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
44
    }
45
}
46