Skip to content
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

Fixes and unit tests for UI language detection #1457

Merged
merged 6 commits into from
May 25, 2023

Conversation

osma
Copy link
Member

@osma osma commented May 24, 2023

Reasons for creating this PR

@namedgraph reported in #1453 that there are problems with the UI language detection. The main problems were fixed in PR #1455, also by @namedgraph.

The WebController.guessLanguage method which is the core of language detection did not have unit tests, and as it was written, it was difficult to unit test it because it accesses cookies and HTTP header values directly.

This PR makes some changes to WebController.guessLanguage that make it easier to test, adds some basic unit tests that verify the main language detection cases, and then applies the fixes from #1455 on top.

Link to relevant issue(s), if any

Description of the changes in this PR

  • Upgrade willdurand/negotiation from 3.0.* to 3.1.* because only 3.1 is compatible with PHP 8.1
  • Add handling of cookie values to the Request class
  • Make WebController.guessLanguage use the Request class to access cookies and HTTP header values
  • Implement unit tests for WebController.guessLanguage
  • Fix the language value passed to in_array (from PR UI language negotiation fix #1455)
  • Fix the language tags in skosmos:languages settings in the sample configs for Docker (from PR UI language negotiation fix #1455)

Known problems or uncertainties in this PR

The same fixes need to be applied to the skosmos-3 branch as well. I will do that in a follow-up PR.

Checklist

  • phpUnit tests pass locally with my changes
  • I have added tests that show that the new code works, or tests are not relevant for this PR (e.g. only HTML/CSS changes)
  • The PR doesn't reduce accessibility of the front-end code (e.g. tab focus, scaling to different resolutions, use of .sr-only class, color contrast)
  • The PR doesn't introduce unintended code changes (e.g. empty lines or useless reindentation)

@osma osma added the bug label May 24, 2023
@osma osma added this to the 2.17 milestone May 24, 2023
@osma osma self-assigned this May 24, 2023
@osma osma mentioned this pull request May 24, 2023
4 tasks
@codecov
Copy link

codecov bot commented May 24, 2023

Codecov Report

Patch coverage: 92.85% and project coverage change: +0.46 🎉

Comparison is base (a6f1795) 69.57% compared to head (9817e23) 70.03%.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1457      +/-   ##
============================================
+ Coverage     69.57%   70.03%   +0.46%     
- Complexity     1651     1656       +5     
============================================
  Files            32       32              
  Lines          4259     4268       +9     
============================================
+ Hits           2963     2989      +26     
+ Misses         1296     1279      -17     
Impacted Files Coverage Δ
model/Request.php 78.35% <87.50%> (+6.44%) ⬆️
controller/WebController.php 19.44% <100.00%> (+3.84%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sonarcloud
Copy link

sonarcloud bot commented May 25, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 15 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@osma osma merged commit f74bc3c into master May 25, 2023
@osma osma deleted the issue1453-guessLanguage-tests branch May 25, 2023 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done (verified in test.dev.finto.fi, set Milestone 3.0 for both issue & PR)
Development

Successfully merging this pull request may close these issues.

Skosmos UI loads in Arabic
2 participants