Completed
Branch master (1d7ebe)
by Wanderson
02:15
created

AlertTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 54.55 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
dl 24
loc 44
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 4

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetMessage() 0 5 1
A testGetType() 0 7 1
A testLoad() 8 8 1
A testCreateAlertWithError() 8 8 1
A testCreateNoError() 8 8 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
namespace Win\Alert;
4
5
use Win\Alert\AlertError;
6
7
class AlertTest extends \PHPUnit_Framework_TestCase {
8
9
	public function testGetMessage() {
10
		$instance = new AlertError('My Alert');
11
		$this->assertEquals('My Alert', $instance->message);
12
		$this->assertEquals('My Alert', $instance);
13
	}
14
15
	public function testGetType() {
16
		$instance = new AlertError('My Error msg');
17
		$this->assertEquals('danger', $instance->type);
18
19
		$instance2 = new AlertSuccess('My Success msg');
20
		$this->assertEquals('success', $instance2->type);
21
	}
22
23 View Code Duplication
	public function testLoad() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
		ob_start();
25
		$alert = new AlertError('My Error msg');
26
		$alert->load();
27
		$content = ob_get_contents();
28
		ob_end_clean();
29
		$this->assertNotEmpty($content);
30
	}
31
32 View Code Duplication
	public function testCreateAlertWithError() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33
		ob_start();
34
		Session::showAlerts();
35
		$alert = Alert::create('This is a error', 'Congratulations');
36
		$this->assertTrue($alert instanceof AlertError);
37
		$this->assertEquals('This is a error', $alert->message);
38
		ob_end_clean();
39
	}
40
41 View Code Duplication
	public function testCreateNoError() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
42
		ob_start();
43
		Session::showAlerts();
44
		$alert = Alert::create(null, 'Congratulations');
45
		$this->assertTrue($alert instanceof AlertSuccess);
46
		$this->assertEquals('Congratulations', $alert->message);
47
		ob_end_clean();
48
	}
49
50
}
51