|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace ArpTest\DominoGame\Value; |
|
6
|
|
|
|
|
7
|
|
|
use Arp\DominoGame\Value\Domino; |
|
8
|
|
|
use Arp\DominoGame\Value\Player; |
|
9
|
|
|
use PHPUnit\Framework\TestCase; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* @author Alex Patterson <[email protected]> |
|
13
|
|
|
* @package ArpTest\Value\PlayerTest |
|
14
|
|
|
*/ |
|
15
|
|
|
final class PlayerTest extends TestCase |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* Assert that the player starts with an empty hand. |
|
19
|
|
|
* |
|
20
|
|
|
* @covers \Arp\DominoGame\Value\Player::getHand |
|
21
|
|
|
*/ |
|
22
|
|
|
public function testPlayerStartsWithAnEmptyHand(): void |
|
23
|
|
|
{ |
|
24
|
|
|
$player = new Player('Bob'); |
|
25
|
|
|
|
|
26
|
|
|
$this->assertSame(0, $player->getHand()->count()); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Assert that the highest numbered double will be returned from the call to getHighestDouble() |
|
31
|
|
|
* |
|
32
|
|
|
* @covers \Arp\DominoGame\Value\Player::getHighestDouble |
|
33
|
|
|
*/ |
|
34
|
|
|
public function testGetHighestDoubleWillReturnHighestDouble(): void |
|
35
|
|
|
{ |
|
36
|
|
|
$player = new Player('Fred'); |
|
37
|
|
|
|
|
38
|
|
|
$highestDouble = new Domino(6, 6); |
|
39
|
|
|
|
|
40
|
|
|
$player->addToHand(new Domino(1, 2)); |
|
41
|
|
|
$player->addToHand(new Domino(3, 3)); |
|
42
|
|
|
$player->addToHand(new Domino(1, 1)); |
|
43
|
|
|
$player->addToHand($highestDouble); |
|
44
|
|
|
$player->addToHand(new Domino(1, 2)); |
|
45
|
|
|
$player->addToHand(new Domino(4, 2)); |
|
46
|
|
|
$player->addToHand(new Domino(5, 3)); |
|
47
|
|
|
$player->addToHand(new Domino(1, 2)); |
|
48
|
|
|
|
|
49
|
|
|
$result = $player->getHighestDouble(); |
|
50
|
|
|
|
|
51
|
|
|
$this->assertSame($highestDouble, $result); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|