Completed
Push — master ( 10e479...8ee696 )
by Reginaldo
32:57
created

LojaControllerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 58
Duplicated Lines 32.76 %

Coupling/Cohesion

Components 1
Dependencies 2
Metric Value
wmc 2
lcom 1
cbo 2
dl 19
loc 58
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreateClienteByLojaController() 19 19 1
B testCreateClientByLojaControllerNextCreateAndress() 0 33 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
require(APP . 'Controller/AppController.php');
4
require(APP . 'Controller/LojaController.php');
5
6
/**
7
* 
8
*/
9
class LojaControllerTest extends PHPUnit_Framework_TestCase
10
{
11
	protected $Loja;
12
13 View Code Duplication
	public function testCreateClienteByLojaController()
14
	{
15
		$this->Loja = new LojaController;
16
		
17
		$data = array(
18
				'nome1' => 'reginaldo',
19
				'nome2' => 'luis',
20
				'email' => '[email protected]',
21
				'documento1' => '123.345.566-89',
22
				'data_de_nascimento' => '1995-03-10',
23
				'ativo' => 1,
24
				'id_usuario' => 23,
25
				'senha' => 'senha123'
26
			);
27
28
29
		$result = $this->Loja->saveClientFromEcommerce($data);
30
		$this->assertEquals(is_numeric($result), true);
31
	}
32
33
	public function testCreateClientByLojaControllerNextCreateAndress()
34
	{
35
		$this->Loja = new LojaController;
36
37
		$data = array(
38
			'nome1' => 'reginaldo',
39
			'nome2' => 'luis',
40
			'email' => '[email protected]',
41
			'documento1' => '123.345.566-89',
42
			'data_de_nascimento' => '1995-03-10',
43
			'ativo' => 1,
44
			'id_usuario' => 23,
45
			'senha' => 'senha123'
46
		);
47
48
		$result = $this->Loja->saveClientFromEcommerce($data);
49
		
50
		$data = array(
51
			'id_usuario' => 23,
52
			'id_cliente' => $result,
53
			'ativo'		 => 1,
54
			'cep'		 => '07252-000',
55
			'endereco'   => 'Avenida do Contorno',
56
			'numero'     => '19b',
57
			'bairro'	 => 'Nova Cidade',
58
			'cidade'	 => 'Guarulhos',
59
			'uf' 		 => 'SP'
60
		);
61
62
		$result = $this->Loja->saveAndressClientFromEcommerce($data);
63
64
		$this->assertEquals(is_array($result), true);
65
	}
66
}