Completed
Pull Request — master (#173)
by
unknown
01:44
created

AccountTest::testShouldCreateAccount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 1
eloc 17
nc 1
nop 0
dl 0
loc 21
rs 9.3142
c 2
b 1
f 0
1
<?php
2
3
namespace Moip\Tests\Resource;
4
5
use Moip\Exceptions;
6
use Moip\Tests\TestCase;
7
8
/**
9
 * Description of AccountTest.
10
 */
11
class AccountTest extends TestCase
12
{
13
    public function testShouldCreateAccount()
14
    {
15
        $this->mockHttpSession($this->body_moip_account);
16
17
        $account = $this->moip->accounts()
18
            ->setName('Fulano')
19
            ->setLastName('De Tal')
20
            ->setEmail('[email protected]')
21
            ->setIdentityDocument('4737283560', 'SSP', '2015-06-23')
22
            ->setBirthDate('1988-12-30')
23
            ->setTaxDocument('16262131000')
24
            ->setType('MERCHANT')
25
            ->setPhone(11, 66778899, 55)
26
            ->addAlternativePhone(11, 66448899, 55)
27
            ->addAlternativePhone(11, 66338899, 55)
28
            ->setTransparentAccount(true)
29
            ->addAddress('Rua de teste', 123, 'Bairro', 'Sao Paulo', 'SP', '01234567', 'Apt. 23', 'BRA')
30
            ->create();
31
32
        $this->assertNotEmpty($account->getId());
33
    }
34
35
    public function testShouldCreateAccountWithCompany()
36
    {
37
        $this->mockHttpSession($this->body_moip_account);
38
39
        $account = $this->moip->accounts()
40
            ->setName('Fulano')
41
            ->setLastName('De Tal')
42
            ->setEmail('[email protected]')
43
            ->setIdentityDocument('4737283560', 'SSP', '2015-06-23')
44
            ->setBirthDate('1988-12-30')
45
            ->setTaxDocument('16262131000')
46
            ->setType('MERCHANT')
47
            ->setPhone(11, 66778899, 55)
48
            ->addAlternativePhone(11, 66448899, 55)
49
            ->addAlternativePhone(11, 66338899, 55)
50
            ->setTransparentAccount(true)
51
            ->addAddress('Rua de teste', 123, 'Bairro', 'Sao Paulo', 'SP', '01234567', 'Apt. 23', 'BRA')
52
            ->setCompanyName('Empresa Teste', 'Teste Empresa ME')
53
            ->setCompanyOpeningDate('2011-01-01')
54
            ->setCompanyPhone(11, 66558899, 55)
55
            ->setCompanyTaxDocument('69086878000198')
56
            ->setCompanyAddress('Rua de teste 2', 123, 'Bairro Teste', 'Sao Paulo', 'SP', '01234567', 'Apt. 23', 'BRA')
57
            ->setCompanyMainActivity('82.91-1/00', 'Atividades de cobranças e informações cadastrais')
58
            ->create();
59
60
        $this->assertNotEmpty($account->getId());
61
        $this->assertEquals('66448899', $account->getAlternativePhones()[0]->number);
62
        $this->assertEquals('Teste Empresa ME', $account->getCompany()->businessName);
63
    }
64
65
    public function testCheckExistingAccount()
66
    {
67
        $this->mockHttpSession('', 200);
68
        $this->assertTrue($this->moip->accounts()->checkAccountExists('123.456.798-91'));
69
    }
70
71
    public function testCheckNonExistingAccount()
72
    {
73
        $this->mockHttpSession('', 404);        
74
        $this->assertFalse($this->moip->accounts()->checkAccountExists('412.309.725-10'));
75
    }
76
77
}
78