|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Hyde\Framework\Testing\Feature\Views; |
| 6 | + |
| 7 | +use Hyde\Hyde; |
| 8 | +use Hyde\Testing\TestCase; |
| 9 | +use Hyde\Foundation\HydeKernel; |
| 10 | +use Hyde\Testing\TestsBladeViews; |
| 11 | +use Hyde\Pages\DocumentationPage; |
| 12 | + |
| 13 | +class SidebarBrandViewTest extends TestCase |
| 14 | +{ |
| 15 | + use TestsBladeViews; |
| 16 | + |
| 17 | + public function testSidebarBrandView() |
| 18 | + { |
| 19 | + $view = $this->test(view('hyde::components.docs.sidebar-brand')); |
| 20 | + |
| 21 | + $view->assertSee('HydePHP Docs'); |
| 22 | + $view->assertSee('theme-toggle-button'); |
| 23 | + $view->assertDontSee('href'); |
| 24 | + } |
| 25 | + |
| 26 | + public function testSidebarBrandViewWithHomeRoute() |
| 27 | + { |
| 28 | + Hyde::routes()->addRoute((new DocumentationPage('index'))->getRoute()); |
| 29 | + |
| 30 | + $view = $this->test(view('hyde::components.docs.sidebar-brand')); |
| 31 | + |
| 32 | + $view->assertSee('HydePHP Docs'); |
| 33 | + $view->assertSee('theme-toggle-button'); |
| 34 | + $view->assertSeeHtml('<a href="docs/index.html">HydePHP Docs</a>', true); |
| 35 | + } |
| 36 | + |
| 37 | + public function testSidebarBrandViewWithDefaultHeaderText() |
| 38 | + { |
| 39 | + config(['docs.sidebar' => []]); |
| 40 | + |
| 41 | + $view = $this->test(view('hyde::components.docs.sidebar-brand')); |
| 42 | + |
| 43 | + $view->assertSee('Documentation'); |
| 44 | + $view->assertDontSee('HydePHP Docs'); |
| 45 | + } |
| 46 | + |
| 47 | + public function testSidebarBrandViewWithDefaultHeaderTextAndHomeRoute() |
| 48 | + { |
| 49 | + Hyde::routes()->addRoute((new DocumentationPage('index'))->getRoute()); |
| 50 | + |
| 51 | + config(['docs.sidebar' => []]); |
| 52 | + |
| 53 | + $view = $this->test(view('hyde::components.docs.sidebar-brand')); |
| 54 | + |
| 55 | + $view->assertSee('Documentation'); |
| 56 | + $view->assertSeeHtml('<a href="docs/index.html">Documentation</a>', true); |
| 57 | + $view->assertDontSee('HydePHP Docs'); |
| 58 | + } |
| 59 | + |
| 60 | + public function testSidebarBrandViewWithoutDarkmodeFeature() |
| 61 | + { |
| 62 | + $mock = $this->mock(HydeKernel::class)->makePartial(); |
| 63 | + $mock->shouldReceive('hasFeature')->with('darkmode')->andReturn(false); |
| 64 | + HydeKernel::setInstance($mock); |
| 65 | + |
| 66 | + $view = $this->test(view('hyde::components.docs.sidebar-brand')); |
| 67 | + |
| 68 | + $view->assertSee('HydePHP Docs'); |
| 69 | + $view->assertDontSee('theme-toggle-button'); |
| 70 | + } |
| 71 | +} |
0 commit comments