testCreatePaymentUIToken()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
nop 0
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