Skip to content

Commit 9c3a278

Browse files
committed
Fix tests
1 parent 7fc1c92 commit 9c3a278

File tree

11 files changed

+19
-18
lines changed

11 files changed

+19
-18
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ $array = [
508508
509509
$xml = array_to_xml($array, 'Guys');
510510
511-
// <?xml version="1.0"?>
511+
// <?xml version="1.0" encoding="utf-8"?>
512512
// <Guys>
513513
// <Good_guy Rating="100">
514514
// <name>Luke Skywalker</name>

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"symfony/finder": "^5.1",
2323
"symfony/process": "^5.1",
2424
"symfony/var-dumper": "^5.1",
25-
"spatie/array-to-xml": "^2.7"
25+
"spatie/array-to-xml": "^3.0"
2626
},
2727
"require-dev": {
2828
"phpunit/phpunit": "^9.1",

src/debug.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function minimized_backtrace_as_string()
2828

2929
return collect($backtrace)
3030
->map(function (string $line) {
31-
return preg_match('/(#\d+) .*? called at \[(.*?)]/', $line, $matches)
31+
return preg_match('/(#\d+) (.*?):/', $line, $matches)
3232
? "{$matches[1]} {$matches[2]}"
3333
: false;
3434
})

src/xml.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ function xml_to_array($xml)
2626
* @param array $array
2727
* @param string $rootElement
2828
* @param bool $replaceSpacesByUnderscoresInKeyNames
29+
* @param string $xmlEncoding
2930
* @return string
3031
*/
31-
function array_to_xml(array $array, string $rootElement = '', bool $replaceSpacesByUnderscoresInKeyNames = true)
32+
function array_to_xml(array $array, string $rootElement = '', bool $replaceSpacesByUnderscoresInKeyNames = true, string $xmlEncoding = 'utf-8')
3233
{
33-
return ArrayToXml::convert($array, $rootElement, $replaceSpacesByUnderscoresInKeyNames);
34+
return ArrayToXml::convert($array, $rootElement, $replaceSpacesByUnderscoresInKeyNames, $xmlEncoding);
3435
}
3536
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#0 backtrace_as_string\(\) called at \[\/.*?\/tests\/debug\/BacktraceAsStringTest\.php:35\]
2-
#1 Illuminated\\Helpers\\Tests\\Debug\\BacktraceAsStringTest->anotherExtraMethod\(\) called at \[\/.*?\/tests\/debug\/BacktraceAsStringTest\.php:25\]
3-
#2 Illuminated\\Helpers\\Tests\\Debug\\BacktraceAsStringTest->getBacktrace\(\) called at \[\/.*?\/tests\/debug\/BacktraceAsStringTest\.php:13\]
4-
#3 Illuminated\\Helpers\\Tests\\Debug\\BacktraceAsStringTest->it_returns_backtrace_as_string_without_args\(\)
1+
#0 \/.*?\/tests\/debug\/BacktraceAsStringTest\.php\(35\): backtrace_as_string\(\)
2+
#1 \/.*?\/tests\/debug\/BacktraceAsStringTest\.php\(25\): Illuminated\\Helpers\\Tests\\Debug\\BacktraceAsStringTest->anotherExtraMethod\(\)
3+
#2 \/.*?\/tests\/debug\/BacktraceAsStringTest\.php\(13\): Illuminated\\Helpers\\Tests\\Debug\\BacktraceAsStringTest->getBacktrace\(\)
4+
#3 .*?: Illuminated\\Helpers\\Tests\\Debug\\BacktraceAsStringTest->it_returns_backtrace_as_string_without_args\(\)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#0 \/.*?\/src\/debug\.php:27
2-
#1 \/.*?\/tests\/debug\/MinimizedBacktraceAsStringTest\.php:35
3-
#2 \/.*?\/tests\/debug\/MinimizedBacktraceAsStringTest\.php:25
4-
#3 \/.*?\/tests\/debug\/MinimizedBacktraceAsStringTest\.php:13
1+
#0 \/.*?\/src\/debug\.php\(27\)
2+
#1 \/.*?\/tests\/debug\/MinimizedBacktraceAsStringTest\.php\(35\)
3+
#2 \/.*?\/tests\/debug\/MinimizedBacktraceAsStringTest\.php\(25\)
4+
#3 \/.*?\/tests\/debug\/MinimizedBacktraceAsStringTest\.php\(13\)
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<?xml version="1.0"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root><task priority="low"><to>John</to><from>Jane</from><title>Go to the shop</title></task><task priority="medium"><to>John</to><from>Paul</from><title>Finish the report</title></task><task priority="high"><to>Jane</to><from>Jeff</from><title>Clean the house</title></task></root>
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<?xml version="1.0"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<tasks><task><to>John</to><from>Jane</from><title>Go to the shop</title></task><task><to>John</to><from>Paul</from><title>Finish the report</title></task><task><to>Jane</to><from>Jeff</from><title>Clean the house</title></task></tasks>
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<?xml version="1.0"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root><task><to_who>John</to_who><from_who>Jane</from_who><title>Go to the shop</title></task><task><to_who>John</to_who><from_who>Paul</from_who><title>Finish the report</title></task><task><to_who>Jane</to_who><from_who>Jeff</from_who><title>Clean the house</title></task></root>
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<?xml version="1.0"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root><task><to>John</to><from>Jane</from><title>Go to the shop</title></task><task><to>John</to><from>Paul</from><title>Finish the report</title></task><task><to>Jane</to><from>Jeff</from><title>Clean the house</title></task></root>

tests/xml/XmlToArrayTest/example.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<?xml version="1.0"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root><tasks><task priority="low"><to>John</to><from>Jane</from><title>Go to the shop</title></task><task priority="medium"><to>John</to><from>Paul</from><title>Finish the report</title></task><task priority="high"><to>Jane</to><from>Jeff</from><title>Clean the house</title></task></tasks></root>

0 commit comments

Comments
 (0)