@@ -145,6 +145,52 @@ public function testRouteKeysCanBeUsedForDocumentationSidebarPriorities()
145145 $ factory = new NavigationConfigTestClass ($ this ->makeCoreDataObject ('baz ' , routeKey: 'key ' , pageClass: DocumentationPage::class));
146146 $ this ->assertSame (502 , $ factory ->makePriority ());
147147 }
148+ public function testSearchForLabelInNavigationConfigForMarkdownPage ()
149+ {
150+ self ::mockConfig ([
151+ 'hyde.navigation.labels ' => [
152+ 'foo ' => 'Foo Label ' ,
153+ 'bar ' => 'Bar Label ' ,
154+ ],
155+ ]);
156+
157+ $ factory = new NavigationConfigTestClass ($ this ->makeCoreDataObject (routeKey: 'foo ' ));
158+ $ this ->assertSame ('Foo Label ' , $ factory ->makeLabel ());
159+
160+ $ factory = new NavigationConfigTestClass ($ this ->makeCoreDataObject (routeKey: 'bar ' ));
161+ $ this ->assertSame ('Bar Label ' , $ factory ->makeLabel ());
162+ }
163+
164+ public function testSearchForLabelInSidebarConfigForDocumentationPage ()
165+ {
166+ self ::mockConfig ([
167+ 'docs.sidebar.labels ' => [
168+ 'foo ' => 'Documentation Foo Label ' ,
169+ 'bar ' => 'Documentation Bar Label ' ,
170+ ],
171+ ]);
172+
173+ $ factory = new NavigationConfigTestClass ($ this ->makeCoreDataObject (routeKey: 'foo ' , pageClass: DocumentationPage::class));
174+ $ this ->assertSame ('Documentation Foo Label ' , $ factory ->makeLabel ());
175+
176+ $ factory = new NavigationConfigTestClass ($ this ->makeCoreDataObject (routeKey: 'bar ' , pageClass: DocumentationPage::class));
177+ $ this ->assertSame ('Documentation Bar Label ' , $ factory ->makeLabel ());
178+ }
179+
180+ public function testLabelFallbackToTitleIfNotDefinedInConfig ()
181+ {
182+ self ::mockConfig ([
183+ 'hyde.navigation.labels ' => [],
184+ 'docs.sidebar.labels ' => [],
185+ ]);
186+
187+ // Assuming the title fallback is correctly set in front matter or title property
188+ $ frontMatter = new FrontMatter (['title ' => 'Fallback Title ' ]);
189+ $ coreDataObject = new CoreDataObject ($ frontMatter , new Markdown (), MarkdownPage::class, '' , '' , '' , 'undefinedKey ' );
190+
191+ $ factory = new NavigationConfigTestClass ($ coreDataObject );
192+ $ this ->assertSame ('Fallback Title ' , $ factory ->makeLabel ());
193+ }
148194
149195 protected function makeCoreDataObject (string $ identifier = '' , string $ routeKey = '' , string $ pageClass = MarkdownPage::class): CoreDataObject
150196 {
@@ -163,4 +209,9 @@ public function makePriority(): int
163209 {
164210 return parent ::makePriority ();
165211 }
212+
213+ public function makeLabel (): ?string
214+ {
215+ return parent ::makeLabel ();
216+ }
166217}
0 commit comments