Completed
Push — master ( 76844d...a0c467 )
by Tomáš
02:57
created

ControllerResolverTest::testGetArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4286
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Symplify\ControllerAutowire\Tests\HttpKernel\Controller;
4
5
use PHPUnit_Framework_TestCase;
6
use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser;
7
use Symfony\Component\DependencyInjection\ContainerInterface;
8
use Symfony\Component\HttpFoundation\Request;
9
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
10
use Symplify\ControllerAutowire\HttpKernel\Controller\ControllerResolver;
11
12
final class ControllerResolverTest extends PHPUnit_Framework_TestCase
13
{
14
    /**
15
     * @var ControllerResolver
16
     */
17
    private $controllerResolver;
18
19
    protected function setUp()
20
    {
21
        $this->controllerResolver = $this->createControllerResolverWithMocks();
22
    }
23
24 View Code Duplication
    public function testGetController()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
    {
26
        $request = new Request();
27
        $request->attributes->set('_controller', 'SomeController::someAction');
28
29
        $controller = $this->controllerResolver->getController($request);
30
        $this->assertNull($controller);
31
    }
32
33
    public function testGetArguments()
34
    {
35
        $this->assertNull(
36
            $this->controllerResolver->getArguments(new Request(), 'missing')
37
        );
38
    }
39
40
    /**
41
     * @return ControllerResolver
42
     */
43
    private function createControllerResolverWithMocks()
44
    {
45
        $parentControllerResolverMock = $this->prophesize(ControllerResolverInterface::class);
46
        $containerMock = $this->prophesize(ContainerInterface::class);
47
        $controllerNameParser = $this->prophesize(ControllerNameParser::class);
48
49
        return new ControllerResolver(
50
            $parentControllerResolverMock->reveal(),
51
            $containerMock->reveal(),
52
            $controllerNameParser->reveal()
53
        );
54
    }
55
}
56