From 75acba318ddb2e3933d06cf29a5504ea0737cae0 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Thu, 7 Aug 2014 22:47:07 -0400 Subject: [PATCH] Started on some unit tests. --- tests/bootstrap.php | 68 +++++++++++++++++++++++++++++++++++ tests/simplexml_dump_Test.php | 62 ++++++++++++++++++++++++++++++++ tests/simplexml_tree_Test.php | 0 3 files changed, 130 insertions(+) create mode 100644 tests/bootstrap.php create mode 100644 tests/simplexml_dump_Test.php create mode 100644 tests/simplexml_tree_Test.php diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..3be9ba2 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,68 @@ +simpleXML = simplexml_load_string(' + + + PHP: Behind the Parser + + + Ms. Coder + Onlivia Actora + + + Mr. Coder + El ActÓr + + + + So, this language. It\'s like, a programming language. + Or is it a scripting language? All is revealed in this + thrilling horror spoof of a documentary. + + + PHP solves all my web problems + + 7 + 5 + + + '); + + $this->simpleXML_NS = simplexml_load_string(' + + + PHP: Behind the Parser + + + Ms. Coder + Onlivia Actora + + + Mr. Coder + El ActÓr + + + + So, this language. It\'s like, a programming language. + Or is it a scripting language? All is revealed in this + thrilling horror spoof of a documentary. + + + PHP solves all my web problems + + 7 + 5 + + + '); + } +} + +?> diff --git a/tests/simplexml_dump_Test.php b/tests/simplexml_dump_Test.php new file mode 100644 index 0000000..d29506f --- /dev/null +++ b/tests/simplexml_dump_Test.php @@ -0,0 +1,62 @@ +expected = "SimpleXML object (1 item) +[ + Element { + Name: 'movies' + String Content: ' + + ' + Content in Default Namespace + Children: 1 - 1 'movie' + Attributes: 0 + } +] +"; + + $this->expected_NS = "SimpleXML object (1 item) +[ + Element { + Name: 'movies' + String Content: ' + + ' + Content in Namespace test + Namespace URI: 'https://github.com/IMSoP/simplexml_debug' + Children: 1 - 1 'movie' + Attributes: 0 + } +] +"; + + parent::setUp(); + } + + public function testDump() + { + ob_start(); + simplexml_dump($this->simpleXML); + $return = ob_get_contents(); + ob_end_clean(); + + $this->assertEquals($this->expected, $return); + } + + public function testDumpReturn() + { + $return = simplexml_dump($this->simpleXML, true); + $this->assertEquals($this->expected, $return); + } + + public function testDumpWithNS() + { + $return = simplexml_dump($this->simpleXML_NS, true); + $this->assertEquals($this->expected_NS, $return); + } +} + +?> diff --git a/tests/simplexml_tree_Test.php b/tests/simplexml_tree_Test.php new file mode 100644 index 0000000..e69de29