-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
- Loading branch information
Showing
3 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
packages/framework/tests/Feature/Views/SidebarBrandViewTest.php
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'); | ||
} | ||
} |
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