File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
src/Illuminate/Concurrency
tests/Integration/Concurrency Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ public function run(Closure|array $tasks): array
25
25
/** @phpstan-ignore class.notFound */
26
26
$ results = Fork::new ()->run (...$ values );
27
27
28
+ ksort ($ results );
29
+
28
30
return array_combine ($ keys , $ results );
29
31
}
30
32
Original file line number Diff line number Diff line change 8
8
use Illuminate \Process \Factory as ProcessFactory ;
9
9
use Illuminate \Support \Facades \Concurrency ;
10
10
use Orchestra \Testbench \TestCase ;
11
+ use PHPUnit \Framework \Attributes \DataProvider ;
11
12
use PHPUnit \Framework \Attributes \RequiresOperatingSystem ;
12
13
13
14
#[RequiresOperatingSystem('Linux|DAR ' )]
@@ -119,6 +120,42 @@ public function testRunHandlerProcessErrorWithCustomExceptionWithParam()
119
120
),
120
121
]);
121
122
}
123
+
124
+ public static function getConcurrencyDrivers (): array
125
+ {
126
+ return [
127
+ ['sync ' ],
128
+ ['process ' ],
129
+ // spatie/fork package is not included by default
130
+ // ['fork'],
131
+ ];
132
+ }
133
+
134
+ #[DataProvider('getConcurrencyDrivers ' )]
135
+ public function testRunPreservesCallbackOrder (string $ driver )
136
+ {
137
+ [$ first , $ second , $ third ] = Concurrency::driver ($ driver )->run ([
138
+ function () {
139
+ usleep (1000000 );
140
+
141
+ return 'first ' ;
142
+ },
143
+ function () {
144
+ usleep (500000 );
145
+
146
+ return 'second ' ;
147
+ },
148
+ function () {
149
+ usleep (200000 );
150
+
151
+ return 'third ' ;
152
+ },
153
+ ]);
154
+
155
+ $ this ->assertEquals ('first ' , $ first );
156
+ $ this ->assertEquals ('second ' , $ second );
157
+ $ this ->assertEquals ('third ' , $ third );
158
+ }
122
159
}
123
160
124
161
class ExceptionWithoutParam extends Exception
You can’t perform that action at this time.
0 commit comments