File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 5
5
use Closure ;
6
6
use Illuminate \Contracts \Container \Container ;
7
7
use Illuminate \Contracts \Pipeline \Pipeline as PipelineContract ;
8
+ use Illuminate \Support \Traits \Conditionable ;
8
9
use RuntimeException ;
9
10
use Throwable ;
10
11
11
12
class Pipeline implements PipelineContract
12
13
{
14
+ use Conditionable;
15
+
13
16
/**
14
17
* The container implementation.
15
18
*
Original file line number Diff line number Diff line change @@ -243,6 +243,36 @@ public function testPipelineThenReturnMethodRunsPipelineThenReturnsPassable()
243
243
244
244
unset($ _SERVER ['__test.pipe.one ' ]);
245
245
}
246
+
247
+ public function testPipelineConditionable ()
248
+ {
249
+ $ result = (new Pipeline (new Container ))
250
+ ->send ('foo ' )
251
+ ->when (true , function (Pipeline $ pipeline ) {
252
+ $ pipeline ->pipe ([PipelineTestPipeOne::class]);
253
+ })
254
+ ->then (function ($ piped ) {
255
+ return $ piped ;
256
+ });
257
+
258
+ $ this ->assertSame ('foo ' , $ result );
259
+ $ this ->assertSame ('foo ' , $ _SERVER ['__test.pipe.one ' ]);
260
+ unset($ _SERVER ['__test.pipe.one ' ]);
261
+
262
+ $ _SERVER ['__test.pipe.one ' ] = null ;
263
+ $ result = (new Pipeline (new Container ))
264
+ ->send ('foo ' )
265
+ ->when (false , function (Pipeline $ pipeline ) {
266
+ $ pipeline ->pipe ([PipelineTestPipeOne::class]);
267
+ })
268
+ ->then (function ($ piped ) {
269
+ return $ piped ;
270
+ });
271
+
272
+ $ this ->assertSame ('foo ' , $ result );
273
+ $ this ->assertNull ($ _SERVER ['__test.pipe.one ' ]);
274
+ unset($ _SERVER ['__test.pipe.one ' ]);
275
+ }
246
276
}
247
277
248
278
class PipelineTestPipeOne
You can’t perform that action at this time.
0 commit comments