PHPUnit MySQL case sensitivity failures - any workaround?

PHPUnit MySQL case sensitivity failures - any workaround?

by Dave Balch -
Number of replies: 2

Hi,

I'm getting started with unit testing, and hoping to run the PHPUnit tests nightly and start writing tests for (at least) my own Moodle customisations, with any failures emailed to me.

Unfortunately MySQL's case-insensitive collation causes two failures that (I think) aren't serious [0].

I'm using a fresh M2.5 install with DEFAULT CHARSET=utf8 and Collation = utf8_general_ci, so I'd just like to check what I've gathered from old threads [1]:

  1. The test failures are just from how MySQL works - there's no way to get it to do case sensitive and passing the tests (without using collation utf8_bin and possibly getting wierd sorting)
  2. There's some way to change the fails to warnings (ref a comment by Michael de Raadt: https://tracker.moodle.org/browse/MDL-27983?focusedCommentId=131960&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-131960)

Ideally I could change the tests from fail to warn, which would make it easier to only email when there's a real failure.

Cheers,
Dave

[0] Failures;

1) dml_testcase::test_unique_index_collation_trouble
Unique index is accent insensitive, this may cause problems for non-ascii languages. This is usually caused by accent insensitive default collation.

...

2) dml_testcase::test_sql_binary_equal
SQL operator "=" is expected to be case sensitive
Failed asserting that 1 matches expected 2.

 [1] Others with same/similar problem: https://moodle.org/public/search?cx=017878793330196534763%3A-0qxztjngoy&cof=FORID%3A9&ie=UTF-8&q=test_unique_index_collation_trouble&sa=Search+moodle.org

Average of ratings: -
In reply to Dave Balch

Re: PHPUnit MySQL case sensitivity failures - any workaround?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Change the collation to use utf8-bin.

You might also be interested to read http://docs.moodle.org/dev/Database_collation_issue

Average of ratings: Useful (1)
In reply to Tim Hunt

Re: PHPUnit MySQL case sensitivity failures - any workaround?

by Dave Balch -

Ah, that's a very useful page - thanks!