1616 */
1717namespace Bake \Test \TestCase \View \Helper ;
1818
19+ use Bake \Test \App \Model \Enum \BakeUserStatus ;
1920use Bake \View \BakeView ;
2021use Bake \View \Helper \BakeHelper ;
22+ use Cake \Database \Type \EnumType ;
2123use Cake \Http \Response ;
2224use Cake \Http \ServerRequest as Request ;
2325use Cake \TestSuite \TestCase ;
@@ -40,6 +42,7 @@ class BakeHelperTest extends TestCase
4042 'plugin.Bake.BakeComments ' ,
4143 'plugin.Bake.BakeArticlesBakeTags ' ,
4244 'plugin.Bake.BakeTags ' ,
45+ 'plugin.Bake.Users ' ,
4346 ];
4447
4548 /**
@@ -89,12 +92,12 @@ public function testAliasExtractorFilteredHasMany()
8992 'className ' => '\Bake\Test\App\Model\Table\ArticlesTable ' ,
9093 ]);
9194 $ this ->BakeHelper = $ this ->getMockBuilder ('Bake\View\Helper\BakeHelper ' )
92- ->disableOriginalConstructor ()
93- ->onlyMethods (['_filterHasManyAssociationsAliases ' ])
94- ->getMock ();
95+ ->disableOriginalConstructor ()
96+ ->onlyMethods (['_filterHasManyAssociationsAliases ' ])
97+ ->getMock ();
9598 $ this ->BakeHelper ->expects ($ this ->once ())
96- ->method ('_filterHasManyAssociationsAliases ' )
97- ->with ($ table , ['ArticlesTags ' ]);
99+ ->method ('_filterHasManyAssociationsAliases ' )
100+ ->with ($ table , ['ArticlesTags ' ]);
98101 $ result = $ this ->BakeHelper ->aliasExtractor ($ table , 'HasMany ' );
99102 $ this ->assertEmpty ($ result );
100103 }
@@ -107,7 +110,7 @@ public function testAliasExtractorFilteredHasMany()
107110 public function testAliasExtractorBelongsTo ()
108111 {
109112 $ table = $ this ->getTableLocator ()->get ('Articles ' , [
110- 'className ' => '\Bake\Test\App\Model\Table\ArticlesTable ' ,
113+ 'className ' => '\Bake\Test\App\Model\Table\ArticlesTable ' ,
111114 ]);
112115 $ result = $ this ->BakeHelper ->aliasExtractor ($ table , 'BelongsTo ' );
113116 $ expected = ['authors ' ];
@@ -122,7 +125,7 @@ public function testAliasExtractorBelongsTo()
122125 public function testAliasExtractorBelongsToMany ()
123126 {
124127 $ table = $ this ->getTableLocator ()->get ('Articles ' , [
125- 'className ' => '\Bake\Test\App\Model\Table\ArticlesTable ' ,
128+ 'className ' => '\Bake\Test\App\Model\Table\ArticlesTable ' ,
126129 ]);
127130 $ result = $ this ->BakeHelper ->aliasExtractor ($ table , 'BelongsToMany ' );
128131 $ expected = ['tags ' ];
@@ -185,4 +188,15 @@ public function testHasPlugin(): void
185188 $ this ->assertTrue ($ this ->BakeHelper ->hasPlugin ('Bake ' ));
186189 $ this ->assertFalse ($ this ->BakeHelper ->hasPlugin ('DebugKit ' ));
187190 }
191+
192+ public function testEnumSupportsLabel (): void
193+ {
194+ $ table = $ this ->fetchTable ('BakeUsers ' );
195+ $ schema = $ table ->getSchema ();
196+ $ schema ->setColumnType ('status ' , EnumType::from (BakeUserStatus::class));
197+
198+ $ this ->assertTrue ($ this ->BakeHelper ->enumSupportsLabel ('status ' , $ schema ));
199+ $ this ->assertFalse ($ this ->BakeHelper ->enumSupportsLabel ('username ' , $ schema ));
200+ $ this ->assertFalse ($ this ->BakeHelper ->enumSupportsLabel ('does_not_exist ' , $ schema ));
201+ }
188202}
0 commit comments