2828use Cake \ORM \Table ;
2929use Cake \TestSuite \TestCase ;
3030use PHPUnit \Framework \Attributes \CoversClass ;
31+ use ReflectionProperty ;
3132
3233/**
3334 * DocBlockHelper Test
@@ -72,7 +73,7 @@ protected function tearDown(): void
7273 }
7374
7475 /**
75- * Tests the classDescription method including annotation spacing
76+ * Tests the classDescription method
7677 *
7778 * @return void
7879 */
@@ -85,6 +86,28 @@ public function testClassDescription(): void
8586 '@foo $bar baz ' ,
8687 '@see there ' ,
8788 ];
89+ $ classDescription = $ this ->DocBlockHelper ->classDescription ($ className , $ classType , $ lines );
90+ $ expected = "/** \n * Comments Model \n * \n * Line 1 \n * @foo \$bar baz \n * @see there \n */ " ;
91+ $ this ::assertSame ($ expected , $ classDescription );
92+ }
93+
94+ /**
95+ * Tests the classDescription method with annotation spacing enabled
96+ *
97+ * @return void
98+ */
99+ public function testClassDescriptionAnnotationSpacing (): void
100+ {
101+ $ className = 'Comments ' ;
102+ $ classType = 'Model ' ;
103+ $ lines = [
104+ 'Line 1 ' ,
105+ '@foo $bar baz ' ,
106+ '@see there ' ,
107+ ];
108+ $ reflection = new ReflectionProperty ($ this ->DocBlockHelper , 'annotationSpacing ' );
109+ $ reflection ->setValue ($ this ->DocBlockHelper , true );
110+
88111 $ classDescription = $ this ->DocBlockHelper ->classDescription ($ className , $ classType , $ lines );
89112 $ expected = "/** \n * Comments Model \n * \n * Line 1 \n * @foo \$bar baz \n * \n * @see there \n */ " ;
90113 $ this ::assertSame ($ expected , $ classDescription );
@@ -103,14 +126,14 @@ public function testAssociatedEntityTypeToHintType(): void
103126 $ type = 'Foo ' ;
104127 $ association = new BelongsToMany ('Foo ' , $ sourceTable );
105128 $ assocEntityType = $ this ->DocBlockHelper ->associatedEntityTypeToHintType ($ type , $ association );
106- $ expected = 'Foo[] ' ;
129+ $ expected = 'array< Foo> ' ;
107130 $ this ->assertSame ($ expected , $ assocEntityType );
108131
109132 // Test with ONE_TO_MANY
110133 $ type = 'Bar ' ;
111134 $ association = new HasMany ('Bar ' , $ sourceTable );
112135 $ assocEntityType = $ this ->DocBlockHelper ->associatedEntityTypeToHintType ($ type , $ association );
113- $ expected = 'Bar[] ' ;
136+ $ expected = 'array< Bar> ' ;
114137 $ this ->assertSame ($ expected , $ assocEntityType );
115138
116139 // Test with ONE_TO_ONE
0 commit comments