|
7 | 7 | use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
|
8 | 8 | use Symfony\Component\HttpFoundation\Request;
|
9 | 9 | use Symfony\Component\HttpFoundation\Response;
|
| 10 | +use Symfony\Component\HttpKernel\Kernel; |
| 11 | +use Symfony\Component\Config\Loader\LoaderInterface; |
10 | 12 | use Zend\Diactoros\ServerRequestFactory;
|
11 | 13 |
|
12 | 14 | class KernelWrapperTest extends \PHPUnit_Framework_TestCase
|
@@ -46,3 +48,51 @@ public function testKernelWrapper()
|
46 | 48 | $this->assertEquals($symfonyResponse->getStatusCode(), $psrResponse->getStatusCode());
|
47 | 49 | }
|
48 | 50 | }
|
| 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 | +} |
0 commit comments