Skip to content

Commit a6551c2

Browse files
author
=
committed
Refactored kernel wrapper test
1 parent 3533bcf commit a6551c2

File tree

2 files changed

+50
-50
lines changed

2 files changed

+50
-50
lines changed

Tests/Bridge/KernelWrapperTest.php

+50
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
88
use Symfony\Component\HttpFoundation\Request;
99
use Symfony\Component\HttpFoundation\Response;
10+
use Symfony\Component\HttpKernel\Kernel;
11+
use Symfony\Component\Config\Loader\LoaderInterface;
1012
use Zend\Diactoros\ServerRequestFactory;
1113

1214
class KernelWrapperTest extends \PHPUnit_Framework_TestCase
@@ -46,3 +48,51 @@ public function testKernelWrapper()
4648
$this->assertEquals($symfonyResponse->getStatusCode(), $psrResponse->getStatusCode());
4749
}
4850
}
51+
52+
class MockKernel extends Kernel
53+
{
54+
/**
55+
* @var callable
56+
*/
57+
protected $callback;
58+
59+
/**
60+
* Constructor.
61+
*
62+
* @param callable $callback
63+
*/
64+
public function __construct($callback)
65+
{
66+
$this->callback = $callback;
67+
68+
parent::__construct('dev', false);
69+
}
70+
71+
/**
72+
* {@inheritdoc}
73+
*/
74+
public function registerBundles()
75+
{
76+
return [];
77+
}
78+
79+
/**
80+
* {@inheritdoc}
81+
*/
82+
public function registerContainerConfiguration(LoaderInterface $loader)
83+
{
84+
}
85+
86+
/**
87+
* {@inheritdoc}
88+
*/
89+
public function handle(Request $request, $type = 1, $catch = true)
90+
{
91+
return call_user_func($this->callback, $request);
92+
93+
$psrResponse = $kernelWrapper->handleRequest($psrRequest);
94+
95+
$this->assertEquals($symfonyResponse->getContent(), (string) $psrResponse->getBody());
96+
$this->assertEquals($symfonyResponse->getStatusCode(), $psrResponse->getStatusCode());
97+
}
98+
}

Tests/Bridge/MockKernel.php

-50
This file was deleted.

0 commit comments

Comments
 (0)