#72 Unable to change parameters passed by reference

open
nobody
5
2009-12-01
2009-12-01
No

If mocking a class with a function which has "out parameters" i.e. parameters passed by reference and used to return a value, there is no way to set those parameters with SimpleTest mocks a la "setReturnValue()".

e.g. how it might be used
<?php
class C { function f ($arg1, &$arg2) { $arg2 = 'altered'; } }
require_once($path."/AdPlanner/libs/simpletest/mock_objects.php");
require_once($path."/AdPlanner/libs/simpletest/unit_tester.php");
Mock::generate('C');
class TestReferenceArgument extends UnitTestCase
{
function test()
{
$mock = new MockC();
$mock->setReturnValueAndReferenceParameters('f', 'return value', array('arg1 value', 'test input'), array(1=>'test output'));
$arg2 = 'test input';
$result = $mock->f('arg1 value', $arg2);
$this->assertEqual($arg2, 'test output');
}
}
?>

Discussion


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks