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
|
|
|
->addAddress('Av. Brigadeiro Faria Lima', 2927, 'Itaim', 'São Paulo', 'SP', '01234000', 'Apt. X', 'BRA') |
28
|
|
|
->create(); |
29
|
|
|
|
30
|
|
|
$this->assertNotEmpty($account->getId()); |
31
|
|
|
$this->assertNotEmpty($account->getAccessToken()); |
32
|
|
|
$this->assertNotEmpty($account->getchannelId()); |
33
|
|
|
$this->assertNotEmpty($account->getCreatedAt()); |
34
|
|
|
$this->assertEquals('144563480', $account->getIdentityDocumentNumber()); |
35
|
|
|
$this->assertEquals('SSP', $account->getIdentityDocumentIssuer()); |
36
|
|
|
$this->assertEquals('2017-10-25', $account->getIdentityDocumentIssueDate()); |
37
|
|
|
$this->assertEquals('RG', $account->getIdentityDocumentType()); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testShouldCreateAccountWithCompany() |
41
|
|
|
{ |
42
|
|
|
$this->mockHttpSession($this->body_moip_account_create); |
43
|
|
|
|
44
|
|
|
$account = $this->moip->accounts() |
45
|
|
|
->setName('For tests') |
46
|
|
|
->setLastName('Mine Customer Company') |
47
|
|
|
->setEmail('[email protected]') |
48
|
|
|
->setIdentityDocument('144563480', 'SSP', '2017-10-25') |
49
|
|
|
->setBirthDate('1990-01-01') |
50
|
|
|
->setTaxDocument('02822921873') |
51
|
|
|
->setType('MERCHANT') |
52
|
|
|
->setPhone(11, 965213244, 55) |
53
|
|
|
->addAlternativePhone(11, 912345678, 55) |
54
|
|
|
->setTransparentAccount(false) |
55
|
|
|
->addAddress('Av. Brigadeiro Faria Lima', 2927, 'Itaim', 'São Paulo', 'SP', '01234000', 'Apt. X', 'BRA') |
56
|
|
|
->setCompanyName('Mine Customer Company', 'Company Business') |
57
|
|
|
->setCompanyOpeningDate('2011-01-01') |
58
|
|
|
->setCompanyPhone(11, 987654321, 55) |
59
|
|
|
->setCompanyTaxDocument('64893609000110') |
60
|
|
|
->setCompanyAddress('R. Company', 321, 'Bairro Company', 'São Paulo', 'SP', '12345678', 'Ap. Y', 'BRA') |
61
|
|
|
->setCompanyMainActivity('82.91-1/00', 'Test') |
62
|
|
|
->create(); |
63
|
|
|
|
64
|
|
|
$this->assertNotEmpty($account->getId()); |
65
|
|
|
$this->assertNotEmpty($account->getAccessToken()); |
66
|
|
|
$this->assertNotEmpty($account->getchannelId()); |
67
|
|
|
$this->assertNotEmpty($account->getCreatedAt()); |
68
|
|
|
$this->assertEquals('144563480', $account->getIdentityDocumentNumber()); |
69
|
|
|
$this->assertEquals('SSP', $account->getIdentityDocumentIssuer()); |
70
|
|
|
$this->assertEquals('RG', $account->getIdentityDocumentType()); |
71
|
|
|
$this->assertEquals('912345678', $account->getAlternativePhones()[0]->number); |
72
|
|
|
$this->assertEquals('Company Business', $account->getCompany()->businessName); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function testCheckExistingAccount() |
76
|
|
|
{ |
77
|
|
|
$this->mockHttpSession('', 200); |
78
|
|
|
$this->assertTrue($this->moip->accounts()->checkExistence('123.456.798-91')); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function testCheckNonExistingAccount() |
82
|
|
|
{ |
83
|
|
|
$this->mockHttpSession('', 404); |
84
|
|
|
$this->assertFalse($this->moip->accounts()->checkExistence('412.309.725-10')); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function testShouldGetAccount() |
88
|
|
|
{ |
89
|
|
|
$this->mockHttpSession($this->body_moip_account_get); |
90
|
|
|
$account_id = 'MPA-7E9B1F907512'; |
91
|
|
|
$account = $this->moip->accounts()->get($account_id); |
92
|
|
|
|
93
|
|
|
$this->assertNotEmpty($account->getId()); |
94
|
|
|
$this->assertNotEmpty($account->getCreatedAt()); |
95
|
|
|
$this->assertEquals(false, $account->getTransparentAccount()); |
96
|
|
|
$this->assertEquals('[email protected]', $account->getLogin()); |
97
|
|
|
$this->assertEquals(true, $account->getEmailConfirmed()); |
98
|
|
|
$this->assertEquals('[email protected]', $account->getEmailAddress()); |
99
|
|
|
$this->assertEquals('794.663.228-26', $account->getTaxDocumentNumber()); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|