diff --git a/example/phpunit/.tests/Dice/DiceTest.php b/example/phpunit/.tests/Dice/DiceTest.php new file mode 100644 index 0000000..7a4dffc --- /dev/null +++ b/example/phpunit/.tests/Dice/DiceTest.php @@ -0,0 +1,38 @@ +assertInstanceOf("\Mos\Dice\Dice", $die); + + $res = $die->getValue(); + $exp = null; + $this->assertEquals($exp, $res); + } + + /** + * Roll the dice and assert value is within bounds. + */ + public function testRollDice() + { + $die = new Dice(); + $res = $die->roll(); + $this->assertIsInt($res); + + $res = $die->getValue(); + $this->assertTrue($res >= 1); + $this->assertTrue($res <= 6); + } +} diff --git a/example/phpunit/.tests/Guess/GuessExceptionTest.php b/example/phpunit/.tests/Guess/GuessExceptionTest.php new file mode 100644 index 0000000..2ff7e14 --- /dev/null +++ b/example/phpunit/.tests/Guess/GuessExceptionTest.php @@ -0,0 +1,33 @@ +expectException(GuessException::class); + $guess->makeGuess(101); + } + + /** + * Verify GuessException when guess is to low. + */ + public function testGuessToLow() + { + $guess = new Guess(); + + $this->expectException(GuessException::class); + $guess->makeGuess(0); + } +}