Skip to content

Commit

Permalink
Merge pull request #1589 from hydephp/improved-view-testing
Browse files Browse the repository at this point in the history
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.
71 changes: 71 additions & 0 deletions tests/Feature/Views/SidebarBrandViewTest.php
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');
}
}

0 comments on commit 3e2585d

Please sign in to comment.