Completed
Pull Request — master (#456)
by Vincent
08:23
created

RoutingTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 31
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testRoutes() 0 11 1
A getRoutes() 0 6 1
A getKernelClass() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\NotificationBundle\Tests\Functional\Routing;
15
16
use Sonata\NotificationBundle\Tests\App\AppKernel;
17
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
18
19
/**
20
 * @author Javier Spagnoletti <[email protected]>
21
 */
22
final class RoutingTest extends WebTestCase
23
{
24
    /**
25
     * @group legacy
26
     *
27
     * @dataProvider getRoutes
28
     */
29
    public function testRoutes(string $name, string $path, array $methods): void
30
    {
31
        $client = static::createClient();
32
        $router = $client->getContainer()->get('router');
33
34
        $route = $router->getRouteCollection()->get($name);
35
36
        $this->assertNotNull($route);
37
        $this->assertSame($path, $route->getPath());
38
        $this->assertEmpty(array_diff($methods, $route->getMethods()));
39
    }
40
41
    public function getRoutes(): iterable
42
    {
43
        yield ['nelmio_api_doc_index', '/api/doc/{view}', ['GET']];
44
        yield ['sonata_api_notification_message_get_messages', '/api/notification/messages.{_format}', ['GET']];
45
        yield ['sonata_api_notification_message_post_message', '/api/notification/messages.{_format}', ['POST']];
46
    }
47
48
    protected static function getKernelClass(): string
49
    {
50
        return AppKernel::class;
51
    }
52
}
53