public function testTryLetter() { $game = new Game(new Word('php')); $this->assertFalse($game->tryLetter('3')); $this->assertEquals(1, $game->getAttempts()); $this->assertFalse($game->tryLetter('e')); $this->assertEquals(2, $game->getAttempts()); $this->assertTrue($game->tryLetter('p')); $this->assertEquals(2, $game->getAttempts()); $this->assertFalse($game->tryLetter('p')); $this->assertEquals(3, $game->getAttempts()); }
public function testIsHangedWithLetterTrial() { $game = new Game(new Word('filament'), 0, 5); $game->tryLetter('g'); $this->assertFalse($game->isHanged()); $game->tryLetter('h'); $this->assertFalse($game->isHanged()); $game->tryLetter('j'); $this->assertFalse($game->isHanged()); $game->tryLetter('k'); $this->assertFalse($game->isHanged()); $game->tryLetter('y'); $this->assertTrue($game->isHanged()); }