Advertisement
repente

Untitled

Jun 3rd, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. <?php
  2. // phpunit --configuration .phpunit.xml run test
  3. namespace Anax;
  4.  
  5. use PHPUnit\Framework\TestCase;
  6. use My\Dice\Player;
  7. use My\Dice\RandomSeries;
  8. use My\Dice\Dice;
  9.  
  10. /**
  11. * Example test class.
  12. */
  13. class DiceTest extends TestCase
  14. {
  15. /**
  16. * Just assert something is true.
  17. */
  18. public function testTrue()
  19. {
  20. $this->assertTrue(true);
  21. }
  22.  
  23. public function testPlayer()
  24. {
  25. $foxy = new Player("Jon", "Human");
  26. $this->assertEquals($foxy->type, "human");
  27.  
  28. $foxy->total = 100;
  29. $this->assertEquals($foxy->get_total(), 100);
  30.  
  31. $mark = new Player("Mark", "Human");
  32. $mark->total = 23;
  33. $this->assertEquals($mark->get_total(), 23);
  34. }
  35.  
  36. public function testRandomSeries()
  37. {
  38. $rand = new RandomSeries(2, 6);
  39. $rand_series = $rand->get_series();
  40. $this->assertEquals(count($rand_series), 2);
  41. $this->assertFalse(($rand_series == $rand->get_series()));
  42. $this->assertEquals(gettype($rand_series), gettype([1,2]));
  43.  
  44. }
  45.  
  46. public function testDice()
  47. {
  48. $game = new Dice([["Rony","Human"],["Mag","machine"],["Bob","machine"],["Dwight","machine"]]);
  49. $current = $game->players;
  50. $this->assertEquals(count($current), 4);
  51. $game->contest_who_is_first();
  52. $this->assertFalse(($current == $game->players));
  53. $this->assertEquals(gettype($game->printed_players()), gettype("string"));
  54. $this->assertEquals((boolean) $game->check_winner(), false);
  55. $game->players[0]->total = 100;
  56. $this->assertEquals((boolean) $game->check_winner(), true);
  57.  
  58. $res = $game->moves();
  59. $this->assertEquals(gettype($res), gettype([1,2]));
  60.  
  61. $game02 = new Dice([["Rony","Human"],["Mag","machine"],["Bob","machine"],["Dwight","machine"]]);
  62. $game02->contest_who_is_first();
  63.  
  64. $game02->moves();
  65. $res = $game02->moves();
  66. $this->assertEquals(count($res), 4);
  67. $this->assertEquals(gettype($res), gettype([1,2]));
  68. $game02->moves(1);
  69. $game02->moves(1);
  70. $this->assertEquals($game02->pointer,0);
  71.  
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement