@@ -352,4 +352,66 @@ public function testRejectsControllerWithRemapMethod()
352352
353353 $ router ->getRoute ('remap/test ' );
354354 }
355+
356+ public function testRejectsURIWithUnderscoreFolder ()
357+ {
358+ $ this ->expectException (PageNotFoundException::class);
359+ $ this ->expectExceptionMessage (
360+ 'AutoRouterImproved prohibits access to the URI containing underscores ("dash_folder") '
361+ );
362+
363+ $ router = $ this ->createNewAutoRouter ();
364+
365+ $ router ->getRoute ('dash_folder ' );
366+ }
367+
368+ public function testRejectsURIWithUnderscoreController ()
369+ {
370+ $ this ->expectException (PageNotFoundException::class);
371+ $ this ->expectExceptionMessage (
372+ 'AutoRouterImproved prohibits access to the URI containing underscores ("dash_controller") '
373+ );
374+
375+ $ router = $ this ->createNewAutoRouter ();
376+
377+ $ router ->getRoute ('dash-folder/dash_controller/dash-method ' );
378+ }
379+
380+ public function testRejectsURIWithUnderscoreMethod ()
381+ {
382+ $ this ->expectException (PageNotFoundException::class);
383+ $ this ->expectExceptionMessage (
384+ 'AutoRouterImproved prohibits access to the URI containing underscores ("dash_method") '
385+ );
386+
387+ $ router = $ this ->createNewAutoRouter ();
388+
389+ $ router ->getRoute ('dash-folder/dash-controller/dash_method ' );
390+ }
391+
392+ public function testPermitsURIWithUnderscoreParam ()
393+ {
394+ $ router = $ this ->createNewAutoRouter ();
395+
396+ [$ directory , $ controller , $ method , $ params ]
397+ = $ router ->getRoute ('mycontroller/somemethod/a_b ' );
398+
399+ $ this ->assertNull ($ directory );
400+ $ this ->assertSame ('\\' . Mycontroller::class, $ controller );
401+ $ this ->assertSame ('getSomemethod ' , $ method );
402+ $ this ->assertSame (['a_b ' ], $ params );
403+ }
404+
405+ public function testDoesNotTranslateDashInParam ()
406+ {
407+ $ router = $ this ->createNewAutoRouter ();
408+
409+ [$ directory , $ controller , $ method , $ params ]
410+ = $ router ->getRoute ('mycontroller/somemethod/a-b ' );
411+
412+ $ this ->assertNull ($ directory );
413+ $ this ->assertSame ('\\' . Mycontroller::class, $ controller );
414+ $ this ->assertSame ('getSomemethod ' , $ method );
415+ $ this ->assertSame (['a-b ' ], $ params );
416+ }
355417}
0 commit comments