|
15 | 15 | FactsBlock, |
16 | 16 | FileEntry, |
17 | 17 | FilesBlock, |
| 18 | + HeroBlock, |
18 | 19 | LinkInline, |
19 | 20 | LinksBlock, |
20 | 21 | ManifestBlock, |
|
34 | 35 | use stdClass; |
35 | 36 |
|
36 | 37 | /** |
37 | | - * Unit tests for the {@see PanelView} composite blocks describing cards, stats, files, links, facts, readouts, pills, |
38 | | - * manifests, and sections. |
| 38 | + * Unit tests for the {@see PanelView} composite blocks describing heroes, cards, stats, files, links, facts, readouts, |
| 39 | + * pills, manifests, and sections. |
39 | 40 | */ |
40 | 41 | #[Group('panel-view')] |
41 | 42 | final class CompositeBlockTest extends TestCase |
@@ -163,6 +164,32 @@ public function testFilesKeepTheirTypeToneAndOrder(): void |
163 | 164 | ); |
164 | 165 | } |
165 | 166 |
|
| 167 | + public function testHeroKeepsItsIdentityStatusAndMetricOrder(): void |
| 168 | + { |
| 169 | + $status = PanelView::badge('Active', Tone::SUCCESS); |
| 170 | + |
| 171 | + $metrics = ['id' => PanelView::fact('User ID', '1'), 'roles' => PanelView::fact('Roles', 'admin')]; |
| 172 | + |
| 173 | + self::assertEquals( |
| 174 | + [ |
| 175 | + new HeroBlock( |
| 176 | + 'AD', |
| 177 | + 'admin', |
| 178 | + 'admin@example.com', |
| 179 | + $status, |
| 180 | + [new FactEntry('User ID', '1'), new FactEntry('Roles', 'admin')], |
| 181 | + ), |
| 182 | + ], |
| 183 | + PanelView::create()->hero('AD', 'admin', 'admin@example.com', $status, ...$metrics)->blocks(), |
| 184 | + 'Metrics must keep declaration order without their string keys.', |
| 185 | + ); |
| 186 | + self::assertEquals( |
| 187 | + [new HeroBlock('', 'admin', '', null, [])], |
| 188 | + PanelView::create()->hero('', 'admin', '', null)->blocks(), |
| 189 | + 'A neutral header keeps its optional parts empty.', |
| 190 | + ); |
| 191 | + } |
| 192 | + |
166 | 193 | public function testLinksKeepTheirLabelAndOrder(): void |
167 | 194 | { |
168 | 195 | self::assertEquals( |
|
0 commit comments