Skip to content

Commit

Permalink
Implement the view test
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Feb 25, 2024
1 parent 06e3055 commit f282751
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
1 change: 1 addition & 0 deletions .idea/php-test-framework.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 57 additions & 1 deletion packages/framework/tests/Feature/Views/SidebarBrandViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,68 @@

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');
}
}

0 comments on commit f282751

Please sign in to comment.