/
RoutingTest.php
60 lines (52 loc) 路 2.11 KB
/
RoutingTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/*
* This file is part of the NucleosProfileBundle package.
*
* (c) Christian Gripp <mail@core23.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Nucleos\ProfileBundle\Tests\Routing;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Routing\Loader\PhpFileLoader;
use Symfony\Component\Routing\RouteCollection;
final class RoutingTest extends TestCase
{
/**
* @dataProvider loadRoutingProvider
*
* @param string[] $methods
*/
public function testLoadRouting(string $routeName, string $path, array $methods): void
{
$locator = new FileLocator();
$loader = new PhpFileLoader($locator);
$collection = new RouteCollection();
$subCollection = $loader->load(__DIR__.'/../../src/Resources/config/routing/profile.php');
$subCollection->addPrefix('/profile');
$collection->addCollection($subCollection);
$subCollection = $loader->load(__DIR__.'/../../src/Resources/config/routing/registration.php');
$subCollection->addPrefix('/register');
$collection->addCollection($subCollection);
$route = $collection->get($routeName);
static::assertNotNull($route, sprintf('The route "%s" should exists', $routeName));
static::assertSame($path, $route->getPath());
static::assertSame($methods, $route->getMethods());
}
/**
* @return string[][]|string[][][]
*/
public static function loadRoutingProvider(): array
{
return [
['nucleos_profile_profile_show', '/profile/', ['GET']],
['nucleos_profile_profile_edit', '/profile/edit', ['GET', 'POST']],
['nucleos_profile_registration_register', '/register/', ['GET', 'POST']],
['nucleos_profile_registration_check_email', '/register/check-email', ['GET']],
['nucleos_profile_registration_confirm', '/register/confirm/{token}', ['GET']],
['nucleos_profile_registration_confirmed', '/register/confirmed', ['GET']],
];
}
}