Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // phpunit --configuration .phpunit.xml run test
- namespace Anax;
- use PHPUnit\Framework\TestCase;
- use My\Dice\Player;
- use My\Dice\RandomSeries;
- use My\Dice\Dice;
- /**
- * Example test class.
- */
- class DiceTest extends TestCase
- {
- /**
- * Just assert something is true.
- */
- public function testTrue()
- {
- $this->assertTrue(true);
- }
- public function testPlayer()
- {
- $foxy = new Player("Jon", "Human");
- $this->assertEquals($foxy->type, "human");
- $foxy->total = 100;
- $this->assertEquals($foxy->get_total(), 100);
- $mark = new Player("Mark", "Human");
- $mark->total = 23;
- $this->assertEquals($mark->get_total(), 23);
- }
- public function testRandomSeries()
- {
- $rand = new RandomSeries(2, 6);
- $rand_series = $rand->get_series();
- $this->assertEquals(count($rand_series), 2);
- $this->assertFalse(($rand_series == $rand->get_series()));
- $this->assertEquals(gettype($rand_series), gettype([1,2]));
- }
- public function testDice()
- {
- $game = new Dice([["Rony","Human"],["Mag","machine"],["Bob","machine"],["Dwight","machine"]]);
- $current = $game->players;
- $this->assertEquals(count($current), 4);
- $game->contest_who_is_first();
- $this->assertFalse(($current == $game->players));
- $this->assertEquals(gettype($game->printed_players()), gettype("string"));
- $this->assertEquals((boolean) $game->check_winner(), false);
- $game->players[0]->total = 100;
- $this->assertEquals((boolean) $game->check_winner(), true);
- $res = $game->moves();
- $this->assertEquals(gettype($res), gettype([1,2]));
- $game02 = new Dice([["Rony","Human"],["Mag","machine"],["Bob","machine"],["Dwight","machine"]]);
- $game02->contest_who_is_first();
- $game02->moves();
- $res = $game02->moves();
- $this->assertEquals(count($res), 4);
- $this->assertEquals(gettype($res), gettype([1,2]));
- $game02->moves(1);
- $game02->moves(1);
- $this->assertEquals($game02->pointer,0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement