-
-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathRunnerTest.php
More file actions
61 lines (50 loc) · 1.98 KB
/
RunnerTest.php
File metadata and controls
61 lines (50 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
declare(strict_types=1);
namespace Runtime\FrankenPhpSymfony\Tests;
require_once __DIR__.'/function-mock.php';
use PHPUnit\Framework\TestCase;
use Runtime\FrankenPhpSymfony\Runner;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\RebootableInterface;
use Symfony\Component\HttpKernel\TerminableInterface;
interface TestAppInterface extends HttpKernelInterface, TerminableInterface, RebootableInterface
{
}
/**
* @author Kévin Dunglas <kevin@dunglas.fr>
*/
class RunnerTest extends TestCase
{
public function testRun(): void
{
$application = $this->createMock(TestAppInterface::class);
$application
->expects($this->once())
->method('handle')
->willReturnCallback(function (Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true): Response {
$this->assertSame('bar', $request->server->get('FOO'));
return new Response();
});
$application->expects($this->once())->method('terminate');
$application->expects($this->never())->method('reboot');
$_SERVER['FOO'] = 'bar';
$runner = new Runner($application, 500, 'never');
$this->assertSame(0, $runner->run());
}
public function testRebootAlways(): void
{
$application = $this->createMock(TestAppInterface::class);
$application
->expects($this->once())
->method('handle')
->willReturnCallback(function (Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true): Response {
return new Response();
});
$application->expects($this->once())->method('terminate');
$application->expects($this->once())->method('reboot');
$runner = new Runner($application, 500, 'always');
$this->assertSame(0, $runner->run());
}
}