11<?php
22
3- /*
4- * By adding type hints and enabling strict type checking, code can become
5- * easier to read, self-documenting and reduce the number of potential bugs.
6- * By default, type declarations are non-strict, which means they will attempt
7- * to change the original type to match the type specified by the
8- * type-declaration.
9- *
10- * In other words, if you pass a string to a function requiring a float,
11- * it will attempt to convert the string value to a float.
12- *
13- * To enable strict mode, a single declare directive must be placed at the top
14- * of the file.
15- * This means that the strictness of typing is configured on a per-file basis.
16- * This directive not only affects the type declarations of parameters, but also
17- * a function's return type.
18- *
19- * For more info review the Concept on strict type checking in the PHP track
20- * <link>.
21- *
22- * To disable strict typing, comment out the directive below.
23- */
24-
253declare (strict_types=1 );
264
275use PHPUnit \Framework \TestCase ;
6+ use PHPUnit \Framework \Attributes \TestDox ;
287
298class HighScoresTest extends TestCase
309{
@@ -33,69 +12,135 @@ public static function setUpBeforeClass(): void
3312 require_once 'HighScores.php ' ;
3413 }
3514
15+ /**
16+ * uuid: 1035eb93-2208-4c22-bab8-fef06769a73c
17+ */
18+ #[TestDox('List of scores ' )]
3619 public function testListOfScores (): void
3720 {
3821 $ input = [30 , 50 , 20 , 70 ];
3922 $ this ->assertEquals ([30 , 50 , 20 , 70 ], (new HighScores ($ input ))->scores );
4023 }
4124
25+ /**
26+ * uuid: 6aa5dbf5-78fa-4375-b22c-ffaa989732d2
27+ */
28+ #[TestDox('Latest score ' )]
4229 public function testLatestScore (): void
4330 {
4431 $ input = [100 , 0 , 90 , 30 ];
4532 $ this ->assertEquals (30 , (new HighScores ($ input ))->latest );
4633 }
4734
35+ /**
36+ * uuid: b661a2e1-aebf-4f50-9139-0fb817dd12c6
37+ */
38+ #[TestDox('Personal best ' )]
4839 public function testPersonalBest (): void
4940 {
5041 $ input = [40 , 100 , 70 ];
5142 $ this ->assertEquals (100 , (new HighScores ($ input ))->personalBest );
5243 }
5344
54- public function testPersonalTopThreeFromAListOfScores (): void
45+ /**
46+ * uuid: 3d996a97-c81c-4642-9afc-80b80dc14015
47+ */
48+ #[TestDox('Top 3 scores -> Personal top three from a list of scores ' )]
49+ public function testTop3ScoresPersonalTopThreeFromAListOfScores (): void
5550 {
5651 $ input = [10 , 30 , 90 , 30 , 100 , 20 , 10 , 0 , 30 , 40 , 40 , 70 , 70 ];
5752 $ this ->assertEquals ([100 , 90 , 70 ], (new HighScores ($ input ))->personalTopThree );
5853 }
5954
60- public function testPersonalTopHighestToLowest (): void
55+ /**
56+ * uuid: 1084ecb5-3eb4-46fe-a816-e40331a4e83a
57+ */
58+ #[TestDox('Top 3 scores -> Personal top highest to lowest ' )]
59+ public function testTop3ScoresPersonalTopHighestToLowest (): void
6160 {
6261 $ input = [20 , 10 , 30 ];
6362 $ this ->assertEquals ([30 , 20 , 10 ], (new HighScores ($ input ))->personalTopThree );
6463 }
6564
66- public function testPersonalTopWhenThereIsATie (): void
65+ /**
66+ * uuid: e6465b6b-5a11-4936-bfe3-35241c4f4f16
67+ */
68+ #[TestDox('Top 3 scores -> Personal top when there is a tie ' )]
69+ public function testTop3ScoresPersonalTopWhenThereIsATie (): void
6770 {
6871 $ input = [40 , 20 , 40 , 30 ];
6972 $ this ->assertEquals ([40 , 40 , 30 ], (new HighScores ($ input ))->personalTopThree );
7073 }
7174
72- public function testPersonalTopWhenThereAreLessThan3 (): void
75+ /**
76+ * uuid: f73b02af-c8fd-41c9-91b9-c86eaa86bce2
77+ */
78+ #[TestDox('Top 3 scores -> Personal top when there are less than 3 ' )]
79+ public function testTop3ScoresPersonalTopWhenThereAreLessThan3 (): void
7380 {
7481 $ input = [30 , 70 ];
7582 $ this ->assertEquals ([70 , 30 ], (new HighScores ($ input ))->personalTopThree );
7683 }
7784
78- public function testPersonalTopWhenThereIsOnlyOne (): void
85+ /**
86+ * uuid: 16608eae-f60f-4a88-800e-aabce5df2865
87+ */
88+ #[TestDox('Top 3 scores -> Personal top when there is only one ' )]
89+ public function testTop3ScoresPersonalTopWhenThereIsOnlyOne (): void
7990 {
8091 $ input = [40 ];
8192 $ this ->assertEquals ([40 ], (new HighScores ($ input ))->personalTopThree );
8293 }
8394
84- public function testLatestScoreDoesNotChangeAfterGettingPersonalBest (): void
95+ /**
96+ * uuid: 2df075f9-fec9-4756-8f40-98c52a11504f
97+ */
98+ #[TestDox('Top 3 scores -> Latest score after personal top scores ' )]
99+ public function testTop3ScoresLatestScoreAfterPersonalTopScores (): void
100+ {
101+ $ input = [70 , 50 , 20 , 30 ];
102+ $ highScore = new HighScores ($ input );
103+
104+ $ this ->assertEquals ([70 , 50 , 30 ], $ highScore ->personalTopThree );
105+ $ this ->assertEquals (30 , $ highScore ->latest );
106+ }
107+
108+ /**
109+ * uuid: 809c4058-7eb1-4206-b01e-79238b9b71bc
110+ */
111+ #[TestDox('Top 3 scores -> Scores after personal top scores ' )]
112+ public function testTop3ScoresScoresAfterPersonalTopScores (): void
113+ {
114+ $ input = [30 , 50 , 20 , 70 ];
115+ $ highScore = new HighScores ($ input );
116+
117+ $ this ->assertEquals ([70 , 50 , 30 ], $ highScore ->personalTopThree );
118+ $ this ->assertEquals ([30 , 50 , 20 , 70 ], $ highScore ->scores );
119+ }
120+
121+ /**
122+ * uuid: ddb0efc0-9a86-4f82-bc30-21ae0bdc6418
123+ */
124+ #[TestDox('Top 3 scores -> Latest score after personal best ' )]
125+ public function testTop3ScoresLatestScoreAfterPersonalBest (): void
85126 {
86- $ input = [20 , 10 , 30 , 3 , 2 , 1 ];
127+ $ input = [20 , 70 , 15 , 25 , 30 ];
87128 $ highScore = new HighScores ($ input );
88129
89- $ this ->assertEquals (30 , $ highScore ->personalBest );
90- $ this ->assertEquals (1 , $ highScore ->latest );
130+ $ this ->assertEquals (70 , $ highScore ->personalBest );
131+ $ this ->assertEquals (30 , $ highScore ->latest );
91132 }
92133
93- public function testLatestScoreDoesNotChangeAfterGettingPersonalTopThree (): void
134+ /**
135+ * uuid: 6a0fd2d1-4cc4-46b9-a5bb-2fb667ca2364
136+ */
137+ #[TestDox('Top 3 scores -> Scores after personal best ' )]
138+ public function testTop3ScoresScoresAfterPersonalBest (): void
94139 {
95- $ input = [20 , 100 , 30 , 90 , 2 , 70 ];
140+ $ input = [20 , 70 , 15 , 25 , 30 ];
96141 $ highScore = new HighScores ($ input );
97142
98- $ this ->assertEquals ([ 100 , 90 , 70 ] , $ highScore ->personalTopThree );
99- $ this ->assertEquals (70 , $ highScore ->latest );
143+ $ this ->assertEquals (70 , $ highScore ->personalBest );
144+ $ this ->assertEquals ([ 20 , 70 , 15 , 25 , 30 ], $ highScore ->scores );
100145 }
101146}
0 commit comments