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