Completed
Push — master ( 67d6bf...156008 )
by Reginaldo
39:41
created

PagseguroControllerTest::testFinalizarPedido()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 52
Code Lines 33

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 52
rs 9.4929
cc 1
eloc 33
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
require(APP . 'Controller/AppController.php');
4
require(APP . 'Controller/PagseguroController.php');
5
6
/**
7
* PagseguroControllerTest
8
*/
9
class PagseguroControllerTest extends PHPUnit_Framework_TestCase
10
{
11
12
	protected $pagSeguroController;
13
14
	public function setUp()
15
	{
16
		$this->pagSeguroController = new PagseguroController;
17
		parent::setUp();
18
	}
19
20
	public function testFinalizarPedido()
21
	{
22
		$this->pagSeguroController->setToken('25AB84E7DE7647848D0819210140F79D');
23
        
24
        $this->pagSeguroController->setEmail('[email protected]');
25
        
26
        $produto = array(
27
            0 => array(
28
                'Produto' => array(
29
                    'id' => 23,
30
                    'nome' => 'Produto Teste',
31
                    'variacao' => 'M',
32
                    'quantidade' => 1.00,
33
                    'preco' => 2.44
34
                )
35
            )
36
        );
37
38
        $this->pagSeguroController->setProdutos($produto);
39
40
        $this->pagSeguroController->adicionarProdutosGateway();
41
42
        $endereco = array(
43
            'cep' => '07252-000',
44
            'endereco' => 'Avenida do Contorno',
45
            'numero' => 19,
46
            'complemento' => 'Viela',
47
            'bairro' => 'Nova cidade',
48
            'cidade' => 'Guarulhos',
49
            'estado' => 'SP'
50
        );
51
52
        $this->pagSeguroController->setEndereco($endereco);
53
54
        $cliente = array(
55
            'nome' => 'Reginaldo Junior',
56
            'email' => '[email protected]',
57
            'ddd' => '11',
58
            'telefone' => '946640932',
59
            'cpf' => '43944409843'
60
        );
61
62
        $this->pagSeguroController->setCliente($cliente);
63
64
        $this->pagSeguroController->setReference('#2324');
65
66
        $this->pagSeguroController->setValorFrete(23.44);
67
68
        $url = $this->pagSeguroController->finalizarPedido();
69
70
        $this->assertContains('http', $url);
71
	}
72
73
}
74