Skip to content

Commit e40b470

Browse files
committed
[#2] testing pass by reference with Mockery::on()
1 parent 48b718b commit e40b470

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/PHPMockeryTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,32 @@ protected function setUp()
3434
$this->workaroundMockeryIssue268();
3535
}
3636

37+
/**
38+
* Tests passing by reference as described in Mockery's manual with Mockery::on().
39+
*
40+
* @test
41+
* @link http://docs.mockery.io/en/latest/reference/pass_by_reference_behaviours.html
42+
*/
43+
public function testMockeryPassByReference()
44+
{
45+
PHPMockery::mock(__NAMESPACE__, "exec")->with(
46+
"command",
47+
\Mockery::on(function (&$output) {
48+
$output = "output";
49+
return true;
50+
}),
51+
\Mockery::on(function (&$return_var) {
52+
$return_var = "return_var";
53+
return true;
54+
})
55+
)->once();
56+
57+
exec("command", $output, $return_var);
58+
59+
$this->assertEquals("output", $output);
60+
$this->assertEquals("return_var", $return_var);
61+
}
62+
3763
/**
3864
* Workaround for Mockery's issue 268.
3965
*

0 commit comments

Comments
 (0)