CompleteTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Symplify\ActionAutowire\Tests;
6
7
use PHPUnit\Framework\TestCase;
8
use Symfony\Bundle\FrameworkBundle\Controller\ControllerResolver;
9
use Symfony\Component\HttpFoundation\Request;
10
use Symplify\ActionAutowire\DependencyInjection\ServiceLocator;
11
use Symplify\ActionAutowire\Tests\CompleteSource\SomeService;
12
use Symplify\ActionAutowire\Tests\Controller\SomeController;
13
14
final class CompleteTest extends TestCase
15
{
16
    /**
17
     * @var ServiceLocator
18
     */
19
    private $serviceLocator;
20
21
    /**
22
     * @var ControllerResolver
23
     */
24
    private $controllerResolver;
25
26
    protected function setUp()
27
    {
28
        $kernel = new AppKernel();
29
        $kernel->boot();
30
31
        $this->serviceLocator = $kernel->getContainer()
32
            ->get('symplify.action_autowire.service_locator');
33
34
        $this->controllerResolver = $kernel->getContainer()
35
            ->get('debug.controller_resolver');
36
    }
37
38
    public function testServiceLocator()
39
    {
40
        $this->assertInstanceOf(SomeService::class, $this->serviceLocator->getByType(SomeService::class));
41
42
        $this->assertFalse($this->serviceLocator->getByType('missing'));
43
    }
44
45
    public function testGetAutowiredControllerAction()
46
    {
47
        $request = new Request();
48
        $request->attributes->set('_controller', SomeController::class . '::someServiceAwareAction');
49
50
        $controller = $this->controllerResolver->getController($request);
51
        $arguments = $this->controllerResolver->getArguments($request, $controller);
0 ignored issues
show
Deprecated Code introduced by
The method Symfony\Component\HttpKe...esolver::getArguments() has been deprecated with message: This method is deprecated as of 3.1 and will be removed in 4.0. Implement the ArgumentResolverInterface and inject it in the HttpKernel instead.

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...
52
53
        $this->assertInstanceOf(SomeService::class, $arguments[0]);
54
    }
55
}
56