-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Mos\Dice; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Test cases for class Dice. | ||
*/ | ||
class DiceTest extends TestCase | ||
{ | ||
/** | ||
* Construct object and verify it it a Dice object. | ||
*/ | ||
public function testCreateObject() | ||
{ | ||
$die = new Dice(); | ||
$this->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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Mos\Guess; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Test cases for class Guess. | ||
*/ | ||
class GuessExceptionTest extends TestCase | ||
{ | ||
/** | ||
* Verify GuessException when guess is to high. | ||
*/ | ||
public function testGuessToHigh() | ||
{ | ||
$guess = new Guess(); | ||
|
||
$this->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); | ||
} | ||
} |