File tree Expand file tree Collapse file tree 4 files changed +58
-8
lines changed Expand file tree Collapse file tree 4 files changed +58
-8
lines changed Original file line number Diff line number Diff line change @@ -115,11 +115,11 @@ public function render(array $tests): string
115115 $ prettifiedClassName
116116 );
117117
118- foreach ($ _tests as $ test ) {
118+ foreach ($ this -> reduce ( $ _tests) as $ prettifiedMethodName => $ outcome ) {
119119 $ buffer .= sprintf (
120120 " <li class= \"%s \">%s</li> \n" ,
121- $ test -> status ()-> isSuccess () ? ' success ' : ' defect ' ,
122- $ test -> test ()-> testDox ()-> prettifiedMethodName ()
121+ $ outcome ,
122+ $ prettifiedMethodName
123123 );
124124 }
125125
@@ -128,4 +128,30 @@ public function render(array $tests): string
128128
129129 return $ buffer . self ::PAGE_FOOTER ;
130130 }
131+
132+ /**
133+ * @psalm-return array<string, 'success'|'defect'>
134+ */
135+ private function reduce (TestResultCollection $ tests ): array
136+ {
137+ $ result = [];
138+
139+ foreach ($ tests as $ test ) {
140+ $ prettifiedMethodName = $ test ->test ()->testDox ()->prettifiedMethodName ();
141+
142+ if (!isset ($ result [$ prettifiedMethodName ])) {
143+ $ result [$ prettifiedMethodName ] = $ test ->status ()->isSuccess () ? 'success ' : 'defect ' ;
144+
145+ continue ;
146+ }
147+
148+ if ($ test ->status ()->isSuccess ()) {
149+ continue ;
150+ }
151+
152+ $ result [$ prettifiedMethodName ] = 'defect ' ;
153+ }
154+
155+ return $ result ;
156+ }
131157}
Original file line number Diff line number Diff line change @@ -26,11 +26,11 @@ public function render(array $tests): string
2626 foreach ($ tests as $ prettifiedClassName => $ _tests ) {
2727 $ buffer .= $ prettifiedClassName . "\n" ;
2828
29- foreach ($ _tests as $ test ) {
29+ foreach ($ this -> reduce ( $ _tests) as $ prettifiedMethodName => $ outcome ) {
3030 $ buffer .= sprintf (
3131 ' [%s] %s ' . "\n" ,
32- $ test -> status ()-> isSuccess () ? ' x ' : ' ' ,
33- $ test -> test ()-> testDox ()-> prettifiedMethodName ()
32+ $ outcome ,
33+ $ prettifiedMethodName
3434 );
3535 }
3636
@@ -39,4 +39,30 @@ public function render(array $tests): string
3939
4040 return $ buffer ;
4141 }
42+
43+ /**
44+ * @psalm-return array<string, 'x'|' '>
45+ */
46+ private function reduce (TestResultCollection $ tests ): array
47+ {
48+ $ result = [];
49+
50+ foreach ($ tests as $ test ) {
51+ $ prettifiedMethodName = $ test ->test ()->testDox ()->prettifiedMethodName ();
52+
53+ if (!isset ($ result [$ prettifiedMethodName ])) {
54+ $ result [$ prettifiedMethodName ] = $ test ->status ()->isSuccess () ? 'x ' : ' ' ;
55+
56+ continue ;
57+ }
58+
59+ if ($ test ->status ()->isSuccess ()) {
60+ continue ;
61+ }
62+
63+ $ result [$ prettifiedMethodName ] = ' ' ;
64+ }
65+
66+ return $ result ;
67+ }
4268}
Original file line number Diff line number Diff line change @@ -77,7 +77,6 @@ unlink($output);
7777 <ul>
7878 <li class="success">Balance is initially zero</li>
7979 <li class="success">Balance cannot become negative</li>
80- <li class="success">Balance cannot become negative</li>
8180 </ul>
8281 </body>
8382</html>
Original file line number Diff line number Diff line change @@ -22,4 +22,3 @@ unlink($output);
2222Bank Account (PHPUnit \TestFixture \BankAccount)
2323 [x] Balance is initially zero
2424 [x] Balance cannot become negative
25- [x] Balance cannot become negative
You can’t perform that action at this time.
0 commit comments