File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ protected function streamRequestsToConsole($server)
116116 */
117117 protected function shouldClearOpcodeCache ()
118118 {
119- return config ( ' octane. swoole. clear_opcache ', true ) ;
119+ return $ this -> serverState [ ' octaneConfig ' ][ ' swoole ' ][ ' clear_opcache '] ?? true ;
120120 }
121121
122122 /**
Original file line number Diff line number Diff line change 33namespace Laravel \Octane \Tests ;
44
55use Laravel \Octane \Swoole \Handlers \OnWorkerStart ;
6+ use Laravel \Octane \Swoole \SwooleExtension ;
7+ use Laravel \Octane \Swoole \WorkerState ;
68use Mockery ;
79
810class OnWorkerStartTest extends TestCase
911{
1012 public function test_should_clear_opcache_returns_true_by_default (): void
1113 {
12- $ this ->createApplication ();
13-
1414 // Mock the OnWorkerStart handler to test just the shouldClearOpcodeCache method
1515 $ handler = Mockery::mock (OnWorkerStart::class)->makePartial ();
1616
@@ -23,11 +23,21 @@ public function test_should_clear_opcache_returns_true_by_default(): void
2323
2424 public function test_should_clear_opcache_returns_configured_value (): void
2525 {
26- $ app = $ this ->createApplication ();
27- $ app ['config ' ]['octane.swoole.clear_opcache ' ] = false ;
26+ $ extension = Mockery::mock (SwooleExtension::class);
27+ $ workerState = Mockery::mock (WorkerState::class);
28+ $ basePath = realpath (__DIR__ .'/../vendor/orchestra/testbench-core/laravel ' );
2829
2930 // Mock the OnWorkerStart handler to test just the shouldClearOpcodeCache method
30- $ handler = Mockery::mock (OnWorkerStart::class)->makePartial ();
31+ $ handler = Mockery::mock (OnWorkerStart::class, [
32+ $ extension ,
33+ $ basePath ,
34+ ['octaneConfig ' => [
35+ 'swoole ' => [
36+ 'clear_opcache ' => false ,
37+ ],
38+ ]],
39+ $ workerState ,
40+ ])->makePartial ();
3141
3242 $ reflection = new \ReflectionClass ($ handler );
3343 $ method = $ reflection ->getMethod ('shouldClearOpcodeCache ' );
You can’t perform that action at this time.
0 commit comments