@@ -304,4 +304,66 @@ public function toArray(): array
304304 expect ($ array ['presets ' ][0 ])->toHaveKey ('name ' , 'Array Preset ' );
305305 expect ($ array ['presets ' ][1 ])->toHaveKey ('name ' , 'Object Preset ' );
306306 });
307+
308+ it ('has private flag that defaults to false ' , function () {
309+ $ schema = new BlockSchema ('text ' , 'text ' , TestBlock::class, 'Text Block ' );
310+
311+ expect ($ schema ->private )->toBe (false );
312+ });
313+
314+ it ('can be created with private flag set to true ' , function () {
315+ $ schema = new BlockSchema (
316+ 'text ' ,
317+ 'text ' ,
318+ TestBlock::class,
319+ 'Text Block ' ,
320+ private: true
321+ );
322+
323+ expect ($ schema ->private )->toBe (true );
324+ });
325+
326+ it ('can be created with private flag set to false explicitly ' , function () {
327+ $ schema = new BlockSchema (
328+ 'text ' ,
329+ 'text ' ,
330+ TestBlock::class,
331+ 'Text Block ' ,
332+ private: false
333+ );
334+
335+ expect ($ schema ->private )->toBe (false );
336+ });
337+
338+ it ('includes private flag in toArray output ' , function () {
339+ $ publicSchema = new BlockSchema ('text ' , 'text ' , TestBlock::class, 'Text Block ' , private: false );
340+ $ privateSchema = new BlockSchema ('text ' , 'text ' , TestBlock::class, 'Text Block ' , private: true );
341+
342+ $ publicArray = $ publicSchema ->toArray ();
343+ $ privateArray = $ privateSchema ->toArray ();
344+
345+ expect ($ publicArray )->toHaveKey ('private ' , false );
346+ expect ($ privateArray )->toHaveKey ('private ' , true );
347+ });
348+
349+ it ('includes private flag in JSON serialization ' , function () {
350+ $ schema = new BlockSchema ('text ' , 'text ' , TestBlock::class, 'Text Block ' , private: true );
351+
352+ $ json = json_encode ($ schema );
353+ $ decoded = json_decode ($ json , true );
354+
355+ expect ($ decoded )->toHaveKey ('private ' , true );
356+ });
357+
358+ it ('reads private flag from block class using fromClass ' , function () {
359+ $ schema = BlockSchema::fromClass (PrivateTestBlock::class);
360+
361+ expect ($ schema ->private )->toBe (true );
362+ });
307363});
364+
365+ // Test block with private flag set
366+ class PrivateTestBlock extends TestBlock
367+ {
368+ protected static bool $ private = true ;
369+ }
0 commit comments