Completed
Push — master ( 8bc6ad...b2c48e )
by Vitaliy
16:26 queued 13:19
created

TokenRequestTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 40
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testSetters() 0 37 1
1
<?php
2
3
namespace Xsolla\SDK\Tests\Unit\API\PaymentUI;
4
5
use Xsolla\SDK\API\PaymentUI\TokenRequest;
6
7
/**
8
 * @group unit
9
 */
10
class TokenRequestTest extends \PHPUnit_Framework_TestCase
11
{
12
    public function testSetters()
13
    {
14
        $tokenRequest = new TokenRequest('PROJECT_ID', 'USER_ID');
15
        $actualRequest = $tokenRequest->setUserEmail('[email protected]')
16
            ->setCustomParameters(array('a' => 1, 'b' => 2))
17
            ->setCurrency('USD')
18
            ->setExternalPaymentId(12345)
19
            ->setSandboxMode(true)
20
            ->setUserName('USER_NAME')
21
            ->setPurchase(1.5, 'EUR')
22
            ->toArray();
23
24
        $expectedRequest = array(
25
            'user' => array(
26
                'id' => array('value' => 'USER_ID'),
27
                'email' => array('value' => '[email protected]'),
28
                'name' => array('value' => 'USER_NAME'),
29
            ),
30
            'settings' => array(
31
                'project_id' => 'PROJECT_ID',
32
                'currency' => 'USD',
33
                'external_id' => 12345,
34
                'mode' => 'sandbox',
35
            ),
36
            'custom_parameters' => array(
37
                'a' => 1,
38
                'b' => 2,
39
            ),
40
            'purchase' => array(
41
                'checkout' => array(
42
                    'amount' => 1.5,
43
                    'currency' => 'EUR',
44
                ),
45
            ),
46
        );
47
        static::assertSame($expectedRequest, $actualRequest);
48
    }
49
}
50