Skip to content

Commit

Permalink
Return chainable facade instance
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Sep 8, 2024
1 parent e13b438 commit 2a01eea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 2 additions & 5 deletions packages/framework/tests/Unit/Facades/RouteFacadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Hyde\Pages\BladePage;
use Hyde\Pages\MarkdownPage;
use Hyde\Pages\MarkdownPost;
use Hyde\Support\Facades\Render;
use Hyde\Support\Models\Route;
use Hyde\Testing\UnitTestCase;

Expand Down Expand Up @@ -60,16 +59,14 @@ public function testCurrentReturnsCurrentRoute()
{
$route = new Route(new MarkdownPage('foo'));

self::mockRender();
Render::shouldReceive('getRoute')->andReturn($route);
self::mockRender()->shouldReceive('getRoute')->andReturn($route);

$this->assertSame($route, Routes::current());
}

public function testCurrentReturnsNullIfRouteIsNotFound()
{
self::mockRender();
Render::shouldReceive('getRoute')->andReturn(null);
self::mockRender()->shouldReceive('getRoute')->andReturn(null);

$this->assertNull(Routes::current());
}
Expand Down
7 changes: 4 additions & 3 deletions packages/testing/src/UnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,16 @@ protected static function resetKernel(): void
HydeKernel::setInstance(new HydeKernel());
}

protected static function mockRender(): void
protected static function mockRender(): Render
{
Render::swap(new RenderData());

return new Render();
}

protected static function mockCurrentRouteKey(?string $routeKey = null): void
{
Render::swap(new RenderData());
Render::shouldReceive('getRouteKey')->andReturn($routeKey);
self::mockRender()->shouldReceive('getRouteKey')->andReturn($routeKey);
}

protected static function mockConfig(array $items = []): void
Expand Down

0 comments on commit 2a01eea

Please sign in to comment.