Codeception / module-rest

REST module for Codeception
MIT License
53 stars 27 forks source link

increase xpath support #88

Closed pamoller closed 2 years ago

pamoller commented 2 years ago

Transforming JSON documents to XML document to use with XPath causes a loss of information, cause the string operator translates true and null to ''

 $subNode->nodeValue = htmlspecialchars((string)$value);

So boolean values can't be found by an expression like:

$I->seeResponseJsonXpathEvaluatesTo("//boolean[text() = 'true']");

Using a more elaborated transformation, https://tqdev.com/2017-converting-json-to-xml-in-javascript-and-php, keeps all informations:

{"boolean":true, "number": -1.2780E+2, "null": null, "string": "i'am a sentence"}

transforms to now

<root>
   <boolean type="boolean">true</boolean>
   <number type ="number">-127.8</number>
   <null type="null"></null>
   <string type="string">i'am a sentence</string>
</root>

so see now: JsonArrayTest.php

pamoller commented 2 years ago

I hope, this fits the needs :)

Naktibalda commented 2 years ago

Released as 3.3.0