My attempts at exercism.org
1<?php
2
3declare(strict_types=1);
4
5use PHPUnit\Framework\TestCase;
6use PHPUnit\Framework\Attributes\TestDox;
7
8class ReverseStringTest extends TestCase
9{
10 public static function setUpBeforeClass(): void
11 {
12 require_once 'ReverseString.php';
13 }
14
15 /**
16 * uuid c3b7d806-dced-49ee-8543-933fd1719b1c
17 */
18 #[TestDox('an empty string')]
19 public function testEmptyString(): void
20 {
21 $this->assertEquals("", reverseString(""));
22 }
23
24 /** uuid 01ebf55b-bebb-414e-9dec-06f7bb0bee3c */
25 #[TestDox('a word')]
26 public function testWord(): void
27 {
28 $this->assertEquals("tobor", reverseString("robot"));
29 }
30
31 /**
32 * uuid 0f7c07e4-efd1-4aaa-a07a-90b49ce0b746
33 */
34 #[TestDox('a capitalized word')]
35 public function testCapitalizedWord(): void
36 {
37 $this->assertEquals("nemaR", reverseString("Ramen"));
38 }
39
40 /**
41 * uuid 71854b9c-f200-4469-9f5c-1e8e5eff5614
42 */
43 #[TestDox('a sentence with punctuation')]
44 public function testSentenceWithPunctuation(): void
45 {
46 $this->assertEquals("!yrgnuh m'I", reverseString("I'm hungry!"));
47 }
48
49 /**
50 * uuid 1f8ed2f3-56f3-459b-8f3e-6d8d654a1f6c
51 */
52 #[TestDox('a palindrome')]
53 public function testPalindrome(): void
54 {
55 $this->assertEquals("racecar", reverseString("racecar"));
56 }
57
58 /**
59 * uuid b9e7dec1-c6df-40bd-9fa3-cd7ded010c4c
60 */
61 #[TestDox('an even-sized word')]
62 public function testEvenSizedWord(): void
63 {
64 $this->assertEquals("reward", reverseString("drawer"));
65 }
66}