Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Brain-WP/Hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
gmazzap committed Feb 24, 2022
2 parents b7e7be7 + 8e7dc5d commit 78f113e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/QueryTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function findTemplate(?\WP_Query $query = null, bool $filters = true): st
$found = '';
while ($types && !$found) {
$type = array_shift($types);
$found = $this->finder->findFirst($leaves[$type], $type);
$found = $this->finder->findFirst($leaves[$type], (string) $type);
$filters and $found = $this->applyFilter("{$type}_template", $found, $query);
}

Expand Down
18 changes: 18 additions & 0 deletions tests/src/Unit/QueryTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,24 @@ public function find(string $template, string $type): string
unset($wp_query, $wp_the_query);
}

/**
* @test
*/
public function testFindTemplateWhen404(): void
{
$wpQuery = new \WP_Query([
'is_404' => true,
]);

$finder = \Mockery::mock(TemplateFinder::class);
$finder->expects('findFirst')->andReturn('foo');

$loader = new QueryTemplate($finder);
$loaded = $loader->findTemplate($wpQuery);

static::assertSame('foo', $loaded);
}

/**
* @test
*/
Expand Down

0 comments on commit 78f113e

Please sign in to comment.