Test Failed
Push — master ( 3d561c...6968d6 )
by Jean-Bernard
02:06
created

EngineAsArgumentInKernelControllerTest::testReturnsResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Symfony-Util package.
5
 *
6
 * (c) Jean-Bernard Addor
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
use PHPUnit\Framework\TestCase;
13
use Symfony\Bridge\Twig\TwigEngine;
14
use Symfony\Component\EventDispatcher\EventDispatcher;
15
use Symfony\Component\HttpFoundation\Request;
16
use Symfony\Component\HttpFoundation\RequestStack;
17
use Symfony\Component\HttpFoundation\Response;
18
use Symfony\Component\HttpKernel\Controller\ArgumentResolver;
19
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
20
use Symfony\Component\HttpKernel\EventListener\ResponseListener;
21
use Symfony\Component\HttpKernel\EventListener\RouterListener;
22
use Symfony\Component\HttpKernel\HttpKernel;
23
use Symfony\Component\Routing\Matcher\UrlMatcher;
24
use Symfony\Component\Routing\RequestContext;
25
use Symfony\Component\Routing\RouteCollectionBuilder;
26
use SymfonyUtil\Controller\EngineAsArgumentController;
27
use Tests\Component\AppKernel;
28
29
/**
30
 * @covers \SymfonyUtil\Controller\EngineAsArgumentController
31
 */
32
final class EngineAsArgumentInKernelControllerTest extends TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
33
{
34
    public function testCanBeCreated()
35
    {
36
        $this->assertInstanceOf(
37
            // ...::class, // 5.4 < php
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
38
            'Symfony\Component\HttpKernel\Kernel',
39
            new AppKernel('dev', true)
40
        );
41
    }
42
43
    public function testKernelInterface()
44
    {
45
        $this->assertInstanceOf(
46
            // ...::class, // 5.4 < php
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
47
            'Symfony\Component\HttpKernel\KernelInterface',
48
            new AppKernel('dev', true)
49
        );
50
    }
51
52
    public function testFrameworkReturnsResponse()
53
    {
54
        $this->assertInstanceOf(
55
            // Response::class, // 5.4 < php
56
            'Symfony\Component\HttpFoundation\Response',
57
            (new AppKernel('dev', true))->handle(Request::create('/', 'GET'))
58
        );
59
    }
60
61
    public function testComponentReturnsResponse()
62
    {
63
        $requestStack = new RequestStack();
64
        $routes = new RouteCollectionBuilder(); // Because I know how to use it.
65
        $routes->add('/', EngineAsArgumentController::class, 'index'); // returns Symfony/Component/Routing/Route
66
        $dispatcher = new EventDispatcher();
67
        $dispatcher->addSubscriber(new RouterListener(
68
            new UrlMatcher(
69
                $routes-> build(), 
70
                new RequestContext()
71
            ),
72
            $requestStack
73
        ));
74
        $dispatcher->addSubscriber(new ResponseListener('UTF-8'));
75
        $this->assertInstanceOf(
76
            // Response::class, // 5.4 < php
77
            'Symfony\Component\HttpFoundation\Response',
78
            (new HttpKernel(
79
                $dispatcher,
80
                new ControllerResolver(),
81
                $requestStack,
82
                new ArgumentResolver();
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected ';', expecting ',' or ')'
Loading history...
83
            ))->handle(Request::create('/', 'GET'))
84
        );
85
    }
86
}
87
88
// http://api.symfony.com/3.3/Symfony/Bridge/Twig/TwigEngine.html
89
// http://api.symfony.com/3.3/Symfony/Bundle/TwigBundle/TwigEngine.html
90