mageekguy\atoum\asserters\mock: lines coverage

99% of 198

OPs

96% of 27

Lines

71% of 24

Branches

73% of 11

Paths
Method OPs OPs % Lines Line % Branches Branches % Paths Path %
mageekguy\atoum\asserters\mock::setWith() 59 100% 7 86% 5 80% 2 50%
mageekguy\atoum\asserters\mock::receive() 11 100% 1 100% 1 100% 1 100%
mageekguy\atoum\asserters\mock::wasCalled() 43 100% 6 100% 5 80% 2 50%
mageekguy\atoum\asserters\mock::wasNotCalled() 43 100% 6 100% 5 80% 2 50%
mageekguy\atoum\asserters\mock::adapterIsSet() 21 95% 4 100% 4 50% 2 100%
mageekguy\atoum\asserters\mock::callIsSet() 21 95% 3 100% 4 50% 2 100%
#
1
<?php
2

                    
3
namespace mageekguy\atoum\asserters;
4

                    
5
use
6
	mageekguy\atoum\asserter,
7
	mageekguy\atoum\exceptions,
8
	mageekguy\atoum\asserters\adapter,
9
	mageekguy\atoum\test\adapter\call\decorators
10
;
11

                    
12
class mock extends adapter
13
{
14
	public function setWith($mock)86%
15
	{
16
		if ($mock instanceof \mageekguy\atoum\mock\aggregator === false)
17
		{
18
			$this->fail($this->_('%s is not a mock', $this->getTypeOf($mock)));
19
		}
20
		else
21
		{
22
			parent::setWith($mock->getMockController());
23

                    
24
			$this->call->setDecorator(new decorators\addClass($this->adapter->getMockClass()));
25
		}
26

                    
27
		return $this;
28
	}
29

                    
30
	public function receive($function)100%
31
	{
32
		return $this->call($function);
33
	}
34

                    
35
	public function wasCalled($failMessage = null)100%
36
	{
37
		if ($this->adapterIsSet()->adapter->getCallsNumber() > 0)
38
		{
39
			$this->pass();
40
		}
41
		else
42
		{
43
			$this->fail($failMessage ?: $this->_('%s is not called', $this->adapter->getMockClass()));
44
		}
45

                    
46
		return $this;
47
	}
48

                    
49
	public function wasNotCalled($failMessage = null)100%
50
	{
51
		if ($this->adapterIsSet()->adapter->getCallsNumber() <= 0)
52
		{
53
			$this->pass();
54
		}
55
		else
56
		{
57
			$this->fail($failMessage ?: $this->_('%s is called', $this->adapter->getMockClass()));
58
		}
59

                    
60
		return $this;
61
	}
62

                    
63
	protected function adapterIsSet()100%
64
	{
65
		try
66
		{
67
			return parent::adapterIsSet();
68
		}
69
		catch (adapter\exceptions\logic $exception)
70
		{
71
			throw new mock\exceptions\logic('Mock is undefined');
72
		}
73
	}
74

                    
75
	protected function callIsSet()100%
76
	{
77
		try
78
		{
79
			return parent::callIsSet();
80
		}
81
		catch (adapter\exceptions\logic $exception)
82
		{
83
			throw new mock\exceptions\logic('Call is undefined');
84
		}
85
	}
86
}