Currently, phpspec/prophecy does not properly mock method arguments that are nullable if the default value is not also null. This raised an interesting design issue for RouteResult::fromResultFailure(), as the change to use a nullable argument where the default value is an empty array instead then caused test errors.
In reviewing the functionality, a default argument makes no sense. We should pass in exactly what we intend: the allowed methods for the failed route match, if any. Routers should then pass in:
Route::HTTP_METHOD_ANY if all methods are allowed; this will be true for 404 errors, where no route was matched, too!
An empty array, if no methods are allowed (which likely indicates a malformed route).
A populated array.
This patch updates to that behavior, and adds tests to verify behavior of the result once created.
Currently, phpspec/prophecy does not properly mock method arguments that are nullable if the default value is not also
null
. This raised an interesting design issue forRouteResult::fromResultFailure()
, as the change to use a nullable argument where the default value is an empty array instead then caused test errors.In reviewing the functionality, a default argument makes no sense. We should pass in exactly what we intend: the allowed methods for the failed route match, if any. Routers should then pass in:
Route::HTTP_METHOD_ANY
if all methods are allowed; this will be true for 404 errors, where no route was matched, too!This patch updates to that behavior, and adds tests to verify behavior of the result once created.
Supercedes #42.