? Success

User tests: Successful: Unsuccessful:

avatar elkuku
elkuku
25 Nov 2013

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>
 '

Ref: http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=32813&start=0

avatar elkuku elkuku - open - 25 Nov 2013
avatar mbabker
mbabker - comment - 25 Nov 2013

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.

avatar dbhurley
dbhurley - comment - 25 Nov 2013

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:

  #2596

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

avatar elkuku
elkuku - comment - 25 Nov 2013

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 :(

avatar elkuku elkuku - change - 25 Nov 2013
The description was changed
Title
Fix a failing unit test
Fix a failing unit test [#32813]
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 @@ @@ '&lt;?xml version="1.0"?&gt; -&lt;registry&gt;&lt;node name="foo" type="string"&gt;bar&lt;/node&gt;&lt;node name="quoted" type="string"&gt;"stringwithquotes"&lt;/node&gt;&lt;node name="booleantrue" type="boolean"&gt;1&lt;/node&gt;&lt;node name="booleanfalse" type="boolean"&gt;&lt;/node&gt;&lt;node name="numericint" type="integer"&gt;42&lt;/node&gt;&lt;node name="numericfloat" type="double"&gt;3.1415&lt;/node&gt;&lt;node name="section" type="object"&gt;&lt;node name="key" type="string"&gt;value&lt;/node&gt;&lt;/node&gt;&lt;node name="array" type="array"&gt;&lt;node name="nestedarray" type="array"&gt;&lt;node name="test1" type="string"&gt;value1&lt;/node&gt;&lt;/node&gt;&lt;/node&gt;&lt;/registry&gt; +&lt;registry&gt;&lt;node name="foo" type="string"&gt;bar&lt;/node&gt;&lt;node name="quoted" type="string"&gt;"stringwithquotes"&lt;/node&gt;&lt;node name="booleantrue" type="boolean"&gt;1&lt;/node&gt;&lt;node name="booleanfalse" type="boolean"/&gt;&lt;node name="numericint" type="integer"&gt;42&lt;/node&gt;&lt;node name="numericfloat" type="double"&gt;3.1415&lt;/node&gt;&lt;node name="section" type="object"&gt;&lt;node name="key" type="string"&gt;value&lt;/node&gt;&lt;/node&gt;&lt;node name="array" type="array"&gt;&lt;node name="nestedarray" type="array"&gt;&lt;node name="test1" type="string"&gt;value1&lt;/node&gt;&lt;/node&gt;&lt;/node&gt;&lt;/registry&gt; ' </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 @@ @@ '&lt;?xml version="1.0"?&gt; -&lt;registry&gt;&lt;node name="foo" type="string"&gt;bar&lt;/node&gt;&lt;node name="quoted" type="string"&gt;"stringwithquotes"&lt;/node&gt;&lt;node name="booleantrue" type="boolean"&gt;1&lt;/node&gt;&lt;node name="booleanfalse" type="boolean"&gt;&lt;/node&gt;&lt;node name="numericint" type="integer"&gt;42&lt;/node&gt;&lt;node name="numericfloat" type="double"&gt;3.1415&lt;/node&gt;&lt;node name="section" type="object"&gt;&lt;node name="key" type="string"&gt;value&lt;/node&gt;&lt;/node&gt;&lt;node name="array" type="array"&gt;&lt;node name="nestedarray" type="array"&gt;&lt;node name="test1" type="string"&gt;value1&lt;/node&gt;&lt;/node&gt;&lt;/node&gt;&lt;/registry&gt; +&lt;registry&gt;&lt;node name="foo" type="string"&gt;bar&lt;/node&gt;&lt;node name="quoted" type="string"&gt;"stringwithquotes"&lt;/node&gt;&lt;node name="booleantrue" type="boolean"&gt;1&lt;/node&gt;&lt;node name="booleanfalse" type="boolean"/&gt;&lt;node name="numericint" type="integer"&gt;42&lt;/node&gt;&lt;node name="numericfloat" type="double"&gt;3.1415&lt;/node&gt;&lt;node name="section" type="object"&gt;&lt;node name="key" type="string"&gt;value&lt;/node&gt;&lt;/node&gt;&lt;node name="array" type="array"&gt;&lt;node name="nestedarray" type="array"&gt;&lt;node name="test1" type="string"&gt;value1&lt;/node&gt;&lt;/node&gt;&lt;/node&gt;&lt;/registry&gt; ' </code></pre> <p>Ref: <a href="http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&amp;tracker_item_id=32813&amp;start=0">http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&amp;tracker_item_id=32813&amp;start=0</a></p>
Status New Closed
Closed_Date 0000-00-00 00:00:00 2013-11-25 13:51:10
Labels Added: ?
avatar elkuku elkuku - close - 25 Nov 2013
avatar mbabker
mbabker - comment - 25 Nov 2013

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.

avatar elkuku
elkuku - comment - 25 Nov 2013

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...

avatar elkuku
elkuku - comment - 25 Nov 2013

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 :wink:

avatar elkuku elkuku - change - 25 Nov 2013
Status Closed New
avatar elkuku elkuku - reopen - 25 Nov 2013
avatar elkuku
elkuku - comment - 27 Nov 2013

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.

avatar elkuku elkuku - change - 28 Nov 2013
Labels Added: ?
avatar elkuku
elkuku - comment - 28 Nov 2013

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 :wink:

avatar mbabker
mbabker - comment - 28 Nov 2013

Don't see why not. Could you send the same for the Framework?

avatar mbabker mbabker - change - 28 Nov 2013
Status New Closed
Closed_Date 2013-11-25 13:51:10 2013-11-28 17:21:16
avatar mbabker mbabker - close - 28 Nov 2013
avatar elkuku
elkuku - comment - 28 Nov 2013

That should be doable ;)

Add a Comment

Login with GitHub to post a comment