-
Notifications
You must be signed in to change notification settings - Fork 11.3k
/
Copy pathKernelTest.php
35 lines (30 loc) · 1012 Bytes
/
KernelTest.php
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
<?php
namespace Illuminate\Tests\Foundation\Console;
use Illuminate\Events\Dispatcher;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Console\Kernel;
use Illuminate\Foundation\Events\Terminating;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\StringInput;
class KernelTest extends TestCase
{
public function testItDispatchesTerminatingEvent()
{
$called = [];
$app = new Application;
$events = new Dispatcher($app);
$app->instance('events', $events);
$kernel = new Kernel($app, $events);
$events->listen(function (Terminating $terminating) use (&$called) {
$called[] = 'terminating event';
});
$app->terminating(function () use (&$called) {
$called[] = 'terminating callback';
});
$kernel->terminate(new StringInput('tinker'), 0);
$this->assertSame([
'terminating event',
'terminating callback',
], $called);
}
}