AccountTest::testShouldCreateAccount()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 28
nc 1
nop 0
dl 0
loc 32
rs 8.8571
c 1
b 0
f 1
1
<?php
2
3
namespace Moip\Tests\Resource;
4
5
use Moip\Tests\TestCase;
6
7
/**
8
 * Description of AccountTest.
9
 */
10
class AccountTest extends TestCase
11
{
12
    public function testShouldCreateAccount()
13
    {
14
        $this->mockHttpSession($this->body_moip_account_create);
15
16
        $account = $this->moip->accounts()
17
            ->setName('For tests')
18
            ->setLastName('Mine Customer Company')
19
            ->setEmail('[email protected]')
20
            ->setIdentityDocument('144563480', 'SSP', '2017-10-25')
21
            ->setBirthDate('1990-01-01')
22
            ->setTaxDocument('02822921873')
23
            ->setType('MERCHANT')
24
            ->setPhone(11, 965213244, 55)
25
            ->addAlternativePhone(11, 912345678, 55)
26
            ->setTransparentAccount(false)
27
            ->setBusinessSegment(5)
28
            ->addAddress('Av. Brigadeiro Faria Lima', 2927, 'Itaim', 'São Paulo', 'SP', '01234000', 'Apt. X', 'BRA')
29
            ->create();
30
31
        $this->assertNotEmpty($account->getId());
32
        $this->assertNotEmpty($account->getAccessToken());
33
        $this->assertNotEmpty($account->getchannelId());
34
        $this->assertNotEmpty($account->getCreatedAt());
35
        $this->assertEquals('144563480', $account->getIdentityDocumentNumber());
36
        $this->assertEquals('SSP', $account->getIdentityDocumentIssuer());
37
        $this->assertEquals('2017-10-25', $account->getIdentityDocumentIssueDate());
38
        $this->assertEquals('RG', $account->getIdentityDocumentType());
39
        $this->assertEquals('https://desenvolvedor.moip.com.br/sandbox/AskForNewPassword.do?method=confirm&email=dev.moip%40labs.moip.com.br&code=8e3b306d59907f4a47508913956c96ba', $account->getPasswordLink());
40
        $this->assertEquals(5, $account->getBusinessSegmentId());
41
        $this->assertEquals('Antiguidades / Negociante de artes / Galerias', $account->getBusinessSegmentName());
42
        $this->assertEquals(5971, $account->getBusinessSegmentMcc());
43
    }
44
45
    public function testShouldCreateAccountWithCompany()
46
    {
47
        $this->mockHttpSession($this->body_moip_account_create);
48
49
        $account = $this->moip->accounts()
50
            ->setName('For tests')
51
            ->setLastName('Mine Customer Company')
52
            ->setEmail('[email protected]')
53
            ->setIdentityDocument('144563480', 'SSP', '2017-10-25')
54
            ->setBirthDate('1990-01-01')
55
            ->setTaxDocument('02822921873')
56
            ->setType('MERCHANT')
57
            ->setPhone(11, 965213244, 55)
58
            ->addAlternativePhone(11, 912345678, 55)
59
            ->setTransparentAccount(false)
60
            ->addAddress('Av. Brigadeiro Faria Lima', 2927, 'Itaim', 'São Paulo', 'SP', '01234000', 'Apt. X', 'BRA')
61
            ->setCompanyName('Mine Customer Company', 'Company Business')
62
            ->setCompanyOpeningDate('2011-01-01')
63
            ->setCompanyPhone(11, 987654321, 55)
64
            ->setCompanyTaxDocument('64893609000110')
65
            ->setCompanyAddress('R. Company', 321, 'Bairro Company', 'São Paulo', 'SP', '12345678', 'Ap. Y', 'BRA')
66
            ->setCompanyMainActivity('82.91-1/00', 'Test')
67
            ->create();
68
69
        $this->assertNotEmpty($account->getId());
70
        $this->assertNotEmpty($account->getAccessToken());
71
        $this->assertNotEmpty($account->getchannelId());
72
        $this->assertNotEmpty($account->getCreatedAt());
73
        $this->assertEquals('144563480', $account->getIdentityDocumentNumber());
74
        $this->assertEquals('SSP', $account->getIdentityDocumentIssuer());
75
        $this->assertEquals('RG', $account->getIdentityDocumentType());
76
        $this->assertEquals('912345678', $account->getAlternativePhones()[0]->number);
77
        $this->assertEquals('Company Business', $account->getCompany()->businessName);
78
    }
79
80
    public function testCheckExistingAccount()
81
    {
82
        $this->mockHttpSession('', 200);
83
        $this->assertTrue($this->moip->accounts()->checkExistence('123.456.798-91'));
84
    }
85
86
    public function testCheckNonExistingAccount()
87
    {
88
        $this->mockHttpSession('', 404);
89
        $this->assertFalse($this->moip->accounts()->checkExistence('412.309.725-10'));
90
    }
91
92
    public function testShouldGetAccount()
93
    {
94
        $this->mockHttpSession($this->body_moip_account_get);
95
        $account_id = 'MPA-7E9B1F907512';
96
        $account = $this->moip->accounts()->get($account_id);
97
98
        $this->assertNotEmpty($account->getId());
99
        $this->assertNotEmpty($account->getCreatedAt());
100
        $this->assertEquals(false, $account->getTransparentAccount());
101
        $this->assertEquals('[email protected]', $account->getLogin());
102
        $this->assertEquals(true, $account->getEmailConfirmed());
103
        $this->assertEquals('[email protected]', $account->getEmailAddress());
104
        $this->assertEquals('794.663.228-26', $account->getTaxDocumentNumber());
105
    }
106
}
107