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

SessionTest::testShowAnything()   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 SessionTest extends \PHPUnit_Framework_TestCase {
8
9
	public function setUp() {
10
		Session::clearAlerts();
11
	}
12
13
	public function testCountAlerts() {
14
		ob_start();
15
		new AlertError('My Alert 01');
16
		new AlertError('My Alert 02');
17
		$this->assertEquals(2, count(Session::getAlerts()));
18
19
		Session::clearAlerts();
20
		$this->assertEquals(0, count(Session::getAlerts()));
21
		ob_end_clean();
22
	}
23
24
	public function testHasAlert() {
25
		new AlertDefault('Test');
26
		$this->assertEquals(true, Session::hasAlert());
27
	}
28
29
	public function testHasNoAlert() {
30
		new AlertDefault('Test');
31
		Session::clearAlerts();
32
		$this->assertEquals(false, Session::hasAlert());
33
	}
34
35
	public function testGetAlerts() {
36
		$alert = new AlertError('I am the firt error');
37
		$alerts = Session::getAlerts();
38
		$this->assertEquals($alert->message, $alerts[0]->message);
39
	}
40
41 View Code Duplication
	public function testShowAnything() {
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
		new AlertError('My Error msg');
44
		Session::showAlerts();
45
		$content = ob_get_contents();
46
		ob_end_clean();
47
		$this->assertNotEmpty($content);
48
	}
49
50
	public function testShowNothing() {
51
		ob_start();
52
		Session::showAlerts();
53
		$content = ob_get_contents();
54
		ob_end_clean();
55
		$this->assertEmpty($content);
56
	}
57
58
}
59