From: SourceForge.net <no...@so...> - 2009-12-03 12:44:47
|
Bugs item #2908047, was opened at 2009-12-03 10:39 Message generated for change (Comment added) made by You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=547455&aid=2908047&group_id=76550 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Unit test framework Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: WebmartJohn () Assigned to: Nobody/Anonymous (nobody) Summary: Register and RegisterAt in SimpleCallSchedule are illogical Initial Comment: 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. ---------------------------------------------------------------------- >Comment By: WebmartJohn () Date: 2009-12-03 12:44 Message: (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) ---------------------------------------------------------------------- Comment By: WebmartJohn () Date: 2009-12-03 12:39 Message: 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.) ---------------------------------------------------------------------- Comment By: WebmartJohn () Date: 2009-12-03 11:01 Message: 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? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=547455&aid=2908047&group_id=76550 |