diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..a7c44dd
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,15 @@
+root = true
+
+[*]
+charset = utf-8
+indent_size = 4
+indent_style = space
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.md]
+trim_trailing_whitespace = false
+
+[*.{yml,yaml}]
+indent_size = 2
diff --git a/.gitattributes b/.gitattributes
index adcad46..946ed92 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,11 +1,13 @@
-
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
# Ignore all test and documentation with "export-ignore".
/.gitattributes export-ignore
/.gitignore export-ignore
-/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
-/.scrutinizer.yml export-ignore
-/tests export-ignore
\ No newline at end of file
+/tests export-ignore
+/.editorconfig export-ignore
+/.php_cs export-ignore
+/.github export-ignore
+/psalm.xml export-ignore
+
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
deleted file mode 100644
index b4ae1c4..0000000
--- a/.github/CONTRIBUTING.md
+++ /dev/null
@@ -1,55 +0,0 @@
-# Contributing
-
-Contributions are **welcome** and will be fully **credited**.
-
-Please read and understand the contribution guide before creating an issue or pull request.
-
-## Etiquette
-
-This project is open source, and as such, the maintainers give their free time to build and maintain the source code
-held within. They make the code freely available in the hope that it will be of use to other developers. It would be
-extremely unfair for them to suffer abuse or anger for their hard work.
-
-Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
-world that developers are civilized and selfless people.
-
-It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
-quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
-
-## Viability
-
-When requesting or submitting new features, first consider whether it might be useful to others. Open
-source projects are used by many developers, who may have entirely different needs to your own. Think about
-whether or not your feature is likely to be used by other users of the project.
-
-## Procedure
-
-Before filing an issue:
-
-- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
-- Check to make sure your feature suggestion isn't already present within the project.
-- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
-- Check the pull requests tab to ensure that the feature isn't already in progress.
-
-Before submitting a pull request:
-
-- Check the codebase to ensure that your feature doesn't already exist.
-- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
-
-## Requirements
-
-If the project maintainer has any additional requirements, you will find them listed here.
-
-- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).
-
-- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
-
-- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
-
-- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
-
-- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
-
-- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
-
-**Happy coding**!
diff --git a/.github/SECURITY.md b/.github/SECURITY.md
deleted file mode 100644
index ca91343..0000000
--- a/.github/SECURITY.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Security Policy
-
-If you discover any security related issues, please email freek@spatie.be instead of using the issue tracker.
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..a76dd83
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,8 @@
+version: 2
+
+updates:
+
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "weekly"
diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml
new file mode 100644
index 0000000..78e5cd2
--- /dev/null
+++ b/.github/workflows/dependabot-auto-merge.yml
@@ -0,0 +1,40 @@
+name: dependabot-auto-merge
+on: pull_request_target
+
+permissions:
+ pull-requests: write
+ contents: write
+
+jobs:
+ dependabot:
+ runs-on: ubuntu-latest
+ if: ${{ github.actor == 'dependabot[bot]' }}
+ steps:
+
+ - name: Dependabot metadata
+ id: metadata
+ uses: dependabot/fetch-metadata@v1.3.5
+ with:
+ github-token: "${{ secrets.GITHUB_TOKEN }}"
+ compat-lookup: true
+
+ - name: Auto-merge Dependabot PRs for semver-minor updates
+ if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}}
+ run: gh pr merge --auto --merge "$PR_URL"
+ env:
+ PR_URL: ${{github.event.pull_request.html_url}}
+ GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
+
+ - name: Auto-merge Dependabot PRs for semver-patch updates
+ if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
+ run: gh pr merge --auto --merge "$PR_URL"
+ env:
+ PR_URL: ${{github.event.pull_request.html_url}}
+ GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
+
+ - name: Auto-merge Dependabot PRs for Action major versions when compatibility is higher than 90%
+ if: ${{steps.metadata.outputs.package-ecosystem == 'github_actions' && steps.metadata.outputs.update-type == 'version-update:semver-major' && steps.metadata.outputs.compatibility-score >= 90}}
+ run: gh pr merge --auto --merge "$PR_URL"
+ env:
+ PR_URL: ${{github.event.pull_request.html_url}}
+ GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml
index 4cf285f..dac0c37 100644
--- a/.github/workflows/php-cs-fixer.yml
+++ b/.github/workflows/php-cs-fixer.yml
@@ -8,14 +8,14 @@ jobs:
steps:
- name: Checkout code
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
- args: --config=.php_cs.dist --allow-risky=yes
+ args: --config=.php-cs-fixer.dist.php
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml
index 77743d6..38f51e9 100644
--- a/.github/workflows/run-tests.yml
+++ b/.github/workflows/run-tests.yml
@@ -9,14 +9,14 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
- php: [8.0, 7.4]
+ php: [8.0, 8.1, 8.2, 7.4]
stability: [prefer-lowest, prefer-stable]
name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}
steps:
- name: Checkout code
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
@@ -24,14 +24,13 @@ jobs:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: none
-
+
- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install dependencies
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Execute tests
- run: vendor/bin/phpunit
+ run: vendor/bin/pest
diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yml
new file mode 100644
index 0000000..0f38002
--- /dev/null
+++ b/.github/workflows/update-changelog.yml
@@ -0,0 +1,28 @@
+name: "Update Changelog"
+
+on:
+ release:
+ types: [released]
+
+jobs:
+ update:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v3
+ with:
+ ref: main
+
+ - name: Update Changelog
+ uses: stefanzweifel/changelog-updater-action@v1
+ with:
+ latest-version: ${{ github.event.release.name }}
+ release-notes: ${{ github.event.release.body }}
+
+ - name: Commit updated CHANGELOG
+ uses: stefanzweifel/git-auto-commit-action@v4
+ with:
+ branch: v2
+ commit_message: Update CHANGELOG
+ file_pattern: CHANGELOG.md
diff --git a/.gitignore b/.gitignore
index ea85fc4..d003269 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,12 @@
+.idea
+.php_cs
+.php_cs.cache
+.php-cs-fixer.cache
+.phpunit.result.cache
build
composer.lock
+coverage
docs
+phpunit.xml
+psalm.xml
vendor
-.php_cs.cache
\ No newline at end of file
diff --git a/.php_cs.dist b/.php-cs-fixer.dist.php
similarity index 75%
rename from .php_cs.dist
rename to .php-cs-fixer.dist.php
index ac127a7..3600d2d 100644
--- a/.php_cs.dist
+++ b/.php-cs-fixer.dist.php
@@ -1,6 +1,9 @@
in([
__DIR__ . '/src',
__DIR__ . '/tests',
@@ -9,15 +12,16 @@
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);
+$config = new Config();
-return PhpCsFixer\Config::create()
+return $config->setFinder($finder)
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
- 'ordered_imports' => ['sortAlgorithm' => 'alpha'],
+ 'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
- 'trailing_comma_in_multiline_array' => true,
+ 'trailing_comma_in_multiline' => ['elements' => ['arrays']],
'phpdoc_scalar' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
@@ -28,7 +32,7 @@
'phpdoc_var_without_name' => true,
'class_attributes_separation' => [
'elements' => [
- 'method',
+ 'method' => 'one',
],
],
'method_argument_space' => [
@@ -37,4 +41,4 @@
],
'single_trait_insert_per_statement' => true,
])
- ->setFinder($finder);
+ ->setRiskyAllowed(true);
diff --git a/README.md b/README.md
index f581303..5d4769a 100755
--- a/README.md
+++ b/README.md
@@ -1,3 +1,6 @@
+
+[](https://supportukrainenow.org)
+
# Convert an array to xml
[![Latest Version](https://img.shields.io/github/release/spatie/array-to-xml.svg?style=flat-square)](https://github.com/spatie/array-to-xml/releases)
@@ -360,7 +363,7 @@ This will result in:
estacet
first-tag
- second-tag
+ second-tag
@@ -477,23 +480,43 @@ This will result in:
soap:value
```
+### Adding processing instructions
+
+Call `$arrayToXml->addProcessingInstruction($target, $data)` method on ArrayToXml object to prepend a processing instruction before the root element.
+
+Example:
+
+```php
+$arrayToXml = new ArrayToXml($array);
+$arrayToXml->addProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="base.xsl"');
+$result = $arrayToXml->toXml();
+```
+
+This will result in:
+
+```xml
+
+
+Luke SkywalkerLightsaberSauronEvil Eye
+```
+
## Testing
```bash
vendor/bin/phpunit
```
-### Changelog
+## Changelog
-Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
+Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
-Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
+Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.
-## Security
+## Security Vulnerabilities
-If you discover any security related issues, please email freek@spatie.be instead of using the issue tracker.
+Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Postcardware
diff --git a/composer.json b/composer.json
index 90520ab..9f3b0bf 100755
--- a/composer.json
+++ b/composer.json
@@ -23,7 +23,8 @@
"require-dev": {
"phpunit/phpunit" : "^9.0",
"mockery/mockery": "^1.2",
- "spatie/phpunit-snapshot-assertions": "^4.2"
+ "pestphp/pest": "^1.21",
+ "spatie/pest-plugin-snapshots": "^1.1"
},
"autoload": {
"psr-4": {
@@ -34,5 +35,13 @@
"psr-4": {
"Spatie\\ArrayToXml\\Test\\": "tests"
}
+ },
+ "scripts": {
+ "test": "vendor/bin/pest"
+ },
+ "config": {
+ "allow-plugins": {
+ "pestphp/pest-plugin": true
+ }
}
}
diff --git a/phpunit.xml b/phpunit.xml
deleted file mode 100644
index b2daa31..0000000
--- a/phpunit.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
- src/
-
-
-
-
- ./tests/
-
-
-
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
new file mode 100644
index 0000000..94c0e39
--- /dev/null
+++ b/phpunit.xml.dist
@@ -0,0 +1,39 @@
+
+
+
+
+ tests
+
+
+
+
+ ./src
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ArrayToXml.php b/src/ArrayToXml.php
index 66eb49e..8eba571 100644
--- a/src/ArrayToXml.php
+++ b/src/ArrayToXml.php
@@ -26,7 +26,7 @@ public function __construct(
$domProperties = [],
$xmlStandalone = null
) {
- $this->document = new DOMDocument($xmlVersion, $xmlEncoding);
+ $this->document = new DOMDocument($xmlVersion, $xmlEncoding ?? '');
if (! is_null($xmlStandalone)) {
$this->document->xmlStandalone = $xmlStandalone;
@@ -38,7 +38,7 @@ public function __construct(
$this->replaceSpacesByUnderScoresInKeyNames = $replaceSpacesByUnderScoresInKeyNames;
- if ($this->isArrayAllKeySequential($array) && ! empty($array)) {
+ if (! empty($array) && $this->isArrayAllKeySequential($array)) {
throw new DOMException('Invalid Character Error');
}
@@ -78,11 +78,9 @@ public static function convert(
public function toXml(): string
{
- if ($this->addXmlDeclaration === false) {
- return $this->document->saveXml($this->document->documentElement);
- }
-
- return $this->document->saveXML();
+ return $this->addXmlDeclaration
+ ? $this->document->saveXML()
+ : $this->document->saveXml($this->document->documentElement);
}
public function toDom(): DOMDocument
@@ -94,7 +92,7 @@ protected function ensureValidDomProperties(array $domProperties)
{
foreach ($domProperties as $key => $value) {
if (! property_exists($this->document, $key)) {
- throw new Exception($key.' is not a valid property of DOMDocument');
+ throw new Exception("{$key} is not a valid property of DOMDocument");
}
}
}
@@ -125,12 +123,25 @@ public function dropXmlDeclaration()
return $this;
}
+ public function addProcessingInstruction($target, $data)
+ {
+ $elements = $this->document->getElementsByTagName('*');
+
+ $rootElement = $elements->count() > 0 ? $elements->item(0) : null;
+
+ $processingInstruction = $this->document->createProcessingInstruction($target, $data);
+
+ $this->document->insertBefore($processingInstruction, $rootElement);
+
+ return $this;
+ }
+
private function convertElement(DOMElement $element, $value)
{
$sequential = $this->isArrayAllKeySequential($value);
if (! is_array($value)) {
- $value = htmlspecialchars($value);
+ $value = htmlspecialchars($value ?? '');
$value = $this->removeControlCharacters($value);
@@ -205,7 +216,7 @@ protected function addSequentialNode(DOMElement $element, $value)
return;
}
- $child = new DOMElement($element->tagName);
+ $child = $this->document->createElement($element->tagName);
$child->nodeValue = htmlspecialchars($value);
$element->parentNode->appendChild($child);
}
diff --git a/tests/ArrayToXmlTest.php b/tests/ArrayToXmlTest.php
index 59edb50..ef2640e 100644
--- a/tests/ArrayToXmlTest.php
+++ b/tests/ArrayToXmlTest.php
@@ -1,410 +1,314 @@
testArray = [
- 'Good guy' => [
-
- 'name' => 'Luke Skywalker',
- 'weapon' => 'Lightsaber',
-
+uses(MatchesSnapshots::class);
+
+beforeEach(function () {
+ $this->testArray = [
+ 'Good guy' => [
+
+ 'name' => 'Luke Skywalker',
+ 'weapon' => 'Lightsaber',
+
+ ],
+ 'Bad guy' => [
+ 'name' => 'Sauron',
+ 'weapon' => 'Evil Eye',
+
+ ],
+ ];
+});
+
+it('can convert an array to xml', function () {
+ assertMatchesXmlSnapshot(ArrayToXml::convert($this->testArray));
+});
+
+it('can handle an empty array', function () {
+ assertMatchesXmlSnapshot(ArrayToXml::convert([]));
+});
+
+it('can receive name for the root element', function () {
+ assertMatchesXmlSnapshot(ArrayToXml::convert([], 'helloyouluckpeople'));
+});
+
+it('can receive name from array for the root element', function () {
+ assertMatchesXmlSnapshot(ArrayToXml::convert([], [
+ 'rootElementName' => 'helloyouluckpeople',
+ ]));
+});
+
+it('can convert attributes to xml for the root element', function () {
+ assertMatchesXmlSnapshot(ArrayToXml::convert([], [
+ '_attributes' => [
+ 'xmlns' => 'https://github.com/spatie/array-to-xml',
+ ],
+ ]));
+});
+
+test('and root element attributes can also be set in SimpleXMLElement style', function () {
+ assertMatchesXmlSnapshot(ArrayToXml::convert([], [
+ '@attributes' => [
+ 'xmlns' => 'https://github.com/spatie/array-to-xml',
+ ],
+ ]));
+});
+
+it('throws an exception when converting an array with no keys', function () {
+ ArrayToXml::convert(['one', 'two', 'three']);
+})->throws(DOMException::class);
+
+it('throws an exception when converting an array with invalid characters key names', function () {
+ echo ArrayToXml::convert(['tom & jerry' => 'cartoon characters'], '', false);
+})->throws(DOMException::class);
+
+it('will raise an exception when spaces should not be replaced and a key contains a space', function () {
+ ArrayToXml::convert($this->testArray, '', false);
+})->throws(DOMException::class);
+
+it('can handle values as basic collection', function () {
+ assertMatchesXmlSnapshot(ArrayToXml::convert([
+ 'user' => ['one', 'two', 'three'],
+ ]));
+});
+
+it('can handle zero values in beginning of basic collection', function () {
+ assertMatchesXmlSnapshot(ArrayToXml::convert([
+ 'user' => ['0', '1', '0'],
+ ]));
+});
+
+it('can handle values with namespace as basic collection', function () {
+ $root = [
+ 'rootElementName' => 'root',
+ '_attributes' => [
+ 'xmlns:ns1' => 'https://github.com/spatie/array-to-xml',
+ ],
+ ];
+
+ assertMatchesXmlSnapshot(ArrayToXml::convert([
+ 'ns1:user' => ['one', 'two', 'three'],
+ ], $root));
+});
+
+it('accepts an xml encoding type', function () {
+ assertMatchesXmlSnapshot(ArrayToXml::convert([], '', false, 'UTF-8'));
+});
+
+it('accepts an xml version', function () {
+ assertMatchesSnapshot(ArrayToXml::convert([], '', false, null, '1.1'));
+});
+
+it('accepts an xml standalone value', function () {
+ assertMatchesXmlSnapshot(ArrayToXml::convert([], '', false, null, '1.0', [], false));
+});
+
+it('can handle values as collection', function () {
+ assertMatchesXmlSnapshot(ArrayToXml::convert([
+ 'user' => [
+ [
+ 'name' => 'een',
+ 'age' => 10,
],
- 'Bad guy' => [
- 'name' => 'Sauron',
- 'weapon' => 'Evil Eye',
-
+ [
+ 'name' => 'twee',
+ 'age' => 12,
],
- ];
- }
-
- /** @test */
- public function it_can_convert_an_array_to_xml()
- {
- $this->assertMatchesXmlSnapshot(ArrayToXml::convert($this->testArray));
- }
-
- /** @test */
- public function it_can_handle_an_empty_array()
- {
- $this->assertMatchesXmlSnapshot(ArrayToXml::convert([]));
- }
-
- /** @test */
- public function it_can_receive_name_for_the_root_element()
- {
- $this->assertMatchesXmlSnapshot(ArrayToXml::convert([], 'helloyouluckpeople'));
- }
-
- /** @test */
- public function it_can_receive_name_from_array_for_the_root_element()
- {
- $this->assertMatchesXmlSnapshot(ArrayToXml::convert([], [
- 'rootElementName' => 'helloyouluckpeople',
- ]));
- }
-
- /** @test */
- public function it_can_convert_attributes_to_xml_for_the_root_element()
- {
- $this->assertMatchesXmlSnapshot(ArrayToXml::convert([], [
- '_attributes' => [
- 'xmlns' => 'https://github.com/spatie/array-to-xml',
- ],
- ]));
- }
-
- /** @test */
- public function and_root_element_attributes_can_also_be_set_in_simplexmlelement_style()
- {
- $this->assertMatchesXmlSnapshot(ArrayToXml::convert([], [
- '@attributes' => [
- 'xmlns' => 'https://github.com/spatie/array-to-xml',
- ],
- ]));
- }
-
- /** @test */
- public function it_throws_an_exception_when_converting_an_array_with_no_keys()
- {
- $this->expectException('DOMException');
-
- ArrayToXml::convert(['one', 'two', 'three']);
- }
-
- /** @test */
- public function it_throws_an_exception_when_converting_an_array_with_invalid_characters_key_names()
- {
- $this->expectException('DOMException');
-
- echo ArrayToXml::convert(['tom & jerry' => 'cartoon characters'], '', false);
- }
-
- /** @test */
- public function it_will_raise_an_exception_when_spaces_should_not_be_replaced_and_a_key_contains_a_space()
- {
- $this->expectException('DOMException');
-
- ArrayToXml::convert($this->testArray, '', false);
- }
-
- /** @test */
- public function it_can_handle_values_as_basic_collection()
- {
- $this->assertMatchesXmlSnapshot(ArrayToXml::convert([
- 'user' => ['one', 'two', 'three'],
- ]));
- }
-
- /** @test */
- public function it_can_handle_zero_values_in_beginning_of_basic_collection()
- {
- $this->assertMatchesXmlSnapshot(ArrayToXml::convert([
- 'user' => ['0', '1', '0'],
- ]));
- }
-
- /** @test */
- public function it_accepts_an_xml_encoding_type()
- {
- $this->assertMatchesXmlSnapshot(ArrayToXml::convert([], '', false, 'UTF-8'));
- }
-
- /** @test */
- public function it_accepts_an_xml_version()
- {
- $this->assertMatchesSnapshot(ArrayToXml::convert([], '', false, null, '1.1'));
- }
-
- /** @test */
- public function it_accepts_an_xml_standalone_value()
- {
- $this->assertMatchesSnapshot(ArrayToXml::convert([], '', false, null, '1.0', [], false));
- }
-
- /** @test */
- public function it_can_handle_values_as_collection()
- {
- $this->assertMatchesXmlSnapshot(ArrayToXml::convert([
- 'user' => [
- [
+ ],
+ ]));
+});
+
+it('can handle values with special characters', function () {
+ assertMatchesXmlSnapshot(ArrayToXml::convert(['name' => 'this & that']));
+});
+
+it('can handle values with special control characters', function () {
+ assertMatchesXmlSnapshot(ArrayToXml::convert(['name' => "i want tothis and \x03 that"]));
+});
+
+it('can group by values when values are in a numeric array', function () {
+ assertMatchesXmlSnapshot(ArrayToXml::convert(['user' => ['foo', 'bar']]));
+});
+
+it('can convert attributes to xml', function () {
+ $withAttributes = $this->testArray;
+ $withAttributes['Good guy']['_attributes'] = ['nameType' => 1];
+
+ assertMatchesXmlSnapshot(ArrayToXml::convert($withAttributes));
+});
+
+it('can handle attributes as collection', function () {
+ assertMatchesXmlSnapshot(ArrayToXml::convert([
+ 'user' => [
+ [
+ '_attributes' => [
'name' => 'een',
'age' => 10,
],
- [
+ ],
+ [
+ '_attributes' => [
'name' => 'twee',
'age' => 12,
],
],
- ]));
- }
-
- /** @test */
- public function it_can_handle_values_with_special_characters()
- {
- $this->assertMatchesXmlSnapshot(ArrayToXml::convert(['name' => 'this & that']));
- }
-
- /** @test */
- public function it_can_handle_values_with_special_control_characters()
- {
- $this->assertMatchesXmlSnapshot(ArrayToXml::convert(['name' => "i want tothis and \x03 that"]));
- }
-
- /**
- * @test
- */
- public function it_can_group_by_values_when_values_are_in_a_numeric_array()
- {
- $this->assertMatchesXmlSnapshot(ArrayToXml::convert(['user' => ['foo', 'bar']]));
- }
-
- /** @test */
- public function it_can_convert_attributes_to_xml()
- {
- $withAttributes = $this->testArray;
-
- $withAttributes['Good guy']['_attributes'] = ['nameType' => 1];
-
- $this->assertMatchesXmlSnapshot(ArrayToXml::convert($withAttributes));
- }
-
- /** @test */
- public function it_can_handle_attributes_as_collection()
- {
- $this->assertMatchesXmlSnapshot(ArrayToXml::convert([
- 'user' => [
- [
- '_attributes' => [
- 'name' => 'een',
- 'age' => 10,
- ],
- ],
- [
- '_attributes' => [
- 'name' => 'twee',
- 'age' => 12,
- ],
+ ],
+ ]));
+});
+
+test('and attributes also can be set in SimpleXMLElement style', function () {
+ $withAttributes = $this->testArray;
+ $withAttributes['Good guy']['@attributes'] = ['nameType' => 1];
+
+ assertMatchesXmlSnapshot(ArrayToXml::convert($withAttributes));
+});
+
+it('can handle values set with attributes with special characters', function () {
+ assertMatchesXmlSnapshot(ArrayToXml::convert([
+ 'movie' => [
+ [
+ 'title' => [
+ '_attributes' => ['category' => 'SF'],
+ '_value' => 'STAR WARS',
],
],
- ]));
- }
-
- /** @test */
- public function and_attributes_also_can_be_set_in_simplexmlelement_style()
- {
- $withAttributes = $this->testArray;
-
- $withAttributes['Good guy']['@attributes'] = ['nameType' => 1];
-
- $this->assertMatchesXmlSnapshot(ArrayToXml::convert($withAttributes));
- }
-
- /** @test */
- public function it_can_handle_values_set_with_attributes_with_special_characters()
- {
- $this->assertMatchesXmlSnapshot(ArrayToXml::convert([
- 'movie' => [
- [
- 'title' => [
- '_attributes' => ['category' => 'SF'],
- '_value' => 'STAR WARS',
- ],
- ],
- [
- 'title' => [
- '_attributes' => ['category' => 'Children'],
- '_value' => 'tom & jerry',
- ],
+ [
+ 'title' => [
+ '_attributes' => ['category' => 'Children'],
+ '_value' => 'tom & jerry',
],
],
- ]));
- }
-
- /** @test */
- public function and_value_also_can_be_set_in_simplexmlelement_style()
- {
- $this->assertMatchesXmlSnapshot(ArrayToXml::convert([
- 'movie' => [
- [
- 'title' => [
- '@attributes' => ['category' => 'SF'],
- '@value' => 'STAR WARS',
- ],
- ],
- [
- 'title' => [
- '@attributes' => ['category' => 'Children'],
- '@value' => 'tom & jerry',
- ],
+ ],
+ ]));
+});
+
+test('and value also can be set in SimpleXMLElement style', function () {
+ assertMatchesXmlSnapshot(ArrayToXml::convert([
+ 'movie' => [
+ [
+ 'title' => [
+ '@attributes' => ['category' => 'SF'],
+ '@value' => 'STAR WARS',
],
],
- ]));
- }
-
- /** @test */
- public function it_can_handle_values_set_as_cdata()
- {
- $this->assertMatchesSnapshot(ArrayToXml::convert([
- 'movie' => [
- [
- 'title' => [
- '_attributes' => ['category' => 'SF'],
- '_cdata' => '
STAR WARS
',
- ],
- ],
- [
- 'title' => [
- '_attributes' => ['category' => 'Children'],
- '_cdata' => 'tom & jerry
',
- ],
+ [
+ 'title' => [
+ '@attributes' => ['category' => 'Children'],
+ '@value' => 'tom & jerry',
],
],
- ]));
- }
-
- /** @test */
- public function and_cdata_values_can_also_be_set_in_simplexmlelement_style()
- {
- $this->assertMatchesSnapshot(ArrayToXml::convert([
- 'movie' => [
- [
- 'title' => [
- '@attributes' => ['category' => 'SF'],
- '@cdata' => 'STAR WARS
',
- ],
- ],
- [
- 'title' => [
- '@attributes' => ['category' => 'Children'],
- '@cdata' => 'tom & jerry
',
- ],
+ ],
+ ]));
+});
+
+it('can handle values set as cdata', function () {
+ assertMatchesSnapshot(ArrayToXml::convert([
+ 'movie' => [
+ [
+ 'title' => [
+ '_attributes' => ['category' => 'SF'],
+ '_cdata' => 'STAR WARS
',
],
],
- ]));
- }
-
- /** @test */
- public function it_doesnt_pollute_attributes_in_collection_and_sequential_nodes()
- {
- $this->assertMatchesSnapshot(ArrayToXml::convert([
- 'books' => [
- 'book' => [
- ['name' => 'A', '@attributes' => ['z' => 1]],
- ['name' => 'B'],
- ['name' => 'C'],
+ [
+ 'title' => [
+ '_attributes' => ['category' => 'Children'],
+ '_cdata' => 'tom & jerry
',
],
],
- ]));
- }
-
- /** @test */
- public function it_can_convert_array_to_dom()
- {
- $resultDom = (new ArrayToXml($this->testArray))->toDom();
-
- $this->assertSame('Luke Skywalker', $resultDom->getElementsByTagName('name')->item(0)->nodeValue);
- $this->assertSame('Sauron', $resultDom->getElementsByTagName('name')->item(1)->nodeValue);
- $this->assertSame('Lightsaber', $resultDom->getElementsByTagName('weapon')->item(0)->nodeValue);
- $this->assertSame('Evil Eye', $resultDom->getElementsByTagName('weapon')->item(1)->nodeValue);
- }
-
- /** @test */
- public function it_can_handle_values_set_as_mixed()
- {
- $this->assertMatchesSnapshot(ArrayToXml::convert([
- 'movie' => [
- [
- 'title' => [
- '@attributes' => ['category' => 'SF'],
- '_mixed' => 'STAR WARS Figure 1',
- ],
+ ],
+ ]));
+});
+
+test('and cdata values can also be set in SimpleXMLElement style', function () {
+ assertMatchesSnapshot(ArrayToXml::convert([
+ 'movie' => [
+ [
+ 'title' => [
+ '@attributes' => ['category' => 'SF'],
+ '@cdata' => 'STAR WARS
',
],
- [
- 'title' => [
- '@attributes' => ['category' => 'Action'],
- '_mixed' => 'ROBOCOP Figure 2',
- ],
+ ],
+ [
+ 'title' => [
+ '@attributes' => ['category' => 'Children'],
+ '@cdata' => 'tom & jerry
',
],
],
- ]));
- }
-
- /** @test */
- public function and_mixed_values_can_also_be_set_in_simplexmlelement_style()
- {
- $this->assertMatchesSnapshot(ArrayToXml::convert([
- 'movie' => [
- [
- 'title' => [
- '@attributes' => ['category' => 'SF'],
- '@mixed' => 'STAR WARS Figure 1',
- ],
+ ],
+ ]));
+});
+
+it('doesnt pollute attributes in collection and sequential nodes', function () {
+ assertMatchesSnapshot(ArrayToXml::convert([
+ 'books' => [
+ 'book' => [
+ ['name' => 'A', '@attributes' => ['z' => 1]],
+ ['name' => 'B'],
+ ['name' => 'C'],
+ ],
+ ],
+ ]));
+});
+
+it('can convert array to dom', function () {
+ $resultDom = (new ArrayToXml($this->testArray))->toDom();
+
+ expect($resultDom->getElementsByTagName('name')->item(0)->nodeValue)->toBe('Luke Skywalker');
+ expect($resultDom->getElementsByTagName('name')->item(1)->nodeValue)->toBe('Sauron');
+ expect($resultDom->getElementsByTagName('weapon')->item(0)->nodeValue)->toBe('Lightsaber');
+ expect($resultDom->getElementsByTagName('weapon')->item(1)->nodeValue)->toBe('Evil Eye');
+});
+
+it('can handle values set as mixed', function () {
+ assertMatchesSnapshot(ArrayToXml::convert([
+ 'movie' => [
+ [
+ 'title' => [
+ '@attributes' => ['category' => 'SF'],
+ '_mixed' => 'STAR WARS Figure 1',
],
- [
- 'title' => [
- '@attributes' => ['category' => 'Action'],
- '@mixed' => 'ROBOCOP Figure 2',
- ],
+ ],
+ [
+ 'title' => [
+ '@attributes' => ['category' => 'Action'],
+ '_mixed' => 'ROBOCOP Figure 2',
],
],
- ]));
- }
-
- /** @test */
- public function it_can_handle_numeric_keys()
- {
- $this->assertMatchesSnapshot(ArrayToXml::convert([
- '__numeric' => [
- 16 => [
- 'parent' => 'aaa',
- 'numLinks' => 3,
- 'child' => [
- 16 => [
- 'parent' => 'abc',
- 'numLinks' => 3,
- ],
- ],
+ ],
+ ]));
+});
+
+test('and mixed values can also be set in SimpleXMLElement style', function () {
+ assertMatchesSnapshot(ArrayToXml::convert([
+ 'movie' => [
+ [
+ 'title' => [
+ '@attributes' => ['category' => 'SF'],
+ '@mixed' => 'STAR WARS Figure 1',
],
- 17 => [
- 'parent' => 'bb',
- 'numLinks' => 3,
- 'child' => [
- 16 => [
- 'parent' => 'abb',
- 'numLinks' => 3,
- 'child' => [
- 16 => [
- 'parent' => 'abc',
- 'numLinks' => 3,
- ],
- ],
- ],
- 17 => [
- 'parent' => 'acb',
- 'numLinks' => 3,
- ],
- ],
+ ],
+ [
+ 'title' => [
+ '@attributes' => ['category' => 'Action'],
+ '@mixed' => 'ROBOCOP Figure 2',
],
],
- ]));
- }
-
- /** @test */
- public function it_can_handle_custom_keys()
- {
- $this->assertMatchesSnapshot(ArrayToXml::convert([
- '__custom:custom-key:01' => [
+ ],
+ ]));
+});
+
+it('can handle numeric keys', function () {
+ assertMatchesSnapshot(ArrayToXml::convert([
+ '__numeric' => [
+ 16 => [
'parent' => 'aaa',
'numLinks' => 3,
'child' => [
@@ -414,106 +318,146 @@ public function it_can_handle_custom_keys()
],
],
],
- '__custom:custom-key:02' => [
+ 17 => [
'parent' => 'bb',
'numLinks' => 3,
'child' => [
- '__custom:custom-subkey:01' => [
+ 16 => [
'parent' => 'abb',
'numLinks' => 3,
'child' => [
- '__custom:custom-subsubkey:01' => [
+ 16 => [
'parent' => 'abc',
'numLinks' => 3,
],
],
],
- '__custom:custom-subkey:02' => [
+ 17 => [
'parent' => 'acb',
'numLinks' => 3,
],
],
],
- ]));
- }
-
- /** @test */
- public function it_can_handle_custom_keys_containing_colon_character()
- {
- $this->assertMatchesSnapshot(ArrayToXml::convert([
- '__custom:custom\:key:01' => [
- 'parent' => 'aaa',
- 'numLinks' => 3,
- 'child' => [
- 16 => [
- 'parent' => 'abc',
- 'numLinks' => 3,
- ],
+ ],
+ ]));
+});
+
+it('can handle custom keys', function () {
+ assertMatchesSnapshot(ArrayToXml::convert([
+ '__custom:custom-key:01' => [
+ 'parent' => 'aaa',
+ 'numLinks' => 3,
+ 'child' => [
+ 16 => [
+ 'parent' => 'abc',
+ 'numLinks' => 3,
],
],
- '__custom:custom\:key:02' => [
- 'parent' => 'bb',
- 'numLinks' => 3,
- 'child' => [
- '__custom:custom\:subkey:01' => [
- 'parent' => 'abb',
- 'numLinks' => 3,
- 'child' => [
- '__custom:custom\:subsubkey:01' => [
- 'parent' => 'abc',
- 'numLinks' => 3,
- ],
+ ],
+ '__custom:custom-key:02' => [
+ 'parent' => 'bb',
+ 'numLinks' => 3,
+ 'child' => [
+ '__custom:custom-subkey:01' => [
+ 'parent' => 'abb',
+ 'numLinks' => 3,
+ 'child' => [
+ '__custom:custom-subsubkey:01' => [
+ 'parent' => 'abc',
+ 'numLinks' => 3,
],
],
- '__custom:custom\:subkey:02' => [
- 'parent' => 'acb',
- 'numLinks' => 3,
- ],
+ ],
+ '__custom:custom-subkey:02' => [
+ 'parent' => 'acb',
+ 'numLinks' => 3,
],
],
- ]));
- }
-
- /** @test */
- public function setting_invalid_properties_will_result_in_an_exception()
- {
- $this->expectException(\Exception::class);
- $xml2Array = new ArrayToXml($this->testArray);
-
- $xml2Array->setDomProperties(['foo' => 'bar']);
- }
-
- /** @test */
- public function it_can_set_dom_properties()
- {
- $xml2Array = new ArrayToXml($this->testArray);
- $xml2Array->setDomProperties([
- 'formatOutput' => true,
- 'version' => '1234567',
- ]);
-
- $dom = $xml2Array->toDom();
- $this->assertTrue($dom->formatOutput);
- $this->assertEquals('1234567', $dom->version);
- }
-
- /** @test */
- public function it_can_drop_xml_declaration()
- {
- $root = [
- 'rootElementName' => 'soap:Envelope',
- '_attributes' => [
- 'xmlns:soap' => 'http://www.w3.org/2003/05/soap-envelope/',
+ ],
+ ]));
+});
+
+it('can handle custom keys containing colon character', function () {
+ assertMatchesSnapshot(ArrayToXml::convert([
+ '__custom:custom\:key:01' => [
+ 'parent' => 'aaa',
+ 'numLinks' => 3,
+ 'child' => [
+ 16 => [
+ 'parent' => 'abc',
+ 'numLinks' => 3,
+ ],
],
- ];
- $array = [
- 'soap:Header' => [],
- 'soap:Body' => [
- 'soap:key' => 'soap:value',
+ ],
+ '__custom:custom\:key:02' => [
+ 'parent' => 'bb',
+ 'numLinks' => 3,
+ 'child' => [
+ '__custom:custom\:subkey:01' => [
+ 'parent' => 'abb',
+ 'numLinks' => 3,
+ 'child' => [
+ '__custom:custom\:subsubkey:01' => [
+ 'parent' => 'abc',
+ 'numLinks' => 3,
+ ],
+ ],
+ ],
+ '__custom:custom\:subkey:02' => [
+ 'parent' => 'acb',
+ 'numLinks' => 3,
+ ],
],
- ];
- $arrayToXml = new ArrayToXml($array, $root);
-
- $this->assertMatchesSnapshot($arrayToXml->dropXmlDeclaration()->toXml());
- }
-}
+ ],
+ ]));
+});
+
+test('Setting invalid properties will result in an exception', function () {
+ $xml2Array = new ArrayToXml($this->testArray);
+ $xml2Array->setDomProperties(['foo' => 'bar']);
+})->throws(Exception::class);
+
+it('can set dom properties', function () {
+ $xml2Array = new ArrayToXml($this->testArray);
+ $xml2Array->setDomProperties([
+ 'formatOutput' => true,
+ 'version' => '1234567',
+ ]);
+
+ $dom = $xml2Array->toDom();
+ expect($dom->formatOutput)->toBeTrue();
+ expect($dom->version)->toBe('1234567');
+});
+
+it('can drop xml declaration', function () {
+ $root = [
+ 'rootElementName' => 'soap:Envelope',
+ '_attributes' => [
+ 'xmlns:soap' => 'http://www.w3.org/2003/05/soap-envelope/',
+ ],
+ ];
+ $array = [
+ 'soap:Header' => [],
+ 'soap:Body' => [
+ 'soap:key' => 'soap:value',
+ ],
+ ];
+ $arrayToXml = new ArrayToXml($array, $root);
+
+ assertMatchesSnapshot($arrayToXml->dropXmlDeclaration()->toXml());
+});
+
+it('can convert an array with null value to xml', function () {
+ $arr = [
+ 'test' => null,
+ ];
+
+ assertMatchesXmlSnapshot(ArrayToXml::convert($arr));
+});
+
+it('can add processing instructions', function () {
+ $arrayToXml = new ArrayToXml($this->testArray);
+ $arrayToXml->addProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="base.xsl"');
+
+ assertMatchesSnapshot($arrayToXml->toXml());
+});
diff --git a/tests/__snapshots__/ArrayToXmlTest__and_cdata_values_can_also_be_set_in_simplexmlelement_style__1.txt b/tests/__snapshots__/ArrayToXmlTest__And_cdata_values_can_also_be_set_in_SimpleXMLElement_style__1.txt
similarity index 100%
rename from tests/__snapshots__/ArrayToXmlTest__and_cdata_values_can_also_be_set_in_simplexmlelement_style__1.txt
rename to tests/__snapshots__/ArrayToXmlTest__And_cdata_values_can_also_be_set_in_SimpleXMLElement_style__1.txt
diff --git a/tests/__snapshots__/ArrayToXmlTest__and_mixed_values_can_also_be_set_in_simplexmlelement_style__1.txt b/tests/__snapshots__/ArrayToXmlTest__And_mixed_values_can_also_be_set_in_SimpleXMLElement_style__1.txt
similarity index 100%
rename from tests/__snapshots__/ArrayToXmlTest__and_mixed_values_can_also_be_set_in_simplexmlelement_style__1.txt
rename to tests/__snapshots__/ArrayToXmlTest__And_mixed_values_can_also_be_set_in_SimpleXMLElement_style__1.txt
diff --git a/tests/__snapshots__/ArrayToXmlTest__it_accepts_an_xml_standalone_value__1.txt b/tests/__snapshots__/ArrayToXmlTest__It_accepts_an_xml_standalone_value__1.xml
similarity index 100%
rename from tests/__snapshots__/ArrayToXmlTest__it_accepts_an_xml_standalone_value__1.txt
rename to tests/__snapshots__/ArrayToXmlTest__It_accepts_an_xml_standalone_value__1.xml
diff --git a/tests/__snapshots__/ArrayToXmlTest__and_attributes_also_can_be_set_in_SimpleXMLElement_style__1.xml b/tests/__snapshots__/ArrayToXmlTest__and_attributes_also_can_be_set_in_SimpleXMLElement_style__1.xml
new file mode 100644
index 0000000..286a1ed
--- /dev/null
+++ b/tests/__snapshots__/ArrayToXmlTest__and_attributes_also_can_be_set_in_SimpleXMLElement_style__1.xml
@@ -0,0 +1,11 @@
+
+
+
+ Luke Skywalker
+ Lightsaber
+
+
+ Sauron
+ Evil Eye
+
+
diff --git a/tests/__snapshots__/ArrayToXmlTest__and_cdata_values_can_also_be_set_in_simplexmlelement_style__1.php b/tests/__snapshots__/ArrayToXmlTest__and_cdata_values_can_also_be_set_in_SimpleXMLElement_style__1.txt
similarity index 80%
rename from tests/__snapshots__/ArrayToXmlTest__and_cdata_values_can_also_be_set_in_simplexmlelement_style__1.php
rename to tests/__snapshots__/ArrayToXmlTest__and_cdata_values_can_also_be_set_in_SimpleXMLElement_style__1.txt
index 404ef01..34a7995 100644
--- a/tests/__snapshots__/ArrayToXmlTest__and_cdata_values_can_also_be_set_in_simplexmlelement_style__1.php
+++ b/tests/__snapshots__/ArrayToXmlTest__and_cdata_values_can_also_be_set_in_SimpleXMLElement_style__1.txt
@@ -1,5 +1,2 @@
-
+
STAR WARS]]>tom & jerry]]>
-';
diff --git a/tests/__snapshots__/ArrayToXmlTest__and_mixed_values_can_also_be_set_in_simplexmlelement_style__1.php b/tests/__snapshots__/ArrayToXmlTest__and_mixed_values_can_also_be_set_in_SimpleXMLElement_style__1.txt
similarity index 84%
rename from tests/__snapshots__/ArrayToXmlTest__and_mixed_values_can_also_be_set_in_simplexmlelement_style__1.php
rename to tests/__snapshots__/ArrayToXmlTest__and_mixed_values_can_also_be_set_in_SimpleXMLElement_style__1.txt
index 1e746ec..a7a95ac 100644
--- a/tests/__snapshots__/ArrayToXmlTest__and_mixed_values_can_also_be_set_in_simplexmlelement_style__1.php
+++ b/tests/__snapshots__/ArrayToXmlTest__and_mixed_values_can_also_be_set_in_SimpleXMLElement_style__1.txt
@@ -1,5 +1,2 @@
-
+
STAR WARS Figure 1ROBOCOP Figure 2
-';
diff --git a/tests/__snapshots__/ArrayToXmlTest__and_root_element_attributes_can_also_be_set_in_SimpleXMLElement_style__1.xml b/tests/__snapshots__/ArrayToXmlTest__and_root_element_attributes_can_also_be_set_in_SimpleXMLElement_style__1.xml
new file mode 100644
index 0000000..177125b
--- /dev/null
+++ b/tests/__snapshots__/ArrayToXmlTest__and_root_element_attributes_can_also_be_set_in_SimpleXMLElement_style__1.xml
@@ -0,0 +1,2 @@
+
+
diff --git a/tests/__snapshots__/ArrayToXmlTest__and_value_also_can_be_set_in_SimpleXMLElement_style__1.xml b/tests/__snapshots__/ArrayToXmlTest__and_value_also_can_be_set_in_SimpleXMLElement_style__1.xml
new file mode 100644
index 0000000..61d5db3
--- /dev/null
+++ b/tests/__snapshots__/ArrayToXmlTest__and_value_also_can_be_set_in_SimpleXMLElement_style__1.xml
@@ -0,0 +1,9 @@
+
+
+
+ STAR WARS
+
+
+ tom & jerry
+
+
diff --git a/tests/__snapshots__/ArrayToXmlTest__it_accepts_an_xml_standalone_value__1.php b/tests/__snapshots__/ArrayToXmlTest__it_accepts_an_xml_standalone_value__1.php
deleted file mode 100644
index 89a1f24..0000000
--- a/tests/__snapshots__/ArrayToXmlTest__it_accepts_an_xml_standalone_value__1.php
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-';
diff --git a/tests/__snapshots__/ArrayToXmlTest__it_accepts_an_xml_standalone_value__1.xml b/tests/__snapshots__/ArrayToXmlTest__it_accepts_an_xml_standalone_value__1.xml
new file mode 100644
index 0000000..2589464
--- /dev/null
+++ b/tests/__snapshots__/ArrayToXmlTest__it_accepts_an_xml_standalone_value__1.xml
@@ -0,0 +1,2 @@
+
+
diff --git a/tests/__snapshots__/ArrayToXmlTest__it_accepts_an_xml_version__1.php b/tests/__snapshots__/ArrayToXmlTest__it_accepts_an_xml_version__1.php
deleted file mode 100644
index 106de26..0000000
--- a/tests/__snapshots__/ArrayToXmlTest__it_accepts_an_xml_version__1.php
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-';
diff --git a/tests/__snapshots__/ArrayToXmlTest__it_can_add_processing_instructions__1.txt b/tests/__snapshots__/ArrayToXmlTest__it_can_add_processing_instructions__1.txt
new file mode 100644
index 0000000..8173007
--- /dev/null
+++ b/tests/__snapshots__/ArrayToXmlTest__it_can_add_processing_instructions__1.txt
@@ -0,0 +1,3 @@
+
+
+Luke SkywalkerLightsaberSauronEvil Eye
diff --git a/tests/__snapshots__/ArrayToXmlTest__it_can_convert_an_array_with_null_value_to_xml__1.xml b/tests/__snapshots__/ArrayToXmlTest__it_can_convert_an_array_with_null_value_to_xml__1.xml
new file mode 100644
index 0000000..179f597
--- /dev/null
+++ b/tests/__snapshots__/ArrayToXmlTest__it_can_convert_an_array_with_null_value_to_xml__1.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/tests/__snapshots__/ArrayToXmlTest__it_can_drop_xml_declaration__1.php b/tests/__snapshots__/ArrayToXmlTest__it_can_drop_xml_declaration__1.php
deleted file mode 100644
index e04e9a0..0000000
--- a/tests/__snapshots__/ArrayToXmlTest__it_can_drop_xml_declaration__1.php
+++ /dev/null
@@ -1,3 +0,0 @@
-soap:value';
diff --git a/tests/__snapshots__/ArrayToXmlTest__it_can_handle_custom_keys__1.php b/tests/__snapshots__/ArrayToXmlTest__it_can_handle_custom_keys__1.php
deleted file mode 100644
index e1c066a..0000000
--- a/tests/__snapshots__/ArrayToXmlTest__it_can_handle_custom_keys__1.php
+++ /dev/null
@@ -1,5 +0,0 @@
-
-aaa3abc3bb3abb3abc3acb3
-';
diff --git a/tests/__snapshots__/ArrayToXmlTest__it_can_handle_custom_keys_containing_colon_character__1.php b/tests/__snapshots__/ArrayToXmlTest__it_can_handle_custom_keys_containing_colon_character__1.php
deleted file mode 100644
index 86e55a2..0000000
--- a/tests/__snapshots__/ArrayToXmlTest__it_can_handle_custom_keys_containing_colon_character__1.php
+++ /dev/null
@@ -1,5 +0,0 @@
-
-aaa3abc3bb3abb3abc3acb3
-';
diff --git a/tests/__snapshots__/ArrayToXmlTest__it_can_handle_numeric_keys__1.php b/tests/__snapshots__/ArrayToXmlTest__it_can_handle_numeric_keys__1.php
deleted file mode 100644
index ce1a70c..0000000
--- a/tests/__snapshots__/ArrayToXmlTest__it_can_handle_numeric_keys__1.php
+++ /dev/null
@@ -1,5 +0,0 @@
-
-aaa3abc3bb3abb3abc3acb3
-';
diff --git a/tests/__snapshots__/ArrayToXmlTest__it_can_handle_numeric_keys__1.xml b/tests/__snapshots__/ArrayToXmlTest__it_can_handle_numeric_keys__1.xml
deleted file mode 100644
index 1175728..0000000
--- a/tests/__snapshots__/ArrayToXmlTest__it_can_handle_numeric_keys__1.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
- aaa
- 3
-
- abc
- 3
-
-
-
- bb
- 3
-
-
- abb
- 3
-
-
- abc
- 3
-
-
-
-
- acb
- 3
-
-
-
-
diff --git a/tests/__snapshots__/ArrayToXmlTest__it_can_handle_numeric_keys__1__1.php b/tests/__snapshots__/ArrayToXmlTest__it_can_handle_numeric_keys__1__1.php
deleted file mode 100644
index 067aa51..0000000
--- a/tests/__snapshots__/ArrayToXmlTest__it_can_handle_numeric_keys__1__1.php
+++ /dev/null
@@ -1,5 +0,0 @@
-
-aaa3abc3bb3abb3abc3acb3aaa3abc3bb3abb3abc3acb3
-';
diff --git a/tests/__snapshots__/ArrayToXmlTest__it_can_handle_values_set_as_cdata__1.php b/tests/__snapshots__/ArrayToXmlTest__it_can_handle_values_set_as_cdata__1.php
deleted file mode 100644
index 404ef01..0000000
--- a/tests/__snapshots__/ArrayToXmlTest__it_can_handle_values_set_as_cdata__1.php
+++ /dev/null
@@ -1,5 +0,0 @@
-
-STAR WARS]]>tom & jerry]]>
-';
diff --git a/tests/__snapshots__/ArrayToXmlTest__it_can_handle_values_set_as_mixed__1.php b/tests/__snapshots__/ArrayToXmlTest__it_can_handle_values_set_as_mixed__1.php
deleted file mode 100644
index 1e746ec..0000000
--- a/tests/__snapshots__/ArrayToXmlTest__it_can_handle_values_set_as_mixed__1.php
+++ /dev/null
@@ -1,5 +0,0 @@
-
-STAR WARS Figure 1ROBOCOP Figure 2
-';
diff --git a/tests/__snapshots__/ArrayToXmlTest__it_can_handle_values_with_namespace_as_basic_collection__1.xml b/tests/__snapshots__/ArrayToXmlTest__it_can_handle_values_with_namespace_as_basic_collection__1.xml
new file mode 100644
index 0000000..cf905c9
--- /dev/null
+++ b/tests/__snapshots__/ArrayToXmlTest__it_can_handle_values_with_namespace_as_basic_collection__1.xml
@@ -0,0 +1,6 @@
+
+
+ one
+ two
+ three
+
diff --git a/tests/__snapshots__/ArrayToXmlTest__it_doesnt_pollute_attributes_in_collection_and_sequential_nodes__1.php b/tests/__snapshots__/ArrayToXmlTest__it_doesnt_pollute_attributes_in_collection_and_sequential_nodes__1.php
deleted file mode 100644
index b8ef10b..0000000
--- a/tests/__snapshots__/ArrayToXmlTest__it_doesnt_pollute_attributes_in_collection_and_sequential_nodes__1.php
+++ /dev/null
@@ -1,5 +0,0 @@
-
-ABC
-';