Skip to content

[phpunit-bridge] Correctly handling locale #11087

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

Closed
melkamar opened this issue Mar 5, 2019 · 4 comments
Closed

[phpunit-bridge] Correctly handling locale #11087

melkamar opened this issue Mar 5, 2019 · 4 comments
Labels
hasPR A Pull Request has already been submitted for this issue. PHPUnitBridge

Comments

@melkamar
Copy link
Contributor

melkamar commented Mar 5, 2019

Some of our unit tests break when using phpunit-bridge due to this "feature":

Forces the tests to use a consistent locale (C);

There is no further documentation about this.

  • Can the default locale be changed to something else than C?
  • What is the proper way to write code that depends on the locale? Are we supposed to explicitly call setlocale() in every function that needs it so that granular unit tests pass?
@melkamar melkamar changed the title [phpunit-bridge] How to correctly handle locale [phpunit-bridge] Correctly handling locale Mar 5, 2019
@raymondschouten
Copy link

raymondschouten commented Apr 15, 2019

Same issue here... Forcing the locale to "C" makes iconv unable to transliterate accents and now completely removes accented characters as being "invalid".

For now I have "fixed" this issue by adding a line to my PHPUnit bootstrap file:

setlocale(LC_CTYPE, 'en_US.UTF-8');

@javiereguiluz
Copy link
Member

@nicolas-grekas quick question: does this look like a bug on the code ... or is this expected and something to be documented? Thanks.

@nicolas-grekas
Copy link
Member

Phpunit provides a setLocale method for locale-sensitive tests, see e.g. https://git.higidi.com/TYPO3/TYPO3.CMS/commit/8f997b6de9e227885859740895cfe261705801dd

That's unrelated to the bridge: tests should not be context-dependent

@raymondschouten
Copy link

@nicolas-grekas thanks, I was not aware of that method provided by PHPUnit!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hasPR A Pull Request has already been submitted for this issue. PHPUnitBridge
Projects
None yet
Development

No branches or pull requests

4 participants