File tree 2 files changed +63
-2
lines changed
packages/framework/tests/Unit/Views
2 files changed +63
-2
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Hyde \Framework \Testing \Unit \Views ;
4
+
5
+ use Hyde \Testing \TestCase ;
6
+
7
+ /**
8
+ * @see resources/views/layouts/navigation.blade.php
9
+ */
10
+ class NavigationMenuViewTest extends TestCase
11
+ {
12
+ protected function setUp (): void
13
+ {
14
+ parent ::setUp ();
15
+ $ this ->mockRoute ();
16
+ $ this ->mockPage ();
17
+ }
18
+
19
+ protected function render (): string
20
+ {
21
+ return view ('hyde::layouts.navigation ' )->render ();
22
+ }
23
+
24
+ public function test_component_can_be_rendered ()
25
+ {
26
+ $ this ->assertStringContainsString ('id="main-navigation" ' , $ this ->render ());
27
+ }
28
+
29
+ public function test_component_contains_dark_mode_button ()
30
+ {
31
+ $ this ->assertStringContainsString ('theme-toggle-button ' , $ this ->render ());
32
+ }
33
+
34
+ public function test_component_contains_navigation_menu_toggle_button ()
35
+ {
36
+ $ this ->assertStringContainsString ('id="navigation-toggle-button" ' , $ this ->render ());
37
+ }
38
+
39
+ public function test_component_contains_main_navigation_links ()
40
+ {
41
+ $ this ->assertStringContainsString ('id="main-navigation-links" ' , $ this ->render ());
42
+ }
43
+
44
+ public function test_component_contains_index_html_link ()
45
+ {
46
+ $ this ->assertStringContainsString ('href="index.html" ' , $ this ->render ());
47
+ }
48
+
49
+ public function test_component_not_contains_404_html_link ()
50
+ {
51
+ $ this ->assertStringNotContainsString ('href="404.html" ' , $ this ->render ());
52
+ }
53
+ }
Original file line number Diff line number Diff line change @@ -60,8 +60,16 @@ protected function tearDown(): void
60
60
parent ::tearDown ();
61
61
}
62
62
63
- protected function mockRoute ()
63
+ /** @internal */
64
+ protected function mockRoute (?Route $ route = null )
64
65
{
65
- view ()->share ('currentRoute ' , (new Route (new MarkdownPage ())));
66
+ view ()->share ('currentRoute ' , $ route ?? (new Route (new MarkdownPage ())));
67
+ }
68
+
69
+ /** @internal */
70
+ protected function mockPage ()
71
+ {
72
+ view ()->share ('page ' , new MarkdownPage ());
73
+ view ()->share ('currentPage ' , 'PHPUnit ' );
66
74
}
67
75
}
You can’t perform that action at this time.
0 commit comments