|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Tests\Unit\FizzBuzzDomain; |
|
4
|
|
|
|
|
5
|
|
|
use FizzBuzzDomain\Game; |
|
6
|
|
|
use FizzBuzzDomain\Rules\RulesSets\StandardRulesSet; |
|
7
|
|
|
use GameDomain\Round\RoundCollection; |
|
8
|
|
|
use GameDomain\Round\RoundResultCollection; |
|
9
|
|
|
use GameDomain\Round\Step\StepResultCollection; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Game Test |
|
13
|
|
|
*/ |
|
14
|
|
|
class GameTest extends \PHPUnit_Framework_TestCase |
|
15
|
|
|
{ |
|
16
|
|
|
const NB_ROUNDS = 3; |
|
17
|
|
|
|
|
18
|
|
|
/** @var \FizzBuzzDomain\Game */ |
|
19
|
|
|
protected $sut; |
|
20
|
|
|
|
|
21
|
|
|
/** @var \GameDomain\Round\RoundCollection */ |
|
22
|
|
|
protected $roundMockCollection; |
|
23
|
|
|
|
|
24
|
|
|
/** @var \GameDomain\Rule\AbstractRulesSet */ |
|
25
|
|
|
protected $rulesSet; |
|
26
|
|
|
|
|
27
|
|
|
/** @var \GameDomain\Round\AbstractRound|\PHPUnit_Framework_MockObject_MockObject */ |
|
28
|
|
|
protected $roundMock; |
|
29
|
|
|
|
|
30
|
|
|
/** @var \GameDomain\Round\RoundResultCollection */ |
|
31
|
|
|
protected $roundResultCollection; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* {@inheritDoc} |
|
35
|
|
|
*/ |
|
36
|
|
|
public function setUp() |
|
37
|
|
|
{ |
|
38
|
|
|
$this->roundMock = $this->getMockForAbstractClass( |
|
39
|
|
|
'\GameDomain\Round\AbstractRound', |
|
40
|
|
|
array(), |
|
41
|
|
|
'', |
|
42
|
|
|
false, |
|
43
|
|
|
false, |
|
44
|
|
|
true, |
|
45
|
|
|
array('play') |
|
46
|
|
|
); |
|
47
|
|
|
$this->roundMockCollection = new RoundCollection(array_fill(0, static::NB_ROUNDS, $this->roundMock)); |
|
48
|
|
|
$this->roundResultCollection = new RoundResultCollection( |
|
49
|
|
|
array_fill(0, static::NB_ROUNDS, new StepResultCollection()) |
|
50
|
|
|
); |
|
51
|
|
|
|
|
52
|
|
|
$this->rulesSet = new StandardRulesSet(); |
|
53
|
|
|
$this->sut = new Game($this->rulesSet); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @test |
|
58
|
|
|
*/ |
|
59
|
|
|
public function testPlayingTheGame() |
|
60
|
|
|
{ |
|
61
|
|
|
$this->roundMock->expects($this->exactly(static::NB_ROUNDS)) |
|
62
|
|
|
->method('play') |
|
63
|
|
|
->with($this->rulesSet) |
|
64
|
|
|
->will($this->returnValue($this->roundResultCollection)); |
|
65
|
|
|
|
|
66
|
|
|
$gameResult = $this->sut->play($this->roundMockCollection); |
|
67
|
|
|
|
|
68
|
|
|
$this->assertInstanceOf('\GameDomain\Round\RoundResultCollection', $gameResult); |
|
69
|
|
|
$this->assertCount(static::NB_ROUNDS, $gameResult); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|