PlayerTest.php
1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace FootyRoom\Tests\Unit\Predictor;
use FootyRoom\Tests\TestCase;
use FootyRoom\Core\CoreException;
use FootyRoom\Core\Predictor\Player;
class PlayerTest extends TestCase
{
protected const USER_ID = 1;
protected const USERNAME = 'user1';
public function setUp()
{
$this->player = new Player(self::USER_ID, self::USERNAME);
parent::setUp();
}
public function test_it_doesnt_let_you_bet_more_than_its_balance()
{
$this->expectException(CoreException::class);
$this->player->bet(Player::STARTING_POINTS + 1);
}
public function test_it_can_award_points()
{
$this->player->awardPoints(100);
$this->assertEquals(Player::STARTING_POINTS + 100, $this->player->getPoints());
}
public function test_it_deducts_points_when_betting()
{
$this->player->awardPoints(300);
$this->player->bet(100);
$this->assertEquals(Player::STARTING_POINTS + 200, $this->player->getPoints());
}
}