Skip to content

Commit

Permalink
Merge pull request #1704 from hydephp/merge-pull-1703-into-2x
Browse files Browse the repository at this point in the history
[2.x] Honour front matter navigation groups set in front matter regardless of subdirectory setting
  • Loading branch information
caendesilva authored Apr 30, 2024
2 parents 3833e22 + 3ed0453 commit d6295f5
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/framework/tests/Unit/NavigationDataFactoryUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,36 @@ public function testSearchForHiddenInConfigsSelectsCorrectConfigurationBasedOnPa
$this->assertFalse($factory->makeHidden());
}

public function testMakeGroupUsesFrontMatterGroupIfSet()
{
$frontMatter = new FrontMatter(['navigation.group' => 'Test Group']);
$coreDataObject = new CoreDataObject($frontMatter, new Markdown(), MarkdownPage::class, 'test.md', '', '', '');
$factory = new NavigationConfigTestClass($coreDataObject);

$this->assertSame('Test Group', $factory->makeGroup());
}

public function testMakeGroupUsesFrontMatterGroupIfSetRegardlessOfSubdirectoryConfiguration()
{
self::mockConfig(['hyde.navigation.subdirectories' => 'hidden']);

$frontMatter = new FrontMatter(['navigation.group' => 'Test Group']);
$coreDataObject = new CoreDataObject($frontMatter, new Markdown(), MarkdownPage::class, 'test.md', '', '', '');
$factory = new NavigationConfigTestClass($coreDataObject);

$this->assertSame('Test Group', $factory->makeGroup());
}

public function testMakeGroupDefaultsToNullIfFrontMatterGroupNotSetAndSubdirectoriesNotUsed()
{
self::mockConfig(['hyde.navigation.subdirectories' => 'hidden']);

$coreDataObject = new CoreDataObject(new FrontMatter(), new Markdown(), MarkdownPage::class, 'test.md', '', '', '');
$factory = new NavigationConfigTestClass($coreDataObject);

$this->assertNull($factory->makeGroup());
}

protected function makeCoreDataObject(string $identifier = '', string $routeKey = '', string $pageClass = MarkdownPage::class): CoreDataObject
{
return new CoreDataObject(new FrontMatter(), new Markdown(), $pageClass, $identifier, '', '', $routeKey);
Expand Down Expand Up @@ -264,4 +294,9 @@ public function makeHidden(): bool
{
return parent::makeHidden();
}

public function makeGroup(): ?string
{
return parent::makeGroup();
}
}

0 comments on commit d6295f5

Please sign in to comment.