From 58aad47b31bc024f582d3b453137e35c7d2a0d91 Mon Sep 17 00:00:00 2001 From: Davide Pastore Date: Sun, 3 Apr 2022 16:07:33 +0200 Subject: [PATCH] Add XML test with attributes --- tests/Parser/XmlTest.php | 17 +++++++++++++++++ tests/mocks/pass/config-with-attributes.xml | 14 ++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/mocks/pass/config-with-attributes.xml diff --git a/tests/Parser/XmlTest.php b/tests/Parser/XmlTest.php index 37b1a91..2f6a0eb 100644 --- a/tests/Parser/XmlTest.php +++ b/tests/Parser/XmlTest.php @@ -62,4 +62,21 @@ public function testLoadXml() $this->assertEquals('localhost', $string['host']); $this->assertEquals('80', $string['port']); } + + /** + * @covers Noodlehaus\Parser\Xml::parseFile() + * @covers Noodlehaus\Parser\Xml::parseString() + * @covers Noodlehaus\Parser\Xml::parse() + */ + public function testLoadXmlWithAttributes() + { + $file = $this->xml->parseFile(__DIR__ . '/../mocks/pass/config-with-attributes.xml'); + $string = $this->xml->parseString(file_get_contents(__DIR__ . '/../mocks/pass/config-with-attributes.xml')); + + $this->assertEquals('localhost', $file['host']); + $this->assertEquals('80', $file['port']); + + $this->assertEquals('localhost', $string['host']); + $this->assertEquals('80', $string['port']); + } } diff --git a/tests/mocks/pass/config-with-attributes.xml b/tests/mocks/pass/config-with-attributes.xml new file mode 100644 index 0000000..f018a60 --- /dev/null +++ b/tests/mocks/pass/config-with-attributes.xml @@ -0,0 +1,14 @@ + + + + configuration + s3cr3t + + localhost + 80 + + host1 + host2 + host3 + + \ No newline at end of file