File tree Expand file tree Collapse file tree 3 files changed +90
-0
lines changed
framework/tests/Feature/Views Expand file tree Collapse file tree 3 files changed +90
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Hyde \Framework \Testing \Feature \Views ;
6+
7+ use Hyde \Facades \Config ;
8+ use Hyde \Testing \TestCase ;
9+ use Hyde \Testing \TestsBladeViews ;
10+
11+ class SidebarFooterTextViewTest extends TestCase
12+ {
13+ use TestsBladeViews;
14+
15+ public function testSidebarFooterTextViewWithDefaultConfig ()
16+ {
17+ $ view = $ this ->test (view ('hyde::components.docs.sidebar-footer-text ' ));
18+
19+ $ view ->assertSeeHtml ('<a href="index.html">Back to home page</a> ' );
20+ }
21+
22+ public function testSidebarFooterTextViewWhenConfigOptionIsTrue ()
23+ {
24+ Config::set ('docs.sidebar.footer ' , true );
25+
26+ $ view = $ this ->test (view ('hyde::components.docs.sidebar-footer-text ' ));
27+
28+ $ view ->assertSeeHtml ('<a href="index.html">Back to home page</a> ' );
29+ }
30+
31+ public function testSidebarFooterTextViewWhenConfigOptionIsMarkdownString ()
32+ {
33+ Config::set ('docs.sidebar.footer ' , 'Your Markdown String Here ' );
34+
35+ $ view = $ this ->test (view ('hyde::components.docs.sidebar-footer-text ' ));
36+
37+ $ view ->assertSeeText ('Your Markdown String Here ' );
38+ }
39+
40+ public function testSidebarFooterTextViewWhenConfigOptionIsFalse ()
41+ {
42+ // This state is handled earlier in the component by the sidebar component so we don't need to test it here.
43+
44+ $ this ->assertTrue (true );
45+ }
46+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Hyde \Testing \Support ;
6+
7+ class TestView extends \Illuminate \Testing \TestView
8+ {
9+ /**
10+ * Assert that the given HTML is contained within the view.
11+ *
12+ * @return $this
13+ */
14+ public function assertSeeHtml (string $ value ): static
15+ {
16+ return $ this ->assertSee ($ value , false );
17+ }
18+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Hyde \Testing ;
6+
7+ use Illuminate \View \View ;
8+ use Hyde \Testing \Support \TestView ;
9+
10+ /**
11+ * Provides a more fluent way to test Blade views.
12+ */
13+ trait TestsBladeViews
14+ {
15+ /**
16+ * Test a Blade view.
17+ */
18+ protected function test (string |View $ view , $ data = []): TestView
19+ {
20+ if ($ view instanceof View) {
21+ return new TestView ($ view );
22+ }
23+
24+ return new TestView (view ($ view , $ data ));
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments