Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions exercises/practice/robot-name/RobotNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

declare(strict_types=1);

use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;

class RobotNameTest extends TestCase
Expand All @@ -11,12 +12,14 @@ public static function setUpBeforeClass(): void
require_once 'RobotName.php';
}

#[TestDox('Has name')]
public function testHasName(): void
{
$robot = new Robot();
$this->assertMatchesRegularExpression('/^[a-z]{2}\d{3}$/i', $robot->getName());
}

#[TestDox('Name sticks')]
public function testNameSticks(): void
{
$robot = new Robot();
Expand All @@ -25,6 +28,7 @@ public function testNameSticks(): void
$this->assertSame($robot->getName(), $old);
}

#[TestDox('Different robots have different names')]
public function testDifferentRobotsHaveDifferentNames(): void
{
$robot = new Robot();
Expand All @@ -35,6 +39,7 @@ public function testDifferentRobotsHaveDifferentNames(): void
unset($other_bot);
}

#[TestDox('Reset name')]
public function testResetName(): void
{
$robot = new Robot();
Expand All @@ -49,6 +54,7 @@ public function testResetName(): void
$this->assertMatchesRegularExpression('/\w{2}\d{3}/', $name2);
}

#[TestDox("Names aren't recycled")]
public function testNamesArentRecycled(): void
{
$robot = new Robot();
Expand All @@ -63,6 +69,7 @@ public function testNamesArentRecycled(): void
}

// This test is optional.
#[TestDox('Name uniqueness many robots')]
public function testNameUniquenessManyRobots(): void
{
$robot = new Robot();
Expand Down
Loading