-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/phpunit via strategy #100
base: develop
Are you sure you want to change the base?
Feature/phpunit via strategy #100
Conversation
added more test cases |
just wondering @koseduhemak why this redirect happens? UriPath strategy should not do redirect if locale is set in path is this a bug if so maybe better fix it? |
I digged a little more into it.
Because the Zend MVC Application is initialized in the
The uri does not get processed by strategies of SlmLocale anymore, because it previously processed the So the only possibility I see here is to modify
I hope I understood it correctly and could explain it clearly and not to misleading. |
But even if we modify Detector.php like I stated in my previous comment, we would get |
As an solution we could maybe ditch The custom
We then could modify the |
hmm do we have problem with console routes or that AbstractHttpControllerTestCase uses zend\console\request as http request? I have no clue how AbstractHttpControllerTestCase works but guess will have to take a look at it :) |
okay, I think found the problem. We try to detect languages on bootstrap phase but url path is set after bootstrap so maybe moving this to route phase would solve the problem. something like this in public function onBootstrap(EventInterface $e)
{
$app = $e->getApplication();
$sm = $app->getServiceManager();
$detector = $sm->get(Detector::class);
$em = $app->getEventManager();
$em->attach(MvcEvent::EVENT_ROUTE, function ($e) use ($app, $detector) {
$result = $detector->detect($app->getRequest(), $app->getResponse());
if ($result instanceof ResponseInterface) {
return $result;
} else {
Locale::setDefault($result);
}
}, PHP_INT_MAX);
} unfotunetly I don't have project to test this @koseduhemak maybe you can? I am not sure this wont break something else |
@svycka I tried your suggestion and replaced the
|
okay, that's a problem. Of course, you could attach MvcTranslator setLocale also in route phase after slmlocale. But changing this is BC break and not sure about this. So I am not sure about this @basz what do you think? maybe we could create DetectLanguageListener and do not attach to any event at all but leave this for the user and he will decide where to put it under route event or could add as before in onBootstrap or something else. But I am not sure about this. Or maybe we could fire a new event to tell application about found and set language? This way would be clear where and how to get detected language. |
would an additional EnviromentVariableStrategy ( I'm sorry, I haven't looked enough to really understand this issue at hand. I'm not using it actively anymore so perhaps this is a silly suggestion. |
Hi guys... Seems like we have to code our own module. My team decided to code a module by ourselves which is more suited to our needs. Therefore I am not able to investigate this (and other issues) further... We did not release a stable version, as we are not finished with initial coding / testing yet, but we made good progress so far. |
fix #26 .
Added PhpunitStrategy to cope with problems while unit testing zend applications. Updated README also with example code.
Sadly we need a special PHPUNIT variable set in phpunit.xml or boostrap.php file of the unit tests:
SLMLOCALE_DISABLE_STRATEGIES
has to be set totrue
. Otherwise we cannot differentiate between application was run by console command or phpunit command.