<?php
/**
* on the first call, you pass in one argument, the test array.
* On the second call, you pass in the function you want to call and the arguments.
*/
function test_clearinghouse(&$a0 = NULL, &$a1 = NULL, &$a2 = NULL, &$a3 = NULL, &$a4 = NULL, &$a5 = NULL, &$a6 = NULL, &$a7 = NULL, &$a8 = NULL, &$a9 = NULL) {
switch ($state) {
case TEST_LOAD:
$test = $a0;
$state = TEST_START;
break;
case TEST_START:
$state = TEST_IN;
$function = 'original_'. $a0;
switch ($num_args - 1) {
case 0: $return = $function();break
case 1: $return = $function($a1); break;
case 2: $return = $function($a1, $a2); break;
case 3: $return = $function($a1, $a2, $a3); break;
case 4: $return = $function($a1, $a2, $a3, $a4); break;
case 5: $return = $function($a1, $a2, $a3, $a4, $a5); break;
case 6: $return = $function($a1, $a2, $a3, $a4, $a5, $a6); break;
case 7: $return = $function($a1, $a2, $a3, $a4, $a5, $a6, $a7); break;
case 8: $return = $function($a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8); break;
case 9: $return = $function($a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9); break;
}
$final_return = $test['final_return'];
unset($test['final_return']);
if (!$test && $return === $final_return) {
$this->pass();
}
else {
$this->fail();
}
$state = TEST_LOAD;
break;
case TEST_IN:
$incoming = $step['incoming'];
for ($i = 0; $i < $num_args; $i++) {
$variable_name = "$a$i";
if ($incoming[$i] !== $$variable_name) {
$this->fail();
}
}
if (isset($step['references'])) {
foreach ($step['references'] as $key => $value) {
$variable_name = "$a$key";
$$variable_name = $value;
}
}
if (isset($step['return'])) {
return $step['return'];
}
}
}
test_clearinghouse(
'incoming' =>
array('cache_get',
'variables',
'cache'),
'return' => FALSE,
),
'incoming' =>
array('db_query',
'SELECT * FROM {variable}'),
'return' => '__test_placeholder__',
),
'incoming' =>
array('db_fetch_object',
'__test_placeholder__'),
'return' =>
(object
) array('name '=>
'foo',
'value' =>
serialize('bar')),
),
'incoming' =>
array('db_fetch_object',
'__test_placeholder__'),
'return' => FALSE,
),
'incoming' =>
array('cache_set',
'variables',
),
)
);
);
test_clearinghouse('variable_init');