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

AlertTest::testCreateAlertWithError()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 8
loc 8
rs 10
c 0
b 0
f 0
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