Test Setup Failed
Push — master ( e4bb3e...ec0b1d )
by Gabriel
02:21 queued 10s
created

testSetParamsNotOverwriteMapDefaults()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
namespace Nip\Router\Tests\Legacy\Route;
4
5
use Nip\Router\Route\Route;
6
use Nip\Router\Tests\AbstractTest;
7
8
/**
9
 * Class AbstractRouteTraitTest
10
 * @package Nip\Router\Tests\Legacy\Route
11
 */
12
class AbstractRouteTraitTest extends AbstractTest
13
{
14
    public function testSetParamsNotOverwriteMapDefaults()
15
    {
16
        $route = new Route('/{controller}/{action?index}');
0 ignored issues
show
Documentation introduced by
'/{controller}/{action?index}' is of type string, but the function expects a boolean.

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...
17
        self::assertSame(['action' => 'index'], $route->getDefaults());
18
19
        $params = ['test' => 9];
20
        $route->setParams($params);
0 ignored issues
show
Deprecated Code introduced by
The method Nip\Router\Legacy\Route\...RouteTrait::setParams() has been deprecated with message: Use setDefaults

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
21
        self::assertEquals(['test' => 9, 'action' => 'index'], $route->getDefaults());
22
    }
23
24
    public function testSetParams()
25
    {
26
        $route = new Route();
27
        self::assertSame([], $route->getDefaults());
28
29
        $params = ['test' => 9];
30
        $route->setParams($params);
0 ignored issues
show
Deprecated Code introduced by
The method Nip\Router\Legacy\Route\...RouteTrait::setParams() has been deprecated with message: Use setDefaults

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
31
        self::assertEquals($params, $route->getDefaults());
32
    }
33
}
34