Issues (62)

Tests/Routing/RouteMetadataFactoryTest.php (1 issue)

Labels
Severity
1
<?php
2
3
/*
4
 *
5
 * (c) Yaroslav Honcharuk <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Yarhon\RouteGuardBundle\Tests\Routing;
12
13
use PHPUnit\Framework\TestCase;
14
use Symfony\Component\Routing\Route;
15
use Symfony\Component\Routing\CompiledRoute;
16
use Yarhon\RouteGuardBundle\Routing\RouteMetadata;
17
use Yarhon\RouteGuardBundle\Routing\RouteMetadataFactory;
18
19
/**
20
 * @author Yaroslav Honcharuk <[email protected]>
21
 */
22
class RouteMetadataFactoryTest extends TestCase
23
{
24
    private $factory;
25
26
    public function setUp()
27
    {
28
        $this->factory = new RouteMetadataFactory();
29
    }
30
31
    public function testCreateMetadata()
32
    {
33
        $route = $this->createMock(Route::class);
34
35
        $route->method('getDefaults')
0 ignored issues
show
The method method() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
        $route->/** @scrutinizer ignore-call */ 
36
                method('getDefaults')

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
36
            ->willReturn(['_controller' => 'c::d', '_canonical_route' => 'foo', 'page' => 1]);
37
38
        $compiledRoute = $this->createMock(CompiledRoute::class);
39
40
        $route->method('compile')
41
            ->willReturn($compiledRoute);
42
43
        $compiledRoute->method('getVariables')
44
            ->willReturn(['page', 'offset']);
45
46
        $metadata = $this->factory->createMetadata($route);
47
48
        $this->assertInstanceOf(RouteMetadata::class, $metadata);
49
        $this->assertEquals(['page' => 1], $metadata->getDefaults());
50
        $this->assertEquals(['page', 'offset'], $metadata->getVariables());
51
    }
52
}
53