This is a tracking/informational issue - nothing we can do in Ubercart to fix this other than changing the tests to avoid the bug, which I'd rather not do at the moment. I'm documenting this here for reference, as I don't know enough to make a core patch yet.

CountryTest fails when one of the randomly-selected countries contains a single-quote (') in its name. There are only three countries out of 248 that have this, so the probability of encountering this fail is pretty small. These countries are:

Côte d'Ivoire
Korea, Democratic People's Republic of
Lao People's Democratic Republic

When the fail occurs, we can just re-run the test and chances are almost certain it will run green next time.

The fail occurs when testing for the presence of the informational message that a country has been enabled. I've looked at this a bit, and I can see that the country name is output CORRECTLY in the browser and in the Simpletest verbose output screens. The raw HTML also (again in the browser and verbose output screen) shows a single quote, and it visually appears as a single quote, and the country does get enabled (the operations button now shows that it can be disabled) so there is absolutely nothing wrong here. However, assertText() fails when comparing the strings because somewhere internal to assertText() the comparison is done with ' replaced by #039;

Note, this isn't simply HTML encoding of the string that will display properly in the browser but will read wrong in the raw HTML - this is internal to assertText() itself. The call looks like:

      $this->assertText(t('The country @country has been enabled.', ['@country' => $countries[$country_id]]));

I can print out the $countries[$country_id] array element and verify that there really is a single-quote there, NOT #039; So the raw HTML, the on-screen rendering of that HTML, and the raw array element we're comparing all have a single-quote. It's only when you go into assertText() and start printing out values that you see that internally getTextContent() contains the #039;

  protected function getTextContent() {
    if (!isset($this->plainTextContent)) {
      $this->plainTextContent = Xss::filter($this->getRawContent(), array());
    }
    return $this->plainTextContent;
  }

I'm certain that this has to do with the SafeMarkup mess that's been going on for the past few months, and indeed I started noticing these tests fails about the same time. But I haven't figured out where to patch the simpletest module yet.

Comments

TR’s picture

Issue summary: View changes

  • longwave committed 2839ef8 on 8.x-4.x
    Issue #2534240: Workaround for country tests fail when country contains...
longwave’s picture

This is getting annoying now we have multiple testbots running, so I committed a workaround that overrides assertText() in the failing test.

TR’s picture

Component: Code » Tests
TR’s picture

Status: Postponed » Fixed

This is no longer an issue now that the test has been moved from Simpletest to PHPUnit (See https://www.drupal.org/commitlog/commit/3012/554fae1f102b73765ef9b69279a...).

I guess this proves it really was a Simpletest bug...

I removed the assertText() workaround that was committed in #2 because it is no longer needed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.