Completed
Push — master ( 910bf7...975979 )
by mw
02:04
created

SpyMessageReporterTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 45
wmc 3
lcom 0
cbo 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCanConstruct() 0 7 1
A testSpyOnReportedMessages() 0 17 1
A testClearMessages() 0 15 1
1
<?php
2
3
namespace Onoi\MessageReporter\Tests;
4
5
use Onoi\MessageReporter\SpyMessageReporter;
6
7
/**
8
 * @covers \Onoi\MessageReporter\SpyMessageReporter
9
 * @group onoi-message-reporter
10
 *
11
 * @license GNU GPL v2+
12
 * @since 1.2
13
 *
14
 * @author mwjames
15
 */
16
class SpyMessageReporterTest extends \PHPUnit_Framework_TestCase {
17
18
	public function testCanConstruct() {
19
20
		$this->assertInstanceOf(
21
			'\Onoi\MessageReporter\SpyMessageReporter',
22
			new SpyMessageReporter()
23
		);
24
	}
25
26
	public function testSpyOnReportedMessages() {
27
28
		$instance = new SpyMessageReporter();
29
		$instance->reportMessage( 'foo' );
30
31
		$this->assertEquals(
32
			array( 'foo' ),
33
			$instance->getMessages()
34
		);
35
36
		$instance->reportMessage( 'Bar' );
37
38
		$this->assertEquals(
39
			'foo, Bar',
40
			$instance->getMessagesAsString()
41
		);
42
	}
43
44
	public function testClearMessages() {
45
46
		$instance = new SpyMessageReporter();
47
		$instance->reportMessage( 'foo' );
48
49
		$this->assertNotEmpty(
50
			$instance->getMessages()
51
		);
52
53
		$instance->clearMessages();
54
55
		$this->assertEmpty(
56
			$instance->getMessages()
57
		);
58
	}
59
60
}
61