-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1589 from hydephp/improved-view-testing
Improve and add more view tests hydephp/develop@843f461
- Loading branch information
github-actions
committed
Feb 25, 2024
1 parent
59d0329
commit 3e2585d
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Hyde\Framework\Testing\Feature\Views; | ||
|
||
use Hyde\Hyde; | ||
use Hyde\Testing\TestCase; | ||
use Hyde\Foundation\HydeKernel; | ||
use Hyde\Testing\TestsBladeViews; | ||
use Hyde\Pages\DocumentationPage; | ||
|
||
class SidebarBrandViewTest extends TestCase | ||
{ | ||
use TestsBladeViews; | ||
|
||
public function testSidebarBrandView() | ||
{ | ||
$view = $this->test(view('hyde::components.docs.sidebar-brand')); | ||
|
||
$view->assertSee('HydePHP Docs'); | ||
$view->assertSee('theme-toggle-button'); | ||
$view->assertDontSee('href'); | ||
} | ||
|
||
public function testSidebarBrandViewWithHomeRoute() | ||
{ | ||
Hyde::routes()->addRoute((new DocumentationPage('index'))->getRoute()); | ||
|
||
$view = $this->test(view('hyde::components.docs.sidebar-brand')); | ||
|
||
$view->assertSee('HydePHP Docs'); | ||
$view->assertSee('theme-toggle-button'); | ||
$view->assertSeeHtml('<a href="docs/index.html">HydePHP Docs</a>', true); | ||
} | ||
|
||
public function testSidebarBrandViewWithDefaultHeaderText() | ||
{ | ||
config(['docs.sidebar' => []]); | ||
|
||
$view = $this->test(view('hyde::components.docs.sidebar-brand')); | ||
|
||
$view->assertSee('Documentation'); | ||
$view->assertDontSee('HydePHP Docs'); | ||
} | ||
|
||
public function testSidebarBrandViewWithDefaultHeaderTextAndHomeRoute() | ||
{ | ||
Hyde::routes()->addRoute((new DocumentationPage('index'))->getRoute()); | ||
|
||
config(['docs.sidebar' => []]); | ||
|
||
$view = $this->test(view('hyde::components.docs.sidebar-brand')); | ||
|
||
$view->assertSee('Documentation'); | ||
$view->assertSeeHtml('<a href="docs/index.html">Documentation</a>', true); | ||
$view->assertDontSee('HydePHP Docs'); | ||
} | ||
|
||
public function testSidebarBrandViewWithoutDarkmodeFeature() | ||
{ | ||
$mock = $this->mock(HydeKernel::class)->makePartial(); | ||
$mock->shouldReceive('hasFeature')->with('darkmode')->andReturn(false); | ||
HydeKernel::setInstance($mock); | ||
|
||
$view = $this->test(view('hyde::components.docs.sidebar-brand')); | ||
|
||
$view->assertSee('HydePHP Docs'); | ||
$view->assertDontSee('theme-toggle-button'); | ||
} | ||
} |