RoutingTest.php 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace FOS\UserBundle\Tests\Routing;
  3. use Symfony\Component\Config\FileLocator;
  4. use Symfony\Component\Routing\Loader\XmlFileLoader;
  5. use Symfony\Component\Routing\RouteCollection;
  6. class RoutingTest extends \PHPUnit_Framework_TestCase
  7. {
  8. /**
  9. * @dataProvider loadRoutingProvider
  10. */
  11. public function testLoadRouting($routeName, $path, array $methods)
  12. {
  13. $locator = new FileLocator();
  14. $loader = new XmlFileLoader($locator);
  15. $collection = new RouteCollection();
  16. $collection->addCollection($loader->load(__DIR__.'/../../Resources/config/routing/change_password.xml'));
  17. $subCollection = $loader->load(__DIR__.'/../../Resources/config/routing/group.xml');
  18. $subCollection->addPrefix('/group');
  19. $collection->addCollection($subCollection);
  20. $subCollection = $loader->load(__DIR__.'/../../Resources/config/routing/profile.xml');
  21. $subCollection->addPrefix('/profile');
  22. $collection->addCollection($subCollection);
  23. $subCollection = $loader->load(__DIR__.'/../../Resources/config/routing/registration.xml');
  24. $subCollection->addPrefix('/register');
  25. $collection->addCollection($subCollection);
  26. $subCollection = $loader->load(__DIR__.'/../../Resources/config/routing/resetting.xml');
  27. $subCollection->addPrefix('/resetting');
  28. $collection->addCollection($subCollection);
  29. $collection->addCollection($loader->load(__DIR__.'/../../Resources/config/routing/security.xml'));
  30. $route = $collection->get($routeName);
  31. $this->assertNotNull($route, sprintf('The route "%s" should exists', $routeName));
  32. $this->assertEquals($path, $route->getPath());
  33. $this->assertEquals($methods, $route->getMethods());
  34. }
  35. public function loadRoutingProvider()
  36. {
  37. return array(
  38. array('fos_user_change_password', '/change-password', array('GET', 'POST')),
  39. array('fos_user_group_list', '/group/list', array('GET')),
  40. array('fos_user_group_new', '/group/new', array('GET', 'POST')),
  41. array('fos_user_group_show', '/group/{groupname}', array('GET')),
  42. array('fos_user_group_edit', '/group/{groupname}/edit', array('GET', 'POST')),
  43. array('fos_user_group_delete', '/group/{groupname}/delete', array('GET')),
  44. array('fos_user_profile_show', '/profile/', array('GET')),
  45. array('fos_user_profile_edit', '/profile/edit', array('GET', 'POST')),
  46. array('fos_user_registration_register', '/register/', array('GET', 'POST')),
  47. array('fos_user_registration_check_email', '/register/check-email', array('GET')),
  48. array('fos_user_registration_confirm', '/register/confirm/{token}', array('GET')),
  49. array('fos_user_registration_confirmed', '/register/confirmed', array('GET')),
  50. array('fos_user_resetting_request', '/resetting/request', array('GET')),
  51. array('fos_user_resetting_send_email', '/resetting/send-email', array('POST')),
  52. array('fos_user_resetting_check_email', '/resetting/check-email', array('GET')),
  53. array('fos_user_resetting_reset', '/resetting/reset/{token}', array('GET', 'POST')),
  54. array('fos_user_security_login', '/login', array('GET', 'POST')),
  55. array('fos_user_security_check', '/login_check', array('POST')),
  56. array('fos_user_security_logout', '/logout', array('GET')),
  57. );
  58. }
  59. }