コード例 #1
0
ファイル: GameTest.php プロジェクト: alifhughes/InTheCuppa
 /**
  * When a shot results in a miss, the score sheet should be updated
  * accordingly
  * 
  * @covers ::shotMiss
  * @covers ::getScoreSheet
  * @test
  */
 public function shotMissUpdatesScore()
 {
     $john = new User(1);
     $alistair = new User(2);
     // Setup game
     $game = new Game();
     $game->addUser($john)->addUser($alistair)->start();
     // Alistair misses a shot
     $game->shotMiss($alistair);
     // Scores should be empty
     $this->assertEquals(array(1 => array('score' => 0, 'shots' => 0, 'accuracy' => 0), 2 => array('score' => 0, 'shots' => 1, 'accuracy' => 0)), $game->getScoreSheet());
 }
コード例 #2
0
ファイル: GameTest.php プロジェクト: janverton/InTheCuppa
 /**
  * @expectedException \DomainException
  * @expectedExceptionMessage Game state (2) prevents executing this method
  * 
  * @covers ::shotHit
  * @covers ::end
  * @test
  */
 public function firstToSevenEndsGame()
 {
     $john = new User(1);
     $alistair = new User(2);
     // Start a new game
     $game = new Game();
     $game->addUser($john)->addUser($alistair)->start();
     // 7 shots hit wins you the game
     $game->shotHit($john)->shotHit($john)->shotHit($john)->shotHit($john)->shotHit($john)->shotHit($john)->shotHit($john);
     // Try one more shot, which fails because the game has been ended
     $game->shotHit($john);
 }