@@ -135,15 +135,13 @@ public function test_route_facade_all_method_returns_all_routes()
135
135
$ this ->assertEquals (Router::getInstance ()->getRoutes (), Route::all ());
136
136
}
137
137
138
- // test getLink uses hyde::relativeLink() to get the correct path for root pages
139
138
public function test_get_link_returns_correct_path_for_root_pages ()
140
139
{
141
140
$ route = new Route (new MarkdownPage (slug: 'foo ' ));
142
141
$ this ->assertEquals (Hyde::relativeLink ($ route ->getOutputFilePath ()), $ route ->getLink ());
143
142
$ this ->assertEquals ('foo.html ' , $ route ->getLink ());
144
143
}
145
144
146
- // test getLink uses hyde::relativeLink() to get the correct path for nested pages
147
145
public function test_get_link_returns_correct_path_for_nested_pages ()
148
146
{
149
147
$ route = new Route (new MarkdownPage (slug: 'foo/bar ' ));
@@ -154,11 +152,11 @@ public function test_get_link_returns_correct_path_for_nested_pages()
154
152
public function test_get_link_returns_correct_path_for_nested_current_page ()
155
153
{
156
154
$ route = new Route (new MarkdownPage (slug: 'foo ' ));
157
- $ this ->assertEquals (Hyde::relativeLink ($ route ->getOutputFilePath (), 'foo/bar ' ), $ route ->getLink ('foo/bar ' ));
158
- $ this ->assertEquals ('../foo.html ' , $ route ->getLink ('foo/bar ' ));
155
+ view ()->share ('currentPage ' , 'foo/bar ' );
156
+ $ this ->assertEquals (Hyde::relativeLink ($ route ->getOutputFilePath (), 'foo/bar ' ), $ route ->getLink ());
157
+ $ this ->assertEquals ('../foo.html ' , $ route ->getLink ());
159
158
}
160
159
161
- // test getLink returns pretty url if enabled
162
160
public function test_get_link_returns_pretty_url_if_enabled ()
163
161
{
164
162
config (['hyde.pretty_urls ' => true ]);
@@ -167,10 +165,22 @@ public function test_get_link_returns_pretty_url_if_enabled()
167
165
$ this ->assertEquals ('foo ' , $ route ->getLink ());
168
166
}
169
167
170
- // test to string is alias for getLink
171
168
public function test_to_string_is_alias_for_get_link ()
172
169
{
173
170
$ route = new Route (new MarkdownPage (slug: 'foo ' ));
174
171
$ this ->assertEquals ($ route ->getLink (), (string ) $ route );
175
172
}
173
+
174
+ public function test_current_returns_current_route ()
175
+ {
176
+ $ route = new Route (new MarkdownPage (slug: 'foo ' ));
177
+ view ()->share ('currentRoute ' , $ route );
178
+ $ this ->assertEquals ($ route , Route::current ());
179
+ }
180
+
181
+ public function test_current_throws_exception_if_route_is_not_found ()
182
+ {
183
+ $ this ->expectException (RouteNotFoundException::class);
184
+ Route::current ();
185
+ }
176
186
}
0 commit comments