User tests: Successful: Unsuccessful:
This should fix a unit test that is currently failing like:
1) JRegistryFormatXMLTest::testObjectToString
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
'<?xml version="1.0"?>
-<registry><node name="foo" type="string">bar</node><node name="quoted" type="string">"stringwithquotes"</node><node name="booleantrue" type="boolean">1</node><node name="booleanfalse" type="boolean"></node><node name="numericint" type="integer">42</node><node name="numericfloat" type="double">3.1415</node><node name="section" type="object"><node name="key" type="string">value</node></node><node name="array" type="array"><node name="nestedarray" type="array"><node name="test1" type="string">value1</node></node></node></registry>
+<registry><node name="foo" type="string">bar</node><node name="quoted" type="string">"stringwithquotes"</node><node name="booleantrue" type="boolean">1</node><node name="booleanfalse" type="boolean"/><node name="numericint" type="integer">42</node><node name="numericfloat" type="double">3.1415</node><node name="section" type="object"><node name="key" type="string">value</node></node><node name="array" type="array"><node name="nestedarray" type="array"><node name="test1" type="string">value1</node></node></node></registry>
'
I had noticed this failure and Michael and I talked about it earlier trying to sort out the best way to fix it. This fix will repair it on Travis but I think will kill it on other environments.
Thanks,
David Hurley
webspark
david@websparkinc.com
336.525.9282 (mobile)
336.525.6131 (office)
On November 25, 2013 at 8:43:56 AM, Nikolai Plath (notifications@github.com) wrote:
This should fix a unit test that is currently failing like:
1) JRegistryFormatXMLTest::testObjectToString
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
'<?xml version="1.0"?>
-bar"stringwithquotes"1423.1415valuevalue1
+bar"stringwithquotes"1423.1415valuevalue1
'
You can merge this Pull Request by running
git pull https://github.com/elkuku/joomla-cms ut-1
Or view, comment on, or merge it at:
Commit Summary
Fix a failing unit test
File Changes
M tests/unit/suites/libraries/joomla/registry/format/JRegistryFormatXmlTest.php (2)
Patch Links:
https://github.com/joomla/joomla-cms/pull/2596.patch
https://github.com/joomla/joomla-cms/pull/2596.diff
I thought it was too easy... but it seems like right to me.
Do you eventually have a Jenkins log with the test failing ?
Closing :(
Title |
|
||||||
Description | <p>This should fix a unit test that is currently failing like:</p> <pre><code>1) JRegistryFormatXMLTest::testObjectToString Failed asserting that two strings are equal. --- Expected +++ Actual @@ @@ '<?xml version="1.0"?> -<registry><node name="foo" type="string">bar</node><node name="quoted" type="string">"stringwithquotes"</node><node name="booleantrue" type="boolean">1</node><node name="booleanfalse" type="boolean"></node><node name="numericint" type="integer">42</node><node name="numericfloat" type="double">3.1415</node><node name="section" type="object"><node name="key" type="string">value</node></node><node name="array" type="array"><node name="nestedarray" type="array"><node name="test1" type="string">value1</node></node></node></registry> +<registry><node name="foo" type="string">bar</node><node name="quoted" type="string">"stringwithquotes"</node><node name="booleantrue" type="boolean">1</node><node name="booleanfalse" type="boolean"/><node name="numericint" type="integer">42</node><node name="numericfloat" type="double">3.1415</node><node name="section" type="object"><node name="key" type="string">value</node></node><node name="array" type="array"><node name="nestedarray" type="array"><node name="test1" type="string">value1</node></node></node></registry> ' </code></pre> | ⇒ | <p>This should fix a unit test that is currently failing like:</p> <pre><code>1) JRegistryFormatXMLTest::testObjectToString Failed asserting that two strings are equal. --- Expected +++ Actual @@ @@ '<?xml version="1.0"?> -<registry><node name="foo" type="string">bar</node><node name="quoted" type="string">"stringwithquotes"</node><node name="booleantrue" type="boolean">1</node><node name="booleanfalse" type="boolean"></node><node name="numericint" type="integer">42</node><node name="numericfloat" type="double">3.1415</node><node name="section" type="object"><node name="key" type="string">value</node></node><node name="array" type="array"><node name="nestedarray" type="array"><node name="test1" type="string">value1</node></node></node></registry> +<registry><node name="foo" type="string">bar</node><node name="quoted" type="string">"stringwithquotes"</node><node name="booleantrue" type="boolean">1</node><node name="booleanfalse" type="boolean"/><node name="numericint" type="integer">42</node><node name="numericfloat" type="double">3.1415</node><node name="section" type="object"><node name="key" type="string">value</node></node><node name="array" type="array"><node name="nestedarray" type="array"><node name="test1" type="string">value1</node></node></node></registry> ' </code></pre> <p>Ref: <a href="http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=32813&start=0">http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=32813&start=0</a></p> | ||||
Status | New | ⇒ | Closed | ||||
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2013-11-25 13:51:10 | ||||
Labels |
Added:
?
|
It'll be the same test failing but what's being expected now is the actual on Jenkins, so changing the expectation to fix Travis will break Jenkins unfortunately.
OK that made me digging a bit...
Could it be that the problem is a different PHP version and a "slight change" in PHP's SimpleXML-Thingy ?
e.g.: http://stackoverflow.com/questions/17035549/simple-xml-converting-boolean-false-to-simplexmlelement
which only says "RTFM" ;)
This would be a test code:
$xml = simplexml_load_string('<test/>');
$xml->addChild('false', false);
echo $xml->asXML();
and the expected output would be:
<test><false/></test>
I believe that neither (J)Registry nor Jenkins are to blame here ;)
Maybe the server Jenkins is running on only needs a PHP update...
On a testing environment running PHP 5.2.9 I got:
<test><false></false></test>
I am going to reopen this as it seems the correct fix for current PHP versions
Status | Closed | ⇒ | New |
On further investigation, I did a custom compile of PHP 5.2.9 and got the opposite result :(
So it seems it's not only the PHP version but also how it is compiled.
As a band aid, and to make the tests run on both systems, a PHP version check could be used. Would that be an option ?
Otherwise I'm lost.
Labels |
Added:
?
|
Hrrm.. here's another attempt:
// Check for different PHP behavior of displaying boolean false in XML.
$checkFalse = '<check/>' == simplexml_load_string('<test/>')->addChild('check', false)->asXML()
? '/>'
: '></node>';
that should be system independent
Don't see why not. Could you send the same for the Framework?
Status | New | ⇒ | Closed |
Closed_Date | 2013-11-25 13:51:10 | ⇒ | 2013-11-28 17:21:16 |
That should be doable ;)
That'll fix the test in some environments, but will cause failures on others (i.e. our Jenkins server). I've been getting that failure locally for a while (both here and in the Framework) and it only started failing on Travis with their last update. A part of me thinks the right fix is to figure it out in the JRegistry class, but it's not something any of us has really had interest in digging into.