for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Dice;
use PHPUnit\Framework\TestCase;
/**
* Test cases for class Dice.
*/
class DiceTest extends TestCase
{
* Construct object and verify that the object has the expected
* properties, use no arguments.
public function testCreateDice(): void
$die = new Dice();
$this->assertInstanceOf("\App\Dice\Dice", $die);
$res = $die->getAsString();
$this->assertNotEmpty($res);
}
* Construct object.
public function testCreateObject(): void
$dice = new Dice();
$this->assertInstanceOf("\App\Dice\Dice", $dice);
$res = $dice->getValue();
$exp = null;
$this->assertEquals($exp, $res);
* Create a mocked object that always returns 6.
public function testStubRollDiceLastRoll(): void
// Create a stub for the Dice class.
$stub = $this->createMock(Dice::class);
// Configure the stub.
$stub->method('roll')
->willReturn(6);
$res = $stub->roll();
$exp = 6;