Completed
Pull Request — master (#4)
by mw
11:15 queued 09:43
created

BacktraceSnifferTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 59
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testCanConstruct() 0 7 1
A testGetCaller() 0 9 1
A testGetCallerWithDifferentDepth() 0 14 1
A testGetCallers() 0 9 1
A testGetCallersWithDifferentDepth() 0 12 1
1
<?php
2
3
namespace Onoi\CallbackContainer\Tests;
4
5
use Onoi\CallbackContainer\BacktraceSniffer;
6
7
/**
8
 * @covers \Onoi\CallbackContainer\BacktraceSniffer
9
 * @group onoi-callback-container
10
 *
11
 * @license GNU GPL v2+
12
 * @since 2.0
13
 *
14
 * @author mwjames
15
 */
16
class BacktraceSnifferTest extends \PHPUnit_Framework_TestCase {
17
18
	public function testCanConstruct() {
19
20
		$this->assertInstanceOf(
21
			'\Onoi\CallbackContainer\BacktraceSniffer',
22
			new BacktraceSniffer()
23
		);
24
	}
25
26
	public function testGetCaller() {
27
28
		$instance = new BacktraceSniffer();
29
30
		$this->assertEquals(
31
			__METHOD__,
32
			$instance->getCaller()
33
		);
34
	}
35
36
	public function testGetCallerWithDifferentDepth() {
37
38
		$instance = new BacktraceSniffer();
39
40
		$this->assertEquals(
41
			'ReflectionMethod::invokeArgs',
42
			$instance->getCaller( 2 )
43
		);
44
45
		$this->assertEquals(
46
			'unknown',
47
			$instance->getCaller( 100 )
48
		);
49
	}
50
51
	public function testGetCallers() {
52
53
		$instance = new BacktraceSniffer();
54
55
		$this->assertEquals(
56
			array( __METHOD__ ),
57
			$instance->getCallers()
58
		);
59
	}
60
61
	public function testGetCallersWithDifferentDepth() {
62
63
		$instance = new BacktraceSniffer();
64
65
		$this->assertEquals(
66
			array(
67
				'ReflectionMethod::invokeArgs',
68
				__METHOD__
69
			),
70
			$instance->getCallers( 2 )
71
		);
72
	}
73
74
}
75