PlayerRoundTest.php 1.3 KB
<?php

namespace FootyRoom\Tests\Unit\Predictor;

use DateTime;
use FootyRoom\Tests\TestCase;
use FootyRoom\Core\CoreException;
use FootyRoom\Core\Predictor\Player;
use FootyRoom\Core\Predictor\RoundId;
use FootyRoom\Core\Predictor\PlayerRound;

class PlayerRoundTest extends TestCase
{
    protected const USER_ID = 1;
    protected const USERNAME = 'user1';
    protected const ROUND_ID = '2018-W43';

    public function setUp()
    {
        $this->player = new Player(self::USER_ID, self::USERNAME);
        $this->playerRound = new PlayerRound($this->player, new RoundId(new DateTime(self::ROUND_ID)));

        parent::setUp();
    }

    public function test_it_returns_userId()
    {
        $this->assertEquals(self::USER_ID, $this->playerRound->getUserId());
    }

    public function test_it_doesnt_let_you_bet_more_than_rounds_limit()
    {
        $this->playerRound->bet(2000);
        $this->expectException(CoreException::class);
        $this->playerRound->bet(1);
    }

    public function test_it_records_total_bet()
    {
        $this->playerRound->bet(1000);
        $this->assertEquals(1000, $this->playerRound->getStake());
    }

    public function test_it_records_locked_amount()
    {
        $this->playerRound->bet(1000);
        $this->assertEquals(1000, $this->playerRound->getLocked());
    }
}