@@ -422,6 +422,46 @@ function it_generates_read_only_class_if_parent_class_is_read_only(ClassNode $cl
422
422
readonly class CustomClass extends \ReadOnlyClass implements \Prophecy\Doubler\Generator\MirroredInterface {
423
423
424
424
425
+ }
426
+ }
427
+ PHP;
428
+ $ expected = strtr ($ expected , array ("\r\n" => "\n" , "\r" => "\n" ));
429
+ $ code ->shouldBe ($ expected );
430
+ }
431
+
432
+ function it_generates_correct_code_if_argument_default_value_is_an_object (
433
+ ClassNode $ class ,
434
+ MethodNode $ method ,
435
+ ArgumentNode $ argument
436
+ ) {
437
+ $ class ->getParentClass ()->willReturn ('ClassWithArgument ' );
438
+ $ class ->getInterfaces ()->willReturn (array ('Prophecy\Doubler\Generator\MirroredInterface ' ));
439
+ $ class ->getProperties ()->willReturn (array ());
440
+ $ class ->getMethods ()->willReturn (array ($ method ));
441
+ $ class ->isReadOnly ()->willReturn (false );
442
+
443
+ $ method ->getName ()->willReturn ('foo ' );
444
+ $ method ->getVisibility ()->willReturn ('public ' );
445
+ $ method ->isStatic ()->willReturn (false );
446
+ $ method ->getArguments ()->willReturn ([$ argument ]);
447
+ $ method ->getReturnTypeNode ()->willReturn (new ReturnTypeNode ());
448
+ $ method ->returnsReference ()->willReturn (false );
449
+ $ method ->getCode ()->willReturn ('' );
450
+
451
+ $ argument ->getTypeNode ()->willReturn (new ArgumentTypeNode (\DateTimeInterface::class));
452
+ $ argument ->getName ()->willReturn ('arg ' );
453
+ $ argument ->isPassedByReference ()->willReturn (false );
454
+ $ argument ->isVariadic ()->willReturn (false );
455
+ $ argument ->isOptional ()->willReturn (true );
456
+ $ argument ->getDefault ()->willReturn (new \DateTime ());
457
+
458
+ $ code = $ this ->generate ('CustomClass ' , $ class );
459
+ $ expected =<<<'PHP'
460
+ namespace {
461
+ class CustomClass extends \ClassWithArgument implements \Prophecy\Doubler\Generator\MirroredInterface {
462
+ public function foo(\DateTimeInterface $arg = NULL) {
463
+
464
+ }
425
465
}
426
466
}
427
467
PHP;
0 commit comments