Completed
Push — master ( d0f720...b81791 )
by Dominik
02:59
created

RoutingTest::loadRoutingProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Azine\EmailUpdateConfirmationBundle\Routing;
4
5
use Symfony\Component\Config\FileLocator;
6
use Symfony\Component\Routing\Loader\YamlFileLoader;
7
use Symfony\Component\Routing\RouteCollection;
8
9
class RoutingTest extends \PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * @dataProvider loadRoutingProvider
13
     *
14
     * @param string $routeName
15
     * @param string $path
16
     * @param array  $methods
17
     */
18
    public function testLoadRouting($routeName, $path, array $methods)
19
    {
20
        $locator = new FileLocator();
21
        $loader = new YamlFileLoader($locator);
22
23
        $collection = new RouteCollection();
24
        $subCollection = $loader->load(__DIR__.'/../../Resources/config/routing.yml');
25
        $collection->addCollection($subCollection);
0 ignored issues
show
Documentation introduced by
$subCollection is of type object<Symfony\Component\Routing\RouteCollection>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
26
27
        $route = $collection->get($routeName);
28
        $this->assertNotNull($route, sprintf('The route "%s" should exists', $routeName));
29
        $this->assertSame($path, $route->getPath());
30
        $this->assertSame($methods, $route->getMethods());
31
    }
32
33
    /**
34
     * @return array
35
     */
36
    public function loadRoutingProvider()
37
    {
38
        return array(
39
            array('user_update_email_confirm', '/{_locale}/confirm-email-update/{token}/{redirectRoute}', array('GET')),
40
        );
41
    }
42
}
43