Answer the question
In order to leave comments, you need to log in
How to properly test a method?
There is a very simplified method:
public function isAllowed (Dispatcher $dispatcher): bool
{
$module = $dispatcher->getModuleName();
$controller = $dispatcher->getControllerName();
$action = $dispatcher->getActionName();
if ($module === 'main' && $controller === 'index') {
return true;
}
return false;
}
Answer the question
In order to leave comments, you need to log in
There is a very simplified answer:
1. Create a Dispatcher with the desired module / controller / action
2. Pass it to isAllowed
3. Compare answer
Without knowing your Dispatcher, only a clairvoyant can give a more detailed answer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question