Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit 92d93f9

Browse files
authored
Merge pull request #189 from swooletw/develop
add support for Lumen 5.7
2 parents 391e168 + b65df70 commit 92d93f9

File tree

3 files changed

+10
-50
lines changed

3 files changed

+10
-50
lines changed

src/Concerns/WithApplication.php

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@ trait WithApplication
2424

2525
/**
2626
* Bootstrap framework.
27-
*
28-
* @throws \ReflectionException
2927
*/
3028
protected function bootstrap()
3129
{
3230
if ($this->framework === 'laravel') {
33-
$bootstrappers = $this->getBootstrappers();
34-
$this->app->bootstrapWith($bootstrappers);
31+
$this->app->bootstrap();
3532
} else {
33+
// for Lumen 5.7
34+
// https://github.com/laravel/lumen-framework/commit/42cbc998375718b1a8a11883e033617024e57260#diff-c9248b3167fc44af085b81db2e292837
35+
if (method_exists($this->app, 'boot')) {
36+
$this->app->boot();
37+
}
3638
if (is_null(Facade::getFacadeApplication())) {
3739
$this->app->withFacades();
3840
}
@@ -75,28 +77,6 @@ public function setApplication(Container $app)
7577
$this->app = $app;
7678
}
7779

78-
/**
79-
* Get bootstrappers.
80-
*
81-
* @return array
82-
* @throws \ReflectionException
83-
*/
84-
protected function getBootstrappers()
85-
{
86-
$kernel = $this->getApplication()->make(Kernel::class);
87-
88-
$reflection = new \ReflectionObject($kernel);
89-
90-
$bootstrappersMethod = $reflection->getMethod('bootstrappers');
91-
$bootstrappersMethod->setAccessible(true);
92-
93-
$bootstrappers = $bootstrappersMethod->invoke($kernel);
94-
95-
array_splice($bootstrappers, -2, 0, ['Illuminate\Foundation\Bootstrap\SetRequestForConsole']);
96-
97-
return $bootstrappers;
98-
}
99-
10080
/**
10181
* Set framework.
10282
*

tests/Server/ManagerTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,14 @@ public function testOnWorkerStart()
155155
public function testLoadApplication()
156156
{
157157
$server = $this->getServer();
158-
$this->getManager();
159-
160-
$container = $this->getContainer($this->getServer(), $this->getConfig());
158+
$container = $this->getContainer($server, $this->getConfig());
161159
$container->singleton('events', function () {
162160
return $this->getEvent('swoole.workerStart');
163161
});
164162

165163
$path = __DIR__ . '/../fixtures';
166164
$manager = $this->getManager($container, $framework = 'laravel', $path);
167165
$manager->onWorkerStart($server);
168-
169-
$manager->getApplication();
170166
}
171167

172168
public function testOnTaskWorkerStart()

tests/fixtures/bootstrap/app.php

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
<?php
22

3-
use Illuminate\Contracts\Container\Container;
4-
use Illuminate\Contracts\Http\Kernel;
53
use Mockery as m;
6-
7-
$kernel = new TestKernel;
4+
use Illuminate\Contracts\Container\Container;
85

96
$app = m::mock(Container::class);
10-
$app->shouldReceive('make')
11-
->with(Kernel::class)
12-
->once()
13-
->andReturn($kernel);
14-
$app->shouldReceive('bootstrapWith')
15-
->once()
16-
->andReturn($kernel);
7+
$app->shouldReceive('bootstrap')
8+
->once();
179
$app->shouldReceive('offsetExists')
1810
->with('foo')
1911
->once()
@@ -25,11 +17,3 @@
2517
$app->shouldReceive('alias');
2618

2719
return $app;
28-
29-
class TestKernel
30-
{
31-
public function bootstrappers()
32-
{
33-
return [];
34-
}
35-
}

0 commit comments

Comments
 (0)