For some reason these functions are setup to disable the over writing of previous registrations.
For instance, register should 'Stores an action against a signature that will always fire unless masked by a time specific one.'
It will only in fact do so for the first time of calling - if you call it again, and attempt to override a previous setting, then this is appended within the internal SimpleSignatureMap object, leading to it being inaccessible and never (as far as I can see) used.
The same is true of registerAt - 'Stores an action against a signature that will fire at a specific time in the future.' - except it doesn't if you re-register, essentially calling returnValueAt(1,<value>) more than once - the second call will be ignored, having been appended the SimpleSignatureMap object rather than replacing it.
There may be a perfectly rational explanation for this behaviour internally, but the public interface that testers call into (returnValue, returnValueAt) do not behave as one would expected when called twice.
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
Having read "Allows setting of actions against call signatures either at a specific time, or always. Specific time settings trump lasting ones, otherwise the most recently added will mask an earlier match." at the top of the SimpleCallSchedule api docs, it seems perhaps that the real problem here is with FindFirstSlot in http://simpletest.org/api/SimpleTest/MockObjects/SimpleSignatureMap.html - called by FindFirstAction - isn't the logic of this in fact the wrong way around according to the description above? Should it not be finding the last added matching action?
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
Having gone in and had a bit of a play with the mock_objects.php file, I think I now have the expected behaviour, but no idea whether it will effect anything else.
i've simply updated &_findFirstSlot to be:
function &_findFirstSlot($parameters) {
$count = count($this->_map);
for ($i = $count-1; $i > -1; $i--) {
if ($this->_map[$i]["params"]->test($parameters)) {
return $this->_map[$i];
}
}
$null = null;
return $null;
}
(IE, to count backward when looking for a match rather than forward, thus finding the 'most recently added' as per the description.)
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
(I should note that doing what I did in the last comment completely screws simpletests's own test suite - so probably not a very good idea, all in all)