代码同步
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
"php": ">5.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8.35|^5.4.3",
|
||||
"phpunit/phpunit": "*",
|
||||
"symfony/var-dumper": "*"
|
||||
},
|
||||
"autoload": {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Unit">
|
||||
<directory suffix="Test.php">./tests/Unit</directory>
|
||||
<directory suffix="Test.php">./tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
|
||||
@@ -8,14 +8,14 @@ class XML
|
||||
{
|
||||
$res = self::parse($xmlStr);
|
||||
if ($response === null) {
|
||||
return $ref;
|
||||
return $res;
|
||||
} else {
|
||||
if (\is_string($response)) {
|
||||
$response = new $response();
|
||||
}
|
||||
$prop = get_object_vars($response);
|
||||
$target = [];
|
||||
|
||||
|
||||
foreach ($res as $k => $v) {
|
||||
if (isset($prop[$k])) {
|
||||
$target[$k] = $v;
|
||||
@@ -45,7 +45,9 @@ class XML
|
||||
|
||||
private static function parse($xml)
|
||||
{
|
||||
libxml_disable_entity_loader(true);
|
||||
if (\PHP_VERSION_ID < 80000) {
|
||||
libxml_disable_entity_loader(true);
|
||||
}
|
||||
|
||||
return json_decode(
|
||||
json_encode(
|
||||
|
||||
@@ -23,13 +23,13 @@ class RpcUtilsTest extends TestCase
|
||||
$name = $res['name'];
|
||||
$value = $res['value'];
|
||||
$this->assertEquals('test', $name);
|
||||
$this->assertEquals('1', $value);
|
||||
$this->assertEquals(1, $value);
|
||||
|
||||
$res = XML::parseXml($this->xmlStr, null);
|
||||
$name = $res['name'];
|
||||
$value = $res['value'];
|
||||
$this->assertEquals('test', $name);
|
||||
$this->assertEquals('1', $value);
|
||||
$this->assertEquals(1, $value);
|
||||
}
|
||||
|
||||
public function testArrayToXML()
|
||||
|
||||
Reference in New Issue
Block a user