diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..0d59d26 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +* text=auto + +/tests +/.gitattributes export-ignore +/.gitignore export-ignore +/phpunit.xml export-ignore diff --git a/README.md b/README.md index d3207ce..54fe897 100644 --- a/README.md +++ b/README.md @@ -50,8 +50,8 @@ This will result in the following. Reference ---- More complete references can be found here - http://www.lalit.org/lab/convert-xml-to-array-in-php-xml2array/ - http://www.lalit.org/lab/convert-php-array-to-xml-with-attributes/ + http://www.lalit.org/lab/convert-xml-to-array-in-php-xml2array/ + http://www.lalit.org/lab/convert-php-array-to-xml-with-attributes/ ## Changelog diff --git a/composer.json b/composer.json index 7471231..74c50aa 100644 --- a/composer.json +++ b/composer.json @@ -1,33 +1,42 @@ { - "name": "openlss/lib-array2xml" - ,"homepage": "https://www.nullivex.com" - ,"description": "Array2XML conversion library credit to lalit.org" - ,"license": "Apache-2.0" - ,"type": "library" - ,"keywords": [ - "array" - ,"xml" - ,"xml conversion" - ,"array conversion" - ] - ,"authors": [ - { - "name": "Bryan Tong" - ,"email": "bryan@nullivex.com" - ,"homepage": "https://www.nullivex.com" - } - ,{ - "name": "Tony Butler" - ,"email": "spudz76@gmail.com" - ,"homepage": "https://www.nullivex.com" - } - ] - ,"require": { - "php": ">=5.3.2" - } - ,"autoload": { - "psr-0": { - "LSS": "" - } - } + "name": "openlss/lib-array2xml", + "description": "Array2XML conversion library credit to lalit.org", + "type": "library", + "keywords": [ + "array", + "array conversion", + "xml", + "xml conversion" + ], + "homepage": "https://www.nullivex.com", + "license": "Apache-2.0", + "authors": [ + { + "name": "Bryan Tong", + "email": "bryan@nullivex.com", + "homepage": "https://www.nullivex.com" + }, + { + "name": "Tony Butler", + "email": "spudz76@gmail.com", + "homepage": "https://www.nullivex.com" + } + ], + "require": { + "php": ">=5.3.2", + "ext-dom": "*" + }, + "require-dev": { + "phpunit/phpunit": "~6.0 || ~7.0" + }, + "autoload": { + "psr-4": { + "LSS\\": "LSS/" + } + }, + "autoload-dev": { + "psr-4": { + "LSS_tests\\": "tests/" + } + } } diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..e43792f --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,21 @@ + + + + tests + + + + ./LSS/ + + + diff --git a/tests/Array2XMLTest.php b/tests/Array2XMLTest.php new file mode 100644 index 0000000..8b69e8b --- /dev/null +++ b/tests/Array2XMLTest.php @@ -0,0 +1,36 @@ + 'A title', + 'body' => array( + '@xml' => '

The content for the news item

', + ), + ); + + // Use the Array2XML object to transform it. + $xml = \LSS\Array2XML::createXML('news', $array); + + $expected = ' + + A title + + + +

The content for the news item

+ + + +
+'; + + static::assertSame($expected, $xml->saveXML()); + } +} diff --git a/tests/XML2ArrayTest.php b/tests/XML2ArrayTest.php new file mode 100644 index 0000000..ce70d79 --- /dev/null +++ b/tests/XML2ArrayTest.php @@ -0,0 +1,41 @@ + + + A title + + + +

The content for the news item

+ + + +
+'; + + $array = \LSS\XML2Array::createArray($xml); + + $expected = array( + 'news' => array( + 'title' => 'A title', + 'body' => array( + 'html' => array( + 'body' => array( + 'p' => 'The content for the news item', + ), + ), + ), + ), + ); + + static::assertSame($expected, $array); + } +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..48971ba --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,6 @@ +