route.test.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. use Laravel\Routing\Route;
  3. class RouteTest extends PHPUnit_Framework_TestCase {
  4. /**
  5. * Destroy the testing environment.
  6. */
  7. public function tearDown()
  8. {
  9. Request::$route = null;
  10. }
  11. /**
  12. * Tests the Route::handles method.
  13. *
  14. * @group laravel
  15. */
  16. public function testHandlesIndicatesIfTheRouteHandlesAGivenURI()
  17. {
  18. $route = new Route('GET /', array('handles' => array('GET /foo/bar')));
  19. $this->assertTrue($route->handles('foo/*'));
  20. $this->assertTrue($route->handles('foo/bar'));
  21. $this->assertFalse($route->handles('/'));
  22. $this->assertFalse($route->handles('baz'));
  23. $this->assertFalse($route->handles('/foo'));
  24. $this->assertFalse($route->handles('foo'));
  25. $route = new Route('GET /', array('handles' => array('GET /', 'GET /home')));
  26. $this->assertTrue($route->handles('/'));
  27. $this->assertTrue($route->handles('home'));
  28. $this->assertFalse($route->handles('foo'));
  29. }
  30. /**
  31. * Tests the Route::is method.
  32. *
  33. * @group laravel
  34. */
  35. public function testIsMethodIndicatesIfTheRouteHasAGivenName()
  36. {
  37. $route = new Route('GET /', array('name' => 'profile'));
  38. $this->assertTrue($route->is('profile'));
  39. $this->assertFalse($route->is('something'));
  40. }
  41. }