PlayerTest.php 1014 Bytes
<?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());
    }
}