-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[tests-only] Make TemplatesTest more flexible #40059
Conversation
fdded82
to
ccd55f5
Compare
@jvillafanez @janackermann @JammingBen can someone review this please. IMO it should be an easy review - no change to real code, just making the unit test more flexible. |
Did you try checking with https://phpunit.readthedocs.io/en/latest/assertions.html#assertxmlstringequalsxmlstring ? I'm not sure if it will work, but it's worthy to try. |
I tried just now. But then it complained about a lot of white-space differences. There is space that is "printable" (actually would be part of the text that could be rendered). In real life that white-space makes no visible difference when a browser renders it as HTML. But s XML, the PHP assert sees it as different. To make it pass, I needed use my I pushed a commit - @jvillafanez please review again. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
I think that should be ok. I mean, if the text is different because there are white-spaces, then it different. We could considered it as a malformed document that should be fixed. I'm having doubts with the |
It is not intended to be a "general normalizer". It just does the "obvious" things that might be text white-space new-line differences which we know/decide that we don't care about for the purposes of the comparison in this test. If there was a need, then some full normalizer could be written (or find one on GitHub). But actually, we just want to allow some output variation to cope with the white-space differences in rendering that have been observed on different Ubuntu versions - presumably due to some HTML rendering utility version difference somewhere. And the difference is not so important, so we don't want to spend more time to exactly find out which version of which utility is causing this white-space difference. Merging - this is a tests-only change, so we don't need to 'freeze" that, waiting for release-10.10.0 |
Description
Unit tests in CI currently run with the owncloud-ci/php image based on Ubuntu 18.04.
On Ubuntu 20.04 some unit tests fail. See the related issue. They are failing in CI and locally on my Ubuntu 20.04 system.
This PR adjusts the 2 failing TemplatesTest tests. For some reason, on Ubuntu 20.04 (with whatever settings we have in CI and on my local system), the HTML output of the templates is "nicely formatted" with new-lines and indenting. That makes the test cases fail, because the test cases currently expect a particular exact formatting.
PHP unit test fails: https://drone.owncloud.com/owncloud/core/35632/9/8
This PR addresses items (3) and (4).
The changed test code "normalizes" the expected and actual HTML before comparing. That way the test will not be so brittle - it will work even when the formatting of the HTML is a bit different.
Related Issue
#38348
How Has This Been Tested?
CI in this PR (demonstrates that the test still passes on the Ubuntu 18.04 CI image)
Local unit test run on my Ubuntu 20.04 laptop - passes
CI of PR #40006 (demonstrates that these 2 tests pass on the Ubuntu 20.04 CI image)
Types of changes
Checklist: