@@ -516,6 +516,77 @@ public function testCallWithDependencies()
516
516
$ this ->assertEquals ('taylor ' , $ result [1 ]);
517
517
}
518
518
519
+ public function testWithDefaultParametersIndexedArraySyntax ()
520
+ {
521
+ $ container = new Container ;
522
+ $ result = $ container ->call (ContainerTestDefaultyParams::class.'@defaulty ' , ['foo ' , 'bar ' ]);
523
+
524
+ $ this ->assertEquals (['foo ' , 'bar ' , 'default c ' ], $ result );
525
+
526
+ $ container = new Container ;
527
+ $ result = $ container ->call (ContainerTestDefaultyParams::class.'@defaulty ' , ['foo ' , 'bar ' , 'baz ' ]);
528
+
529
+ $ this ->assertEquals (['foo ' , 'bar ' , 'baz ' ], $ result );
530
+
531
+ $ container = new Container ;
532
+ $ result = $ container ->call (ContainerTestDefaultyParams::class.'@defaulty ' );
533
+
534
+ $ this ->assertEquals (['default a ' , 'default b ' , 'default c ' ], $ result );
535
+
536
+ $ container = new Container ;
537
+ $ result = $ container ->call (ContainerTestDefaultyParams::class.'@defaultyBandC ' , ['foo ' , 'bar ' ]);
538
+
539
+ $ this ->assertEquals (['foo ' , 'bar ' , 'default c ' ], $ result );
540
+
541
+ $ container = new Container ;
542
+ $ result = $ container ->call (ContainerTestDefaultyParams::class.'@defaultyBandC ' , ['foo ' ]);
543
+
544
+ $ this ->assertEquals (['foo ' , 'default b ' , 'default c ' ], $ result );
545
+
546
+ $ container = new Container ;
547
+ $ result = $ container ->call (ContainerTestDefaultyParams::class.'@defaultyOnlyC ' , ['foo ' , 'bar ' ]);
548
+
549
+ $ this ->assertEquals (['foo ' , 'bar ' , 'default c ' ], $ result );
550
+
551
+ $ container = new Container ;
552
+ $ result = $ container ->call (ContainerTestDefaultyParams::class.'@noDefault ' , ['foo ' , 'bar ' , 'baz ' ]);
553
+
554
+ $ this ->assertEquals (['foo ' , 'bar ' , 'baz ' ], $ result );
555
+ }
556
+
557
+ public function testWithDefaultParametersAssociativeSyntax ()
558
+ {
559
+ $ container = new Container ;
560
+ $ result = $ container ->call (ContainerTestDefaultyParams::class.'@defaulty ' , ['a ' => 'foo ' , 'b ' => 'bar ' ]);
561
+
562
+ $ this ->assertEquals (['foo ' , 'bar ' , 'default c ' ], $ result );
563
+
564
+ $ container = new Container ;
565
+ $ result = $ container ->call (ContainerTestDefaultyParams::class.'@defaulty ' , ['a ' => 'foo ' , 'b ' => 'bar ' , 'c ' => 'baz ' ]);
566
+
567
+ $ this ->assertEquals (['foo ' , 'bar ' , 'baz ' ], $ result );
568
+
569
+ $ container = new Container ;
570
+ $ result = $ container ->call (ContainerTestDefaultyParams::class.'@defaultyBandC ' , ['a ' => 'foo ' , 'b ' => 'bar ' ]);
571
+
572
+ $ this ->assertEquals (['foo ' , 'bar ' , 'default c ' ], $ result );
573
+
574
+ $ container = new Container ;
575
+ $ result = $ container ->call (ContainerTestDefaultyParams::class.'@defaultyBandC ' , ['a ' => 'foo ' ]);
576
+
577
+ $ this ->assertEquals (['foo ' , 'default b ' , 'default c ' ], $ result );
578
+
579
+ $ container = new Container ;
580
+ $ result = $ container ->call (ContainerTestDefaultyParams::class.'@defaultyOnlyC ' , ['a ' => 'foo ' , 'b ' => 'bar ' ]);
581
+
582
+ $ this ->assertEquals (['foo ' , 'bar ' , 'default c ' ], $ result );
583
+
584
+ $ container = new Container ;
585
+ $ result = $ container ->call (ContainerTestDefaultyParams::class.'@noDefault ' , ['a ' => 'foo ' , 'b ' => 'bar ' , 'c ' => 'baz ' ]);
586
+
587
+ $ this ->assertEquals (['foo ' , 'bar ' , 'baz ' ], $ result );
588
+ }
589
+
519
590
/**
520
591
* @expectedException \ReflectionException
521
592
* @expectedExceptionMessage Function ContainerTestCallStub() does not exist
@@ -1271,3 +1342,26 @@ public function __construct()
1271
1342
static ::$ instantiations ++;
1272
1343
}
1273
1344
}
1345
+
1346
+ class ContainerTestDefaultyParams
1347
+ {
1348
+ public function defaulty ($ a = 'default a ' , $ b = 'default b ' , $ c = 'default c ' )
1349
+ {
1350
+ return func_get_args ();
1351
+ }
1352
+
1353
+ public function defaultyBandC ($ a , $ b = 'default b ' , $ c = 'default c ' )
1354
+ {
1355
+ return func_get_args ();
1356
+ }
1357
+
1358
+ public function defaultyOnlyC ($ a , $ b , $ c = 'default c ' )
1359
+ {
1360
+ return func_get_args ();
1361
+ }
1362
+
1363
+ public function noDefault ($ a , $ b , $ c )
1364
+ {
1365
+ return func_get_args ();
1366
+ }
1367
+ }
0 commit comments