|
48 | 48 | require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'AnInterface.php';
|
49 | 49 | require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'FunctionCallback.php';
|
50 | 50 | require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'MethodCallback.php';
|
| 51 | +require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'MethodCallbackByReference.php'; |
51 | 52 | require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'PartialMockTestClass.php';
|
52 | 53 | require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'SomeClass.php';
|
53 | 54 | require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'StaticMockTestClass.php';
|
@@ -564,6 +565,45 @@ public function testVerificationOfNeverFailsWithAnyParameters()
|
564 | 565 | $this->resetMockObjects();
|
565 | 566 | }
|
566 | 567 |
|
| 568 | + public function testMockArgumentsPassedByReference() { |
| 569 | + $foo = $this->getMockBuilder('MethodCallbackByReference') |
| 570 | + ->setMethods(array('bar')) |
| 571 | + ->disableOriginalConstructor() |
| 572 | + ->disableArgumentCloning() |
| 573 | + ->getMock(); |
| 574 | + |
| 575 | + $foo->expects($this->any()) |
| 576 | + ->method('bar') |
| 577 | + ->will($this->returnCallback(array($foo, 'callback'))); |
| 578 | + |
| 579 | + $a = $b = $c = 0; |
| 580 | + |
| 581 | + $foo->bar($a, $b, $c); |
| 582 | + |
| 583 | + $this->assertEquals(1, $b); |
| 584 | + } |
| 585 | + |
| 586 | + public function testMockArgumentsPassedByReference2() { |
| 587 | + $foo = $this->getMockBuilder('MethodCallbackByReference') |
| 588 | + ->disableOriginalConstructor() |
| 589 | + ->disableArgumentCloning() |
| 590 | + ->getMock(); |
| 591 | + |
| 592 | + $foo->expects($this->any()) |
| 593 | + ->method('bar') |
| 594 | + ->will($this->returnCallback( |
| 595 | + function ($a, &$b, $c) { |
| 596 | + $b = 1; |
| 597 | + } |
| 598 | + )); |
| 599 | + |
| 600 | + $a = $b = $c = 0; |
| 601 | + |
| 602 | + $foo->bar($a, $b, $c); |
| 603 | + |
| 604 | + $this->assertEquals(1, $b); |
| 605 | + } |
| 606 | + |
567 | 607 | /**
|
568 | 608 | * @requires extension soap
|
569 | 609 | */
|
|
0 commit comments