Completed
Push — master ( 8d6a89...35c84b )
by Aimeos
09:03
created

CheckTest::testWaitNotAvailable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Aimeos\MW\Process\Decorator;
4
5
6
class CheckTest extends \PHPUnit\Framework\TestCase
7
{
8
	private $object;
9
	private $stub;
10
11
12
	protected function setUp()
13
	{
14
		$this->stub = $this->getMockBuilder( 'Aimeos\MW\Process\Iface' )
15
			->setMethods( ['isAvailable', 'start', 'wait'] )
16
			->getMock();
17
18
		$this->object = new \Aimeos\MW\Process\Decorator\Check( $this->stub );
19
	}
20
21
22
	protected function tearDown()
23
	{
24
		unset( $this->object, $this->stub );
25
	}
26
27
28
	public function testIsAvailable()
29
	{
30
		$this->stub->expects( $this->once() )->method( 'isAvailable' )
31
			->will( $this->returnValue( true ) );
32
33
		$this->assertTrue( $this->object->isAvailable() );
34
	}
35
36
37
	public function testIsAvailableFalse()
38
	{
39
		$this->stub->expects( $this->once() )->method( 'isAvailable' )
40
			->will( $this->returnValue( false ) );
41
42
		$this->assertFalse( $this->object->isAvailable() );
43
	}
44
45
46
	public function testStart()
47
	{
48
		$fcn = function() {};
49
50
		$this->stub->expects( $this->once() )->method( 'isAvailable' )
51
			->will( $this->returnValue( true ) );
52
53
		$this->stub->expects( $this->once() )->method( 'start' );
54
55
		$this->object->start( $fcn, [] );
56
	}
57
58
59
	public function testStartNotAvailable()
60
	{
61
		$fcn = function() {};
62
63
		$this->stub->expects( $this->once() )->method( 'isAvailable' )
64
			->will( $this->returnValue( false ) );
65
66
		$this->stub->expects( $this->never() )->method( 'start' );
67
68
		$this->object->start( $fcn, [] );
69
	}
70
71
72
	public function testWait()
73
	{
74
		$fcn = function() {};
75
76
		$this->stub->expects( $this->once() )->method( 'isAvailable' )
77
			->will( $this->returnValue( true ) );
78
79
		$this->stub->expects( $this->once() )->method( 'wait' );
80
81
		$this->object->wait();
82
	}
83
84
85
	public function testWaitNotAvailable()
86
	{
87
		$fcn = function() {};
88
89
		$this->stub->expects( $this->once() )->method( 'isAvailable' )
90
			->will( $this->returnValue( false ) );
91
92
		$this->stub->expects( $this->never() )->method( 'wait' );
93
94
		$this->object->wait();
95
	}
96
}
97