88use PHPForge \Debug \Exception \PanelViewMessage ;
99use PHPForge \Debug \{PanelView , Tone };
1010use PHPForge \Debug \Presenter \{
11- CardBlock ,
11+ CardEntry ,
12+ CardsBlock ,
1213 ColumnEntry ,
1314 FactEntry ,
1415 FactsBlock ,
@@ -45,38 +46,64 @@ public function testCardKeepsItsMetaAndTitledColumnsInDeclarationOrder(): void
4546
4647 $ files = PanelView::create ()->files (PanelView::file ('.css ' , 'site.css ' , Tone::INFO ));
4748 $ wiring = PanelView::create ()->facts (PanelView::fact ('SOURCE ' , '@app/assets ' ));
48- $ view = PanelView::create ()
49- ->card (
49+
50+ self ::assertEquals (
51+ new CardEntry (
52+ 'app-asset ' ,
53+ 'asset ' ,
54+ 'AppAsset ' ,
55+ 'App \\Asset \\' ,
56+ [$ badge , new TextInline ('1 js ' , TextStyle::PLAIN )],
57+ [new ColumnEntry ('FILES ' , $ files ), new ColumnEntry ('WIRING ' , $ wiring )],
58+ ),
59+ PanelView::card (
5060 'app-asset ' ,
5161 'asset ' ,
5262 'AppAsset ' ,
5363 'App \\Asset \\' ,
5464 [$ badge , '1 js ' ],
5565 PanelView::column ('FILES ' , $ files ),
5666 PanelView::column ('WIRING ' , $ wiring ),
57- );
67+ ),
68+ 'A card keeps its meta and columns in declaration order. ' ,
69+ );
70+
71+ $ columns = ['files ' => PanelView::column ('FILES ' , $ files ), 'wiring ' => PanelView::column ('WIRING ' , $ wiring )];
5872
5973 self ::assertEquals (
60- [
61- new CardBlock (
62- 'app-asset ' ,
63- 'asset ' ,
64- 'AppAsset ' ,
65- 'App \\Asset \\' ,
66- [$ badge , new TextInline ('1 js ' , TextStyle::PLAIN )],
67- [new ColumnEntry ('FILES ' , $ files ), new ColumnEntry ('WIRING ' , $ wiring )],
68- ),
69- ],
70- $ view ->blocks (),
71- 'A card keeps its meta and columns in declaration order. ' ,
74+ [new ColumnEntry ('FILES ' , $ files ), new ColumnEntry ('WIRING ' , $ wiring )],
75+ PanelView::card ('app-asset ' , 'asset ' , 'AppAsset ' , '' , [], ...$ columns )->columns ,
76+ 'String keys must not reach the column list. ' ,
77+ );
78+ }
79+
80+ public function testCardsKeepTheirEntriesInDeclarationOrder (): void
81+ {
82+ $ app = PanelView::card ('app-asset ' , 'asset ' , 'AppAsset ' , '' , []);
83+ $ yii = PanelView::card ('yii-asset ' , 'asset ' , 'YiiAsset ' , '' , []);
84+
85+ $ cards = ['app ' => $ app , 'yii ' => $ yii ];
86+
87+ self ::assertEquals (
88+ [new CardsBlock ([$ app , $ yii ]), new CardsBlock ([])],
89+ PanelView::create ()
90+ ->cards ($ app , $ yii )
91+ ->cards ()
92+ ->blocks (),
93+ 'A card set keeps its cards in declaration order. ' ,
94+ );
95+ self ::assertEquals (
96+ [new CardsBlock ([$ app , $ yii ])],
97+ PanelView::create ()->cards (...$ cards )->blocks (),
98+ 'String keys must not reach the card list. ' ,
7299 );
73100 }
74101
75102 public function testCardWithoutMetaOrColumnsCarriesEmptyLists (): void
76103 {
77104 self ::assertEquals (
78- [ new CardBlock ('' , '' , 'AppAsset ' , '' , [], [])] ,
79- PanelView::create ()-> card ('' , '' , 'AppAsset ' , '' , [])-> blocks ( ),
105+ new CardEntry ('' , '' , 'AppAsset ' , '' , [], []),
106+ PanelView::card ('' , '' , 'AppAsset ' , '' , []),
80107 'An unadorned card keeps its optional parts empty. ' ,
81108 );
82109 }
@@ -90,6 +117,14 @@ public function testFactsKeepTheirLabelAndValuePairs(): void
90117 ->blocks (),
91118 'A fact strip keeps every pair in declaration order. ' ,
92119 );
120+
121+ $ facts = ['charset ' => PanelView::fact ('Charset ' , 'UTF-8 ' )];
122+
123+ self ::assertEquals (
124+ [new FactsBlock ([new FactEntry ('Charset ' , 'UTF-8 ' )])],
125+ PanelView::create ()->facts (...$ facts )->blocks (),
126+ 'String keys must not reach the fact list. ' ,
127+ );
93128 }
94129
95130 public function testFilesKeepTheirTypeToneAndOrder (): void
@@ -118,6 +153,14 @@ public function testFilesKeepTheirTypeToneAndOrder(): void
118153 ->blocks (),
119154 'A file list keeps every entry in declaration order. ' ,
120155 );
156+
157+ $ files = ['site ' => PanelView::file ('.css ' , 'site.css ' , Tone::INFO )];
158+
159+ self ::assertEquals (
160+ [new FilesBlock ([new FileEntry ('.css ' , 'site.css ' , Tone::INFO )])],
161+ PanelView::create ()->files (...$ files )->blocks (),
162+ 'String keys must not reach the file list. ' ,
163+ );
121164 }
122165
123166 public function testLinksKeepTheirLabelAndOrder (): void
@@ -143,6 +186,14 @@ public function testLinksKeepTheirLabelAndOrder(): void
143186 ->blocks (),
144187 'A link strip keeps every target in declaration order. ' ,
145188 );
189+
190+ $ links = ['yii ' => PanelView::link ('YiiAsset ' , '#yii-asset ' )];
191+
192+ self ::assertEquals (
193+ [new LinksBlock ('Depends on 1 ' , [new LinkInline ('YiiAsset ' , '#yii-asset ' , false )])],
194+ PanelView::create ()->links ('Depends on 1 ' , ...$ links )->blocks (),
195+ 'String keys must not reach the link list. ' ,
196+ );
146197 }
147198
148199 public function testManifestGroupsPackagesUnderOneVendorLabel (): void
@@ -163,6 +214,14 @@ public function testManifestGroupsPackagesUnderOneVendorLabel(): void
163214 $ view ->blocks (),
164215 'A manifest keeps its packages in declaration order under the vendor label. ' ,
165216 );
217+
218+ $ packages = ['aliases ' => PanelView::package ('aliases ' , 'v3.1.1 ' )];
219+
220+ self ::assertEquals (
221+ [new ManifestBlock ('yiisoft/ ' , [new PackageEntry ('aliases ' , 'v3.1.1 ' )])],
222+ PanelView::create ()->manifest ('yiisoft/ ' , ...$ packages )->blocks (),
223+ 'String keys must not reach the package list. ' ,
224+ );
166225 }
167226
168227 public function testPillsKeepTheirStateAndOrder (): void
@@ -177,6 +236,14 @@ public function testPillsKeepTheirStateAndOrder(): void
177236 $ view ->blocks (),
178237 'A pill strip keeps every subject with its own state. ' ,
179238 );
239+
240+ $ pills = ['apcu ' => PanelView::pill ('APCu ' , 'on ' , true )];
241+
242+ self ::assertEquals (
243+ [new PillsBlock ([new PillEntry ('APCu ' , 'on ' , true )])],
244+ PanelView::create ()->pills (...$ pills )->blocks (),
245+ 'String keys must not reach the pill list. ' ,
246+ );
180247 }
181248
182249 public function testReadoutCaptionIsOptional (): void
@@ -193,6 +260,14 @@ public function testReadoutCaptionIsOptional(): void
193260 ->blocks (),
194261 'A readout row carries its cards in declaration order. ' ,
195262 );
263+
264+ $ readouts = ['php ' => PanelView::readout ('PHP ' , '8.5.9 ' , 'runtime ' )];
265+
266+ self ::assertEquals (
267+ [new ReadoutsBlock ([new ReadoutEntry ('PHP ' , '8.5.9 ' , 'runtime ' )])],
268+ PanelView::create ()->readouts (...$ readouts )->blocks (),
269+ 'String keys must not reach the readout list. ' ,
270+ );
196271 }
197272
198273 public function testSectionCountIsOptionalAndWrapsItsOwnBlocks (): void
@@ -248,6 +323,6 @@ public function testThrowInvalidArgumentExceptionForCardMetaNoInlineFactoryBuilt
248323 PanelViewMessage::INLINE_CONTENT_INVALID ->getMessage ('stdClass ' ),
249324 );
250325
251- PanelView::create ()-> card ('' , '' , 'AppAsset ' , '' , [new stdClass ()]);
326+ PanelView::card ('' , '' , 'AppAsset ' , '' , [new stdClass ()]);
252327 }
253328}
0 commit comments