diff options
Diffstat (limited to 'ext/xml/tests')
84 files changed, 9799 insertions, 0 deletions
diff --git a/ext/xml/tests/bug25666.phpt b/ext/xml/tests/bug25666.phpt new file mode 100644 index 0000000..e162d5a --- /dev/null +++ b/ext/xml/tests/bug25666.phpt @@ -0,0 +1,35 @@ +--TEST-- +Bug #25666 (XML namespaces broken in libxml-based SAX interface) +--SKIPIF-- +<?php +require_once("skipif.inc"); +if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this platform");} +?> +--FILE-- +<?php +function start_elem($parser,$name,$attribs) { + var_dump($name); +} +function end_elem() +{ +} + +$xml = <<<HERE +<foo:a xmlns:foo="http://example.com/foo" + xmlns:bar="http://example.com/bar" + xmlns:baz="http://example.com/baz"> + <bar:b /> + <baz:c /> +</foo> +HERE; + +$parser = xml_parser_create_ns("ISO-8859-1","@"); +xml_set_element_handler($parser,'start_elem','end_elem'); +xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); +xml_parse($parser, $xml); +xml_parser_free($parser); +?> +--EXPECT-- +string(24) "http://example.com/foo@a" +string(24) "http://example.com/bar@b" +string(24) "http://example.com/baz@c" diff --git a/ext/xml/tests/bug26528.phpt b/ext/xml/tests/bug26528.phpt new file mode 100644 index 0000000..40a1c53 --- /dev/null +++ b/ext/xml/tests/bug26528.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #26528 (HTML entities are not being decoded) +--SKIPIF-- +<?php +require_once("skipif.inc"); +?> +--FILE-- +<?php + $sample = "<?xml version=\"1.0\"?><test attr=\"angle<bracket\"/>"; + $parser = xml_parser_create(); + $res = xml_parse_into_struct($parser,$sample,$vals,$index); + xml_parser_free($parser); + var_dump($vals); +?> +--EXPECT-- +array(1) { + [0]=> + array(4) { + ["tag"]=> + string(4) "TEST" + ["type"]=> + string(8) "complete" + ["level"]=> + int(1) + ["attributes"]=> + array(1) { + ["ATTR"]=> + string(13) "angle<bracket" + } + } +} diff --git a/ext/xml/tests/bug26614.phpt b/ext/xml/tests/bug26614.phpt new file mode 100644 index 0000000..e1df1bb --- /dev/null +++ b/ext/xml/tests/bug26614.phpt @@ -0,0 +1,93 @@ +--TEST-- +Bug #26614 (CDATA sections skipped on line count) +--SKIPIF-- +<?php +require_once("skipif.inc"); +if (defined("LIBXML_VERSION")) die('skip expat test'); +?> +--FILE-- +<?php +/* +this test works fine with Expat but fails with libxml +which we now use as default + +further investigation has shown that not only line count +is skippet on CDATA sections but that libxml does also +show different column numbers and byte positions depending +on context and in opposition to what one would expect to +see and what good old Expat reported just fine ... +*/ + +$xmls = array(); + +// Case 1: CDATA Sections +$xmls["CDATA"] ='<?xml version="1.0" encoding="iso-8859-1" ?> +<data> +<![CDATA[ +multi +line +CDATA +block +]]> +</data>'; + +// Case 2: replace some characters so that we get comments instead +$xmls["Comment"] ='<?xml version="1.0" encoding="iso-8859-1" ?> +<data> +<!-- ATA[ +multi +line +CDATA +block +--> +</data>'; + +// Case 3: replace even more characters so that only textual data is left +$xmls["Text"] ='<?xml version="1.0" encoding="iso-8859-1" ?> +<data> +-!-- ATA[ +multi +line +CDATA +block +--- +</data>'; + +function startElement($parser, $name, $attrs) { + printf("<$name> at line %d, col %d (byte %d)\n", + xml_get_current_line_number($parser), + xml_get_current_column_number($parser), + xml_get_current_byte_index($parser)); +} + +function endElement($parser, $name) { + printf("</$name> at line %d, col %d (byte %d)\n", + xml_get_current_line_number($parser), + xml_get_current_column_number($parser), + xml_get_current_byte_index($parser)); +} + +function characterData($parser, $data) { + // dummy +} + +foreach ($xmls as $desc => $xml) { + echo "$desc\n"; + $xml_parser = xml_parser_create(); + xml_set_element_handler($xml_parser, "startElement", "endElement"); + xml_set_character_data_handler($xml_parser, "characterData"); + if (!xml_parse($xml_parser, $xml, true)) + echo "Error: ".xml_error_string(xml_get_error_code($xml_parser))."\n"; + xml_parser_free($xml_parser); +} +?> +--EXPECT-- +CDATA +<DATA> at line 2, col 0 (byte 45) +</DATA> at line 9, col 0 (byte 90) +Comment +<DATA> at line 2, col 0 (byte 45) +</DATA> at line 9, col 0 (byte 90) +Text +<DATA> at line 2, col 0 (byte 45) +</DATA> at line 9, col 0 (byte 90) diff --git a/ext/xml/tests/bug26614_libxml.phpt b/ext/xml/tests/bug26614_libxml.phpt new file mode 100644 index 0000000..782bdb1 --- /dev/null +++ b/ext/xml/tests/bug26614_libxml.phpt @@ -0,0 +1,93 @@ +--TEST-- +Bug #26614 (CDATA sections skipped on line count) +--SKIPIF-- +<?php +require_once("skipif.inc"); +if (!defined("LIBXML_VERSION")) die('skip libxml2 test'); +?> +--FILE-- +<?php +/* +this test works fine with Expat but fails with libxml +which we now use as default + +further investigation has shown that not only line count +is skippet on CDATA sections but that libxml does also +show different column numbers and byte positions depending +on context and in opposition to what one would expect to +see and what good old Expat reported just fine ... +*/ + +$xmls = array(); + +// Case 1: CDATA Sections +$xmls["CDATA"] ='<?xml version="1.0" encoding="iso-8859-1" ?> +<data> +<![CDATA[ +multi +line +CDATA +block +]]> +</data>'; + +// Case 2: replace some characters so that we get comments instead +$xmls["Comment"] ='<?xml version="1.0" encoding="iso-8859-1" ?> +<data> +<!-- ATA[ +multi +line +CDATA +block +--> +</data>'; + +// Case 3: replace even more characters so that only textual data is left +$xmls["Text"] ='<?xml version="1.0" encoding="iso-8859-1" ?> +<data> +-!-- ATA[ +multi +line +CDATA +block +--- +</data>'; + +function startElement($parser, $name, $attrs) { + printf("<$name> at line %d, col %d (byte %d)\n", + xml_get_current_line_number($parser), + xml_get_current_column_number($parser), + xml_get_current_byte_index($parser)); +} + +function endElement($parser, $name) { + printf("</$name> at line %d, col %d (byte %d)\n", + xml_get_current_line_number($parser), + xml_get_current_column_number($parser), + xml_get_current_byte_index($parser)); +} + +function characterData($parser, $data) { + // dummy +} + +foreach ($xmls as $desc => $xml) { + echo "$desc\n"; + $xml_parser = xml_parser_create(); + xml_set_element_handler($xml_parser, "startElement", "endElement"); + xml_set_character_data_handler($xml_parser, "characterData"); + if (!xml_parse($xml_parser, $xml, true)) + echo "Error: ".xml_error_string(xml_get_error_code($xml_parser))."\n"; + xml_parser_free($xml_parser); +} +?> +--EXPECTF-- +CDATA +<DATA> at line 2, col %d (byte 9) +</DATA> at line 9, col %d (byte 56) +Comment +<DATA> at line 2, col %d (byte 9) +</DATA> at line 9, col %d (byte 56) +Text +<DATA> at line 2, col %d (byte 9) +</DATA> at line 9, col %d (byte 56) diff --git a/ext/xml/tests/bug27908.phpt b/ext/xml/tests/bug27908.phpt new file mode 100644 index 0000000..e60466f --- /dev/null +++ b/ext/xml/tests/bug27908.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #27908 (default handler not being called) +--SKIPIF-- +<?php +require_once("skipif.inc"); +?> +--FILE-- +<?php + +function x_default_handler($xp,$data) +{ + echo "x_default_handler $data\n"; +} +$xp = xml_parser_create(); +xml_set_default_handler($xp,'x_default_handler'); +xml_parse($xp, '<root></root>',TRUE); +xml_parser_free($xp); +echo "Done\n"; +?> +--EXPECT-- +x_default_handler <root> +x_default_handler </root> +Done diff --git a/ext/xml/tests/bug30266.phpt b/ext/xml/tests/bug30266.phpt new file mode 100644 index 0000000..0a3a5ca --- /dev/null +++ b/ext/xml/tests/bug30266.phpt @@ -0,0 +1,52 @@ +--TEST-- +Bug #30266 (Invalid opcode 137/1/8) +--SKIPIF-- +<?php +require_once("skipif.inc"); +?> +--FILE-- +<?php +/* + +Currently (Feb 10, 2005) CVS HEAD fails with the following message: + +Fatal error: Invalid opcode 137/1/8. in /home/hartmut/projects/php/dev/head/ext/xml/tests/bug30266.php on line 22 + +*/ +class XML_Parser +{ + public $dummy = "a"; + + function parse($data) + { + $parser = xml_parser_create(); + + xml_set_object($parser, $this); + + xml_set_element_handler($parser, 'startHandler', 'endHandler'); + + xml_parse($parser, $data, true); + + xml_parser_free($parser); + } + + function startHandler($XmlParser, $tag, $attr) + { + $this->dummy = "b"; + throw new Exception("ex"); + } + + function endHandler($XmlParser, $tag) + { + } +} + +$p1 = new Xml_Parser(); +try { + $p1->parse('<tag1><tag2></tag2></tag1>'); +} catch (Exception $e) { + echo "OK\n"; +} +?> +--EXPECT-- +OK diff --git a/ext/xml/tests/bug32001.phpt b/ext/xml/tests/bug32001.phpt new file mode 100644 index 0000000..0853b3a --- /dev/null +++ b/ext/xml/tests/bug32001.phpt @@ -0,0 +1,406 @@ +--TEST-- +Bug #32001 (xml_parse*() goes into infinite loop when autodetection in effect), using UTF-* +--SKIPIF-- +<?php +require_once("skipif.inc"); +if (!extension_loaded('iconv')) die ("skip iconv extension not available"); +?> +--FILE-- +<?php +class testcase { + private $encoding; + private $bom; + private $prologue; + private $tags; + private $chunk_size; + + function testcase($enc, $chunk_size = 0, $bom = 0, $omit_prologue = 0) { + $this->encoding = $enc; + $this->chunk_size = $chunk_size; + $this->bom = $bom; + $this->prologue = !$omit_prologue; + $this->tags = array(); + } + + function start_element($parser, $name, $attrs) { + $attrs = array_map('bin2hex', $attrs); + $this->tags[] = bin2hex($name).": ".implode(', ', $attrs); + } + + function end_element($parser, $name) { + } + + function run() { + $data = ''; + + if ($this->prologue) { + $canonical_name = preg_replace('/BE|LE/i', '', $this->encoding); + $data .= "<?xml version=\"1.0\" encoding=\"$canonical_name\" ?>\n"; + } + + $data .= <<<HERE +<テスト:テスト1 xmlns:テスト="http://www.example.com/テスト/" テスト="テスト"> + <テスト:テスト2 テスト="テスト"> + <テスト:テスト3> + test! + </テスト:テスト3> + </テスト:テスト2> +</テスト:テスト1> +HERE; + + $data = iconv("UTF-8", $this->encoding, $data); + + if ($this->bom) { + switch (strtoupper($this->encoding)) { + case 'UTF-8': + case 'UTF8': + $data = "\xef\xbb\xbf".$data; + break; + + case 'UTF-16': + case 'UTF16': + case 'UTF-16BE': + case 'UTF16BE': + case 'UCS-2': + case 'UCS2': + case 'UCS-2BE': + case 'UCS2BE': + $data = "\xfe\xff".$data; + break; + + case 'UTF-16LE': + case 'UTF16LE': + case 'UCS-2LE': + case 'UCS2LE': + $data = "\xff\xfe".$data; + break; + + case 'UTF-32': + case 'UTF32': + case 'UTF-32BE': + case 'UTF32BE': + case 'UCS-4': + case 'UCS4': + case 'UCS-4BE': + case 'UCS4BE': + $data = "\x00\x00\xfe\xff".$data; + break; + + case 'UTF-32LE': + case 'UTF32LE': + case 'UCS-4LE': + case 'UCS4LE': + $data = "\xff\xfe\x00\x00".$data; + break; + } + } + + $parser = xml_parser_create(NULL); + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); + xml_set_element_handler($parser, "start_element", "end_element"); + xml_set_object($parser, $this); + + if ($this->chunk_size == 0) { + $success = @xml_parse($parser, $data, true); + } else { + for ($offset = 0; $offset < strlen($data); + $offset += $this->chunk_size) { + $success = @xml_parse($parser, substr($data, $offset, $this->chunk_size), false); + if (!$success) { + break; + } + } + if ($success) { + $success = @xml_parse($parser, "", true); + } + } + + echo "Encoding: $this->encoding\n"; + echo "XML Prologue: ".($this->prologue ? 'present': 'not present'), "\n"; + echo "Chunk size: ".($this->chunk_size ? "$this->chunk_size byte(s)\n": "all data at once\n"); + echo "BOM: ".($this->bom ? 'prepended': 'not prepended'), "\n"; + + if ($success) { + var_dump($this->tags); + } else { + echo "[Error] ", xml_error_string(xml_get_error_code($parser)), "\n"; + } + } +} +$suite = array( + new testcase("UTF-8", 0, 0, 0), + new testcase("UTF-8", 0, 0, 1), + new testcase("UTF-8", 0, 1, 0), + new testcase("UTF-8", 0, 1, 1), + new testcase("UTF-16BE", 0, 0, 0), + new testcase("UTF-16BE", 0, 1, 0), + new testcase("UTF-16BE", 0, 1, 1), + new testcase("UTF-16LE", 0, 0, 0), + new testcase("UTF-16LE", 0, 1, 0), + new testcase("UTF-16LE", 0, 1, 1), + new testcase("UTF-8", 1, 0, 0), + new testcase("UTF-8", 1, 0, 1), + new testcase("UTF-8", 1, 1, 0), + new testcase("UTF-8", 1, 1, 1), + new testcase("UTF-16BE", 1, 0, 0), + new testcase("UTF-16BE", 1, 1, 0), + new testcase("UTF-16BE", 1, 1, 1), + new testcase("UTF-16LE", 1, 0, 0), + new testcase("UTF-16LE", 1, 1, 0), + new testcase("UTF-16LE", 1, 1, 1), +); + +if (XML_SAX_IMPL == 'libxml') { + echo "libxml2 Version => " . LIBXML_DOTTED_VERSION. "\n"; +} else { + echo "libxml2 Version => NONE\n"; +} + +foreach ($suite as $testcase) { + $testcase->run(); +} + +// vim600: sts=4 sw=4 ts=4 encoding=UTF-8 +?> +--EXPECTF-- +libxml2 Version => %s +Encoding: UTF-8 +XML Prologue: present +Chunk size: all data at once +BOM: not prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: UTF-8 +XML Prologue: not present +Chunk size: all data at once +BOM: not prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: UTF-8 +XML Prologue: present +Chunk size: all data at once +BOM: prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: UTF-8 +XML Prologue: not present +Chunk size: all data at once +BOM: prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: UTF-16BE +XML Prologue: present +Chunk size: all data at once +BOM: not prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: UTF-16BE +XML Prologue: present +Chunk size: all data at once +BOM: prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: UTF-16BE +XML Prologue: not present +Chunk size: all data at once +BOM: prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: UTF-16LE +XML Prologue: present +Chunk size: all data at once +BOM: not prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: UTF-16LE +XML Prologue: present +Chunk size: all data at once +BOM: prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: UTF-16LE +XML Prologue: not present +Chunk size: all data at once +BOM: prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: UTF-8 +XML Prologue: present +Chunk size: 1 byte(s) +BOM: not prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: UTF-8 +XML Prologue: not present +Chunk size: 1 byte(s) +BOM: not prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: UTF-8 +XML Prologue: present +Chunk size: 1 byte(s) +BOM: prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: UTF-8 +XML Prologue: not present +Chunk size: 1 byte(s) +BOM: prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: UTF-16BE +XML Prologue: present +Chunk size: 1 byte(s) +BOM: not prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: UTF-16BE +XML Prologue: present +Chunk size: 1 byte(s) +BOM: prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: UTF-16BE +XML Prologue: not present +Chunk size: 1 byte(s) +BOM: prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: UTF-16LE +XML Prologue: present +Chunk size: 1 byte(s) +BOM: not prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: UTF-16LE +XML Prologue: present +Chunk size: 1 byte(s) +BOM: prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: UTF-16LE +XML Prologue: not present +Chunk size: 1 byte(s) +BOM: prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} diff --git a/ext/xml/tests/bug32001b.phpt b/ext/xml/tests/bug32001b.phpt new file mode 100644 index 0000000..ddf26ce --- /dev/null +++ b/ext/xml/tests/bug32001b.phpt @@ -0,0 +1,182 @@ +--TEST-- +Bug #32001 (xml_parse*() goes into infinite loop when autodetection in effect), using EUC-JP, Shift_JIS, GB2312 +--SKIPIF-- +<?php +require_once("skipif.inc"); +if (!extension_loaded('iconv')) die ("skip iconv extension not available"); +foreach(array('EUC-JP', 'Shift_JISP', 'GB2312') as $encoding) { + if (@xml_parser_create($encoding) === false) die("skip libxml2 does not support $encoding encoding"); +} +?> +--FILE-- +<?php +class testcase { + private $encoding; + private $bom; + private $prologue; + private $tags; + private $chunk_size; + + function testcase($enc, $chunk_size = 0, $bom = 0, $omit_prologue = 0) { + $this->encoding = $enc; + $this->chunk_size = $chunk_size; + $this->bom = $bom; + $this->prologue = !$omit_prologue; + $this->tags = array(); + } + + function start_element($parser, $name, $attrs) { + $attrs = array_map('bin2hex', $attrs); + $this->tags[] = bin2hex($name).": ".implode(', ', $attrs); + } + + function end_element($parser, $name) { + } + + function run() { + $data = ''; + + if ($this->prologue) { + $canonical_name = preg_replace('/BE|LE/i', '', $this->encoding); + $data .= "<?xml version=\"1.0\" encoding=\"$canonical_name\" ?>\n"; + } + + $data .= <<<HERE +<テスト:テスト1 xmlns:テスト="http://www.example.com/テスト/" テスト="テスト"> + <テスト:テスト2 テスト="テスト"> + <テスト:テスト3> + test! + </テスト:テスト3> + </テスト:テスト2> +</テスト:テスト1> +HERE; + + $data = iconv("UTF-8", $this->encoding, $data); + + $parser = xml_parser_create(NULL); + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); + xml_set_element_handler($parser, "start_element", "end_element"); + xml_set_object($parser, $this); + + if ($this->chunk_size == 0) { + $success = @xml_parse($parser, $data, true); + } else { + for ($offset = 0; $offset < strlen($data); + $offset += $this->chunk_size) { + $success = @xml_parse($parser, substr($data, $offset, $this->chunk_size), false); + if (!$success) { + break; + } + } + if ($success) { + $success = @xml_parse($parser, "", true); + } + } + + echo "Encoding: $this->encoding\n"; + echo "XML Prologue: ".($this->prologue ? 'present': 'not present'), "\n"; + echo "Chunk size: ".($this->chunk_size ? "$this->chunk_size byte(s)\n": "all data at once\n"); + echo "BOM: ".($this->bom ? 'prepended': 'not prepended'), "\n"; + + if ($success) { + var_dump($this->tags); + } else { + echo "[Error] ", xml_error_string(xml_get_error_code($parser)), "\n"; + } + } +} +$suite = array( + new testcase("EUC-JP" , 0), + new testcase("EUC-JP" , 1), + new testcase("Shift_JIS", 0), + new testcase("Shift_JIS", 1), + new testcase("GB2312", 0), + new testcase("GB2312", 1), +); + +if (XML_SAX_IMPL == 'libxml') { + echo "libxml2 Version => " . LIBXML_DOTTED_VERSION. "\n"; +} else { + echo "libxml2 Version => NONE\n"; +} + +foreach ($suite as $testcase) { + $testcase->run(); +} + +// vim600: sts=4 sw=4 ts=4 encoding=UTF-8 +?> +--EXPECTF-- +libxml2 Version => %s +Encoding: EUC-JP +XML Prologue: present +Chunk size: all data at once +BOM: not prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: EUC-JP +XML Prologue: present +Chunk size: 1 byte(s) +BOM: not prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: Shift_JIS +XML Prologue: present +Chunk size: all data at once +BOM: not prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: Shift_JIS +XML Prologue: present +Chunk size: 1 byte(s) +BOM: not prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: GB2312 +XML Prologue: present +Chunk size: all data at once +BOM: not prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: GB2312 +XML Prologue: present +Chunk size: 1 byte(s) +BOM: not prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} diff --git a/ext/xml/tests/bug35447.phpt b/ext/xml/tests/bug35447.phpt new file mode 100644 index 0000000..8cbb5e5 --- /dev/null +++ b/ext/xml/tests/bug35447.phpt @@ -0,0 +1,49 @@ +--TEST-- +Bug #35447 (xml_parse_into_struct() chokes on the UTF-8 BOM) +--SKIPIF-- +<?php +require_once("skipif.inc"); +if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this plattform");} +?> +--FILE-- +<?php +$data = <<<END_OF_XML +\xEF\xBB\xBF<?xml version="1.0" encoding="utf-8"?\x3e +<!DOCTYPE bundle [ + <!ELEMENT bundle (resource)+> + <!ELEMENT resource (#PCDATA)> + <!ATTLIST resource + key CDATA #REQUIRED + type (literal|pattern|sub) "literal" + > +]> +<resource key="rSeeYou">A bient&244;t</resource> +END_OF_XML; + +$parser = xml_parser_create_ns('UTF-8'); +xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); +$result = xml_parse_into_struct($parser, $data, $vals, $index); +xml_parser_free($parser); +var_dump($vals); +?> +--EXPECT-- +array(1) { + [0]=> + array(5) { + ["tag"]=> + string(8) "resource" + ["type"]=> + string(8) "complete" + ["level"]=> + int(1) + ["attributes"]=> + array(2) { + ["key"]=> + string(7) "rSeeYou" + ["type"]=> + string(7) "literal" + } + ["value"]=> + string(13) "A bient&244;t" + } +} diff --git a/ext/xml/tests/bug43957.phpt b/ext/xml/tests/bug43957.phpt new file mode 100644 index 0000000..f11d156 --- /dev/null +++ b/ext/xml/tests/bug43957.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #43957 (utf8_decode() bogus conversion on multibyte indicator near end of string) +--SKIPIF-- +<?php +require_once("skipif.inc"); +if (!extension_loaded('xml')) die ("skip xml extension not available"); +?> +--FILE-- +<?php + echo utf8_decode('abc'.chr(0xe0)); +?> +--EXPECTF-- +abc? diff --git a/ext/xml/tests/bug46699.phpt b/ext/xml/tests/bug46699.phpt new file mode 100644 index 0000000..3996fd1 --- /dev/null +++ b/ext/xml/tests/bug46699.phpt @@ -0,0 +1,33 @@ +--TEST-- +Bug #46699: (xml_parse crash when parser is namespace aware) +--SKIPIF-- +<?php +require_once("skipif.inc"); +if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this platform");} +?> +--FILE-- +<?php +function defaultfunc($parser, $data) +{ +echo $data; +} + +$xml = <<<HERE +<a xmlns="http://example.com/foo" + xmlns:bar="http://example.com/bar"> + <bar:b foo="bar">1</bar:b> + <bar:c bar:nix="null" foo="bar">2</bar:c> +</a> +HERE; + +$parser = xml_parser_create_ns("ISO-8859-1","@"); +xml_set_default_handler($parser,'defaultfunc'); +xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); +xml_parse($parser, $xml); +xml_parser_free($parser); +?> +--EXPECT-- +<a xmlns="http://example.com/foo" xmlns:bar="http://example.com/bar"> + <bar:b foo="bar">1</bar:b> + <bar:c bar:nix="null" foo="bar">2</bar:c> +</a> diff --git a/ext/xml/tests/bug49687.phpt b/ext/xml/tests/bug49687.phpt new file mode 100644 index 0000000..3ff19ce --- /dev/null +++ b/ext/xml/tests/bug49687.phpt @@ -0,0 +1,24 @@ +--TEST--
+Bug #49687 Several utf8_decode deficiencies and vulnerabilities
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+if (!extension_loaded('xml')) die ("skip xml extension not available");
+?>
+--FILE--
+<?php
+
+$tests = array(
+ "\x41\xC2\x3E\x42",
+ "\xE3\x80\x22",
+ "\x41\x98\xBA\x42\xE2\x98\x43\xE2\x98\xBA\xE2\x98",
+);
+foreach ($tests as $t) {
+ echo bin2hex(utf8_decode($t)), "\n";
+}
+echo "Done.\n";
+--EXPECT--
+413f3e42
+3f22
+413f3f423f433f3f
+Done.
diff --git a/ext/xml/tests/bug50576.phpt b/ext/xml/tests/bug50576.phpt new file mode 100644 index 0000000..fd3d0cb --- /dev/null +++ b/ext/xml/tests/bug50576.phpt @@ -0,0 +1,133 @@ +--TEST-- +Bug #50576 (XML_OPTION_SKIP_TAGSTART option has no effect) +--SKIPIF-- +<?php +require_once("skipif.inc"); +?> +--FILE-- +<?php + +$XML = <<<XML +<?xml version="1.0"?> +<ns1:listOfAwards xmlns:ns1="http://www.fpdsng.com/FPDS"> +<ns1:count> +<ns1:total>867</ns1:total> +</ns1:count> +</ns1:listOfAwards> +XML; + +$xml_parser = xml_parser_create(); +xml_parser_set_option($xml_parser, XML_OPTION_SKIP_TAGSTART, 4); +xml_parse_into_struct($xml_parser, $XML, $vals, $index); +echo 'Index array' . PHP_EOL; +print_r($index); +echo 'Vals array' . PHP_EOL; +print_r($vals); +xml_parser_free($xml_parser); + +function startElement($parser, $name, $attribs) { echo $name . PHP_EOL; } +function endElement($parser, $name) { echo $name . PHP_EOL; } +$xml_parser = xml_parser_create(); +xml_set_element_handler($xml_parser, 'startElement', 'endElement'); +xml_parser_set_option($xml_parser, XML_OPTION_SKIP_TAGSTART, 4); +xml_parse($xml_parser, $XML); +xml_parser_free($xml_parser); + +?> +--EXPECTF-- +Index array +Array +( + [LISTOFAWARDS] => Array + ( + [0] => 0 + [1] => 5 + [2] => 6 + ) + + [COUNT] => Array + ( + [0] => 1 + [1] => 3 + [2] => 4 + ) + + [TOTAL] => Array + ( + [0] => 2 + ) + +) +Vals array +Array +( + [0] => Array + ( + [tag] => LISTOFAWARDS + [type] => open + [level] => 1 + [attributes] => Array + ( + [XMLNS:NS1] => http://www.fpdsng.com/FPDS + ) + + [value] => + + ) + + [1] => Array + ( + [tag] => COUNT + [type] => open + [level] => 2 + [value] => + + ) + + [2] => Array + ( + [tag] => TOTAL + [type] => complete + [level] => 3 + [value] => 867 + ) + + [3] => Array + ( + [tag] => COUNT + [value] => + + [type] => cdata + [level] => 2 + ) + + [4] => Array + ( + [tag] => COUNT + [type] => close + [level] => 2 + ) + + [5] => Array + ( + [tag] => LISTOFAWARDS + [value] => + + [type] => cdata + [level] => 1 + ) + + [6] => Array + ( + [tag] => LISTOFAWARDS + [type] => close + [level] => 1 + ) + +) +LISTOFAWARDS +COUNT +TOTAL +TOTAL +COUNT +LISTOFAWARDS diff --git a/ext/xml/tests/bug62328.phpt b/ext/xml/tests/bug62328.phpt new file mode 100644 index 0000000..e4c3c59 --- /dev/null +++ b/ext/xml/tests/bug62328.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #62328 (implementing __toString and a cast to string fails) +--SKIPIF-- +<?php +require_once("skipif.inc"); +?> +--FILE-- +<?php +class UberSimpleXML extends SimpleXMLElement { + public function __toString() { + return 'stringification'; + } +} + +$xml = new UberSimpleXML('<xml/>'); + +var_dump((string) $xml); +var_dump($xml->__toString()); +--EXPECT-- +string(15) "stringification" +string(15) "stringification" diff --git a/ext/xml/tests/inc.ent b/ext/xml/tests/inc.ent new file mode 100644 index 0000000..8f86465 --- /dev/null +++ b/ext/xml/tests/inc.ent @@ -0,0 +1 @@ +<!ENTITY included-entity "This is text included from an entity"> diff --git a/ext/xml/tests/skipif.inc b/ext/xml/tests/skipif.inc new file mode 100644 index 0000000..44898f3 --- /dev/null +++ b/ext/xml/tests/skipif.inc @@ -0,0 +1,10 @@ +<?php +// DO NOT dl load extension +//if (!extension_loaded("xml")) { +// $dlext = (substr(PHP_OS, 0, 3) == "WIN") ? ".dll" : ".so"; +// @dl("xml$dlext"); +//} +if (!extension_loaded("xml")) { + die('skip xml extension not available'); +} +?> diff --git a/ext/xml/tests/utf8_decode_error.phpt b/ext/xml/tests/utf8_decode_error.phpt new file mode 100644 index 0000000..8735fd8 --- /dev/null +++ b/ext/xml/tests/utf8_decode_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test utf8_decode() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto string utf8_decode(string data) + * Description: Converts a UTF-8 encoded string to ISO-8859-1 + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing utf8_decode() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing utf8_decode() function with Zero arguments --\n"; +var_dump( utf8_decode() ); + +//Test utf8_decode with one more than the expected number of arguments +echo "\n-- Testing utf8_decode() function with more than expected no. of arguments --\n"; +$data = 'string_val'; +$extra_arg = 10; +var_dump( utf8_decode($data, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing utf8_decode() : error conditions *** + +-- Testing utf8_decode() function with Zero arguments -- + +Warning: utf8_decode() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing utf8_decode() function with more than expected no. of arguments -- + +Warning: utf8_decode() expects exactly 1 parameter, 2 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/utf8_decode_variation1.phpt b/ext/xml/tests/utf8_decode_variation1.phpt new file mode 100644 index 0000000..4b9679a --- /dev/null +++ b/ext/xml/tests/utf8_decode_variation1.phpt @@ -0,0 +1,176 @@ +--TEST-- +Test utf8_decode() function : usage variations - different types for data +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto string utf8_decode(string data) + * Description: Converts a UTF-8 encoded string to ISO-8859-1 + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing utf8_decode() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} + +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // object data + new aClass(), + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for data + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( utf8_decode($value) ); +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing utf8_decode() : usage variations *** + +Arg value 0 +string(1) "0" + +Arg value 1 +string(1) "1" + +Arg value 12345 +string(5) "12345" + +Arg value -2345 +string(5) "-2345" + +Arg value 10.5 +string(4) "10.5" + +Arg value -10.5 +string(5) "-10.5" + +Arg value 101234567000 +string(12) "101234567000" + +Arg value 1.07654321E-9 +string(13) "1.07654321E-9" + +Arg value 0.5 +string(3) "0.5" + +Arg value Array + +Warning: utf8_decode() expects parameter 1 to be string, array given in %s on line %d +NULL + +Arg value Array + +Warning: utf8_decode() expects parameter 1 to be string, array given in %s on line %d +NULL + +Arg value Array + +Warning: utf8_decode() expects parameter 1 to be string, array given in %s on line %d +NULL + +Arg value Array + +Warning: utf8_decode() expects parameter 1 to be string, array given in %s on line %d +NULL + +Arg value Array + +Warning: utf8_decode() expects parameter 1 to be string, array given in %s on line %d +NULL + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value 1 +string(1) "1" + +Arg value +string(0) "" + +Arg value 1 +string(1) "1" + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value Some Ascii Data +string(15) "Some Ascii Data" + +Arg value +string(0) "" + +Arg value +string(0) "" +Done + diff --git a/ext/xml/tests/utf8_encode_error.phpt b/ext/xml/tests/utf8_encode_error.phpt new file mode 100644 index 0000000..a82f98f --- /dev/null +++ b/ext/xml/tests/utf8_encode_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test utf8_encode() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto string utf8_encode(string data) + * Description: Encodes an ISO-8859-1 string to UTF-8 + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing utf8_encode() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing utf8_encode() function with Zero arguments --\n"; +var_dump( utf8_encode() ); + +//Test utf8_encode with one more than the expected number of arguments +echo "\n-- Testing utf8_encode() function with more than expected no. of arguments --\n"; +$data = 'string_val'; +$extra_arg = 10; +var_dump( utf8_encode($data, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing utf8_encode() : error conditions *** + +-- Testing utf8_encode() function with Zero arguments -- + +Warning: utf8_encode() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing utf8_encode() function with more than expected no. of arguments -- + +Warning: utf8_encode() expects exactly 1 parameter, 2 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/utf8_encode_variation1.phpt b/ext/xml/tests/utf8_encode_variation1.phpt new file mode 100644 index 0000000..04b956c --- /dev/null +++ b/ext/xml/tests/utf8_encode_variation1.phpt @@ -0,0 +1,176 @@ +--TEST-- +Test utf8_encode() function : usage variations - <type here specifics of this variation> +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto string utf8_encode(string data) + * Description: Encodes an ISO-8859-1 string to UTF-8 + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing utf8_encode() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} + +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // object data + new aClass(), + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for data + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( utf8_encode($value) ); +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing utf8_encode() : usage variations *** + +Arg value 0 +string(1) "0" + +Arg value 1 +string(1) "1" + +Arg value 12345 +string(5) "12345" + +Arg value -2345 +string(5) "-2345" + +Arg value 10.5 +string(4) "10.5" + +Arg value -10.5 +string(5) "-10.5" + +Arg value 101234567000 +string(12) "101234567000" + +Arg value 1.07654321E-9 +string(13) "1.07654321E-9" + +Arg value 0.5 +string(3) "0.5" + +Arg value Array + +Warning: utf8_encode() expects parameter 1 to be string, array given in %s on line %d +NULL + +Arg value Array + +Warning: utf8_encode() expects parameter 1 to be string, array given in %s on line %d +NULL + +Arg value Array + +Warning: utf8_encode() expects parameter 1 to be string, array given in %s on line %d +NULL + +Arg value Array + +Warning: utf8_encode() expects parameter 1 to be string, array given in %s on line %d +NULL + +Arg value Array + +Warning: utf8_encode() expects parameter 1 to be string, array given in %s on line %d +NULL + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value 1 +string(1) "1" + +Arg value +string(0) "" + +Arg value 1 +string(1) "1" + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value Some Ascii Data +string(15) "Some Ascii Data" + +Arg value +string(0) "" + +Arg value +string(0) "" +Done + diff --git a/ext/xml/tests/xml001.phpt b/ext/xml/tests/xml001.phpt new file mode 100644 index 0000000..9c03b55 --- /dev/null +++ b/ext/xml/tests/xml001.phpt @@ -0,0 +1,97 @@ +--TEST-- +XML parser test, function callbacks +--SKIPIF-- +<?php +require_once("skipif.inc"); +XML_SAX_IMPL == 'libxml' && die('skip this test is not intended for libxml SAX parser'); +?> +--FILE-- +<?php +chdir(dirname(__FILE__)); + +$xml_parser = xml_parser_create(); +xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 1); +xml_set_element_handler($xml_parser, "startElement", "endElement"); +xml_set_character_data_handler($xml_parser, "characterData"); +xml_set_processing_instruction_handler($xml_parser, "PIHandler"); +xml_set_default_handler($xml_parser, "defaultHandler"); +xml_set_external_entity_ref_handler($xml_parser, "externalEntityRefHandler"); + +if (!($fp = @fopen("xmltest.xml", "r"))) { + die("could not open XML input"); +} + +while ($data = fread($fp, 4096)) { + if (!xml_parse($xml_parser, $data, feof($fp))) { + die(sprintf("XML error: %s at line %d\n", + xml_error_string(xml_get_error_code($xml_parser)), + xml_get_current_line_number($xml_parser))); + } +} +print "parse complete\n"; +xml_parser_free($xml_parser); + +function startElement($parser, $name, $attribs) +{ + print '{'.$name; + if (sizeof($attribs)) { + while (list($k, $v) = each($attribs)) { + print " $k=\"$v\""; + } + } + print '}'; +} + +function endElement($parser, $name) +{ + print '{/'.$name.'}'; +} + +function characterData($parser, $data) +{ + print '{CDATA['.$data.']}'; +} + +function PIHandler($parser, $target, $data) +{ + print '{PI['.$target.','.$data.']}'; +} + +function defaultHandler($parser, $data) +{ + if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") { + print '{ENTREF['.$data.']}'; + } else { + print '{?['.$data.']}'; + } +} + +function externalEntityRefHandler($parser, $openEntityNames, $base, $systemId, $publicId) +{ + print '{EXTENTREF['.$openEntityNames.','.$base.','.$systemId.','.$publicId."]}\n"; + return true; +} + +?> +--EXPECT-- +{?[<?xml version="1.0" encoding="ISO-8859-1"?>]}{?[ +]}{?[<!DOCTYPE]}{?[ ]}{?[phptest]}{?[ ]}{?[SYSTEM]}{?[ ]}{?["notfound.dtd"]}{?[ ]}{?[[]}{?[ +]}{?[<!ENTITY]}{?[ ]}{?[%]}{?[ ]}{?[incent]}{?[ ]}{?[SYSTEM]}{?[ ]}{?["inc.ent"]}{?[>]}{?[ +]}{?[%incent;]}{?[ +]}{?[]]}{?[>]}{?[ +]}{ROOT ID="elem1"}{CDATA[ +]}{CDATA[ Plain text.]}{CDATA[ +]}{CDATA[ ]}{ELEM1}{CDATA[ +]}{CDATA[ ]}{?[<!-- comment -->]}{CDATA[ +]}{CDATA[ ]}{ELEM2}{CDATA[ +]}{CDATA[ ]}{?[<![CDATA[]}{CDATA[CDATA block]}{?[]]>]}{CDATA[ +]}{CDATA[ ]}{ELEM3}{CDATA[ +]}{CDATA[ ]}{ENTREF[&included-entity;]}{CDATA[ +]}{CDATA[ ]}{ELEM4}{CDATA[ +]}{CDATA[ ]}{PI[test,processing instruction ]}{CDATA[ +]}{CDATA[ ]}{/ELEM4}{CDATA[ +]}{CDATA[ ]}{/ELEM3}{CDATA[ +]}{CDATA[ ]}{/ELEM2}{CDATA[ +]}{CDATA[ ]}{/ELEM1}{CDATA[ +]}{/ROOT}{?[ +]}parse complete diff --git a/ext/xml/tests/xml002.phpt b/ext/xml/tests/xml002.phpt new file mode 100644 index 0000000..ce547e8 --- /dev/null +++ b/ext/xml/tests/xml002.phpt @@ -0,0 +1,98 @@ +--TEST-- +XML parser test, object tuple callbacks +--SKIPIF-- +<?php +require_once("skipif.inc"); +XML_SAX_IMPL == 'libxml' && die('skip this test is not intended for libxml SAX parser'); +?> +--FILE-- +<?php +chdir(dirname(__FILE__)); + +class myclass +{ + function startElement($parser, $name, $attribs) + { + print '{'.$name; + if (sizeof($attribs)) { + while (list($k, $v) = each($attribs)) { + print " $k=\"$v\""; + } + } + print '}'; + } + function endElement($parser, $name) + { + print '{/'.$name.'}'; + } + function characterData($parser, $data) + { + print '{CDATA['.$data.']}'; + } + function PIHandler($parser, $target, $data) + { + print '{PI['.$target.','.$data.']}'; + } + function defaultHandler($parser, $data) + { + if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") { + print '{ENTREF['.$data.']}'; + } else { + print '{?['.$data.']}'; + } + } + function externalEntityRefHandler($parser, $openEntityNames, $base, $systemId, $publicId) + { + print '{EXTENTREF['.$openEntityNames.','.$base.','.$systemId.','.$publicId."]}\n"; + return true; + } +} + +$xml_parser = xml_parser_create(); +$obj = new myclass; +xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 1); +xml_set_element_handler($xml_parser, array($obj,"startElement"), +array($obj, "endElement")); +xml_set_character_data_handler($xml_parser, array($obj, "characterData")); +xml_set_processing_instruction_handler($xml_parser, array($obj, "PIHandler")); +xml_set_default_handler($xml_parser, array($obj, "defaultHandler")); +xml_set_external_entity_ref_handler($xml_parser, +array($obj, "externalEntityRefHandler")); + +if (!($fp = @fopen("xmltest.xml", "r"))) { + die("could not open XML input"); +} + +while ($data = fread($fp, 4096)) { + if (!xml_parse($xml_parser, $data, feof($fp))) { + die(sprintf("XML error: %s at line %d\n", + xml_error_string(xml_get_error_code($xml_parser)), + xml_get_current_line_number($xml_parser))); + } +} +print "parse complete\n"; +xml_parser_free($xml_parser); + +?> +--EXPECT-- +{?[<?xml version="1.0" encoding="ISO-8859-1"?>]}{?[ +]}{?[<!DOCTYPE]}{?[ ]}{?[phptest]}{?[ ]}{?[SYSTEM]}{?[ ]}{?["notfound.dtd"]}{?[ ]}{?[[]}{?[ +]}{?[<!ENTITY]}{?[ ]}{?[%]}{?[ ]}{?[incent]}{?[ ]}{?[SYSTEM]}{?[ ]}{?["inc.ent"]}{?[>]}{?[ +]}{?[%incent;]}{?[ +]}{?[]]}{?[>]}{?[ +]}{ROOT ID="elem1"}{CDATA[ +]}{CDATA[ Plain text.]}{CDATA[ +]}{CDATA[ ]}{ELEM1}{CDATA[ +]}{CDATA[ ]}{?[<!-- comment -->]}{CDATA[ +]}{CDATA[ ]}{ELEM2}{CDATA[ +]}{CDATA[ ]}{?[<![CDATA[]}{CDATA[CDATA block]}{?[]]>]}{CDATA[ +]}{CDATA[ ]}{ELEM3}{CDATA[ +]}{CDATA[ ]}{ENTREF[&included-entity;]}{CDATA[ +]}{CDATA[ ]}{ELEM4}{CDATA[ +]}{CDATA[ ]}{PI[test,processing instruction ]}{CDATA[ +]}{CDATA[ ]}{/ELEM4}{CDATA[ +]}{CDATA[ ]}{/ELEM3}{CDATA[ +]}{CDATA[ ]}{/ELEM2}{CDATA[ +]}{CDATA[ ]}{/ELEM1}{CDATA[ +]}{/ROOT}{?[ +]}parse complete diff --git a/ext/xml/tests/xml003.phpt b/ext/xml/tests/xml003.phpt new file mode 100644 index 0000000..6b0c3f5 --- /dev/null +++ b/ext/xml/tests/xml003.phpt @@ -0,0 +1,96 @@ +--TEST-- +XML parser test, xml_set_object callbacks +--SKIPIF-- +<?php +require_once("skipif.inc"); +XML_SAX_IMPL == 'libxml' && die('skip this test is not intended for libxml SAX parser'); +?> +--FILE-- +<?php +chdir(dirname(__FILE__)); + +class myclass +{ + function startElement($parser, $name, $attribs) + { + print '{'.$name; + if (sizeof($attribs)) { + while (list($k, $v) = each($attribs)) { + print " $k=\"$v\""; + } + } + print '}'; + } + function endElement($parser, $name) + { + print '{/'.$name.'}'; + } + function characterData($parser, $data) + { + print '{CDATA['.$data.']}'; + } + function PIHandler($parser, $target, $data) + { + print '{PI['.$target.','.$data.']}'; + } + function defaultHandler($parser, $data) + { + if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") { + print '{ENTREF['.$data.']}'; + } else { + print '{?['.$data.']}'; + } + } + function externalEntityRefHandler($parser, $openEntityNames, $base, $systemId, $publicId) + { + print '{EXTENTREF['.$openEntityNames.','.$base.','.$systemId.','.$publicId."]}\n"; + return true; + } +} + +$xml_parser = xml_parser_create(); +$obj = new myclass; +xml_set_object($xml_parser, $obj); +xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 1); +xml_set_element_handler($xml_parser, "startElement", "endElement"); +xml_set_character_data_handler($xml_parser, "characterData"); +xml_set_processing_instruction_handler($xml_parser, "PIHandler"); +xml_set_default_handler($xml_parser, "defaultHandler"); +xml_set_external_entity_ref_handler($xml_parser, "externalEntityRefHandler"); + +if (!($fp = @fopen("xmltest.xml", "r"))) { + die("could not open XML input"); +} + +while ($data = fread($fp, 4096)) { + if (!xml_parse($xml_parser, $data, feof($fp))) { + die(sprintf("XML error: %s at line %d\n", + xml_error_string(xml_get_error_code($xml_parser)), + xml_get_current_line_number($xml_parser))); + } +} +print "parse complete\n"; +xml_parser_free($xml_parser); +?> +--EXPECT-- +{?[<?xml version="1.0" encoding="ISO-8859-1"?>]}{?[ +]}{?[<!DOCTYPE]}{?[ ]}{?[phptest]}{?[ ]}{?[SYSTEM]}{?[ ]}{?["notfound.dtd"]}{?[ ]}{?[[]}{?[ +]}{?[<!ENTITY]}{?[ ]}{?[%]}{?[ ]}{?[incent]}{?[ ]}{?[SYSTEM]}{?[ ]}{?["inc.ent"]}{?[>]}{?[ +]}{?[%incent;]}{?[ +]}{?[]]}{?[>]}{?[ +]}{ROOT ID="elem1"}{CDATA[ +]}{CDATA[ Plain text.]}{CDATA[ +]}{CDATA[ ]}{ELEM1}{CDATA[ +]}{CDATA[ ]}{?[<!-- comment -->]}{CDATA[ +]}{CDATA[ ]}{ELEM2}{CDATA[ +]}{CDATA[ ]}{?[<![CDATA[]}{CDATA[CDATA block]}{?[]]>]}{CDATA[ +]}{CDATA[ ]}{ELEM3}{CDATA[ +]}{CDATA[ ]}{ENTREF[&included-entity;]}{CDATA[ +]}{CDATA[ ]}{ELEM4}{CDATA[ +]}{CDATA[ ]}{PI[test,processing instruction ]}{CDATA[ +]}{CDATA[ ]}{/ELEM4}{CDATA[ +]}{CDATA[ ]}{/ELEM3}{CDATA[ +]}{CDATA[ ]}{/ELEM2}{CDATA[ +]}{CDATA[ ]}{/ELEM1}{CDATA[ +]}{/ROOT}{?[ +]}parse complete diff --git a/ext/xml/tests/xml004.phpt b/ext/xml/tests/xml004.phpt new file mode 100644 index 0000000..245a93f --- /dev/null +++ b/ext/xml/tests/xml004.phpt @@ -0,0 +1,62 @@ +--TEST-- +XML parser case folding test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +chdir(dirname(__FILE__)); + +$xp = xml_parser_create(); +xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false); +xml_set_element_handler($xp, "start_element", "end_element"); +$fp = fopen("xmltest.xml", "r"); +while ($data = fread($fp, 4096)) { + xml_parse($xp, $data, feof($fp)); +} +xml_parser_free($xp); +$xp = xml_parser_create(); +xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, true); +xml_set_element_handler($xp, "start_element", "end_element"); +$fp = fopen("xmltest.xml", "r"); +while ($data = fread($fp, 4096)) { + xml_parse($xp, $data, feof($fp)); +} +xml_parser_free($xp); + +function start_element($xp, $elem, $attribs) +{ + print "<$elem"; + if (sizeof($attribs)) { + while (list($k, $v) = each($attribs)) { + print " $k=\"$v\""; + } + } + print ">\n"; +} + +function end_element($xp, $elem) +{ + print "</$elem>\n"; +} +?> +--EXPECT-- +<root id="elem1"> +<elem1> +<elem2> +<elem3> +<elem4> +</elem4> +</elem3> +</elem2> +</elem1> +</root> +<ROOT ID="elem1"> +<ELEM1> +<ELEM2> +<ELEM3> +<ELEM4> +</ELEM4> +</ELEM3> +</ELEM2> +</ELEM1> +</ROOT> diff --git a/ext/xml/tests/xml006.phpt b/ext/xml/tests/xml006.phpt new file mode 100644 index 0000000..c714e85 --- /dev/null +++ b/ext/xml/tests/xml006.phpt @@ -0,0 +1,12 @@ +--TEST-- +UTF-8<->ISO Latin 1 encoding/decoding test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +printf("%s -> %s\n", urlencode("æ"), urlencode(utf8_encode("æ"))); +printf("%s <- %s\n", urlencode(utf8_decode(urldecode("%C3%A6"))), "%C3%A6"); +?> +--EXPECT-- +%E6 -> %C3%A6 +%E6 <- %C3%A6 diff --git a/ext/xml/tests/xml007.phpt b/ext/xml/tests/xml007.phpt new file mode 100644 index 0000000..377475b --- /dev/null +++ b/ext/xml/tests/xml007.phpt @@ -0,0 +1,53 @@ +--TEST-- +xml_parse_into_struct/umlauts in tags +--SKIPIF-- +<?php // vim600: syn=php +include("skipif.inc"); +if(strtoupper("äöüß") != "ÄÖÜß") +{ + die("skip strtoupper on non-ascii not supported on this platform"); +} +?> +--FILE-- +<?php +function startHandler($parser,$tag,$attr) +{ + var_dump($tag,$attr); +} + +function endHandler($parser,$tag) +{ + var_dump($tag); +} + +$xmldata = '<?xml version="1.0" encoding="ISO-8859-1"?><äöü üäß="Üäß">ÄÖÜ</äöü>'; +$parser = xml_parser_create('ISO-8859-1'); +xml_set_element_handler($parser, "startHandler", "endHandler"); +xml_parse_into_struct($parser, $xmldata, $struct, $index); +var_dump($struct); +?> +--EXPECT-- +string(3) "ÄÖÜ" +array(1) { + ["ÜÄß"]=> + string(3) "Üäß" +} +string(3) "ÄÖÜ" +array(1) { + [0]=> + array(5) { + ["tag"]=> + string(3) "ÄÖÜ" + ["type"]=> + string(8) "complete" + ["level"]=> + int(1) + ["attributes"]=> + array(1) { + ["ÜÄß"]=> + string(3) "Üäß" + } + ["value"]=> + string(3) "ÄÖÜ" + } +} diff --git a/ext/xml/tests/xml009.phpt b/ext/xml/tests/xml009.phpt new file mode 100644 index 0000000..84b89bb --- /dev/null +++ b/ext/xml/tests/xml009.phpt @@ -0,0 +1,35 @@ +--TEST-- +XML parser test, default namespaces +--SKIPIF-- +<?php +require_once("skipif.inc"); +if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this plattform");} +?> +--FILE-- +<?php +function start_elem($parser,$name,$attribs) { + var_dump($name); +} +function end_elem() +{ +} + +$xml = <<<HERE +<a xmlns="http://example.com/foo" + xmlns:bar="http://example.com/bar" + xmlns:baz="http://example.com/baz"> + <bar:b /> + <bar:c xmlns:bar="http://example.com/foo"/> +</a> +HERE; + +$parser = xml_parser_create_ns("ISO-8859-1","@"); +xml_set_element_handler($parser,'start_elem','end_elem'); +xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); +xml_parse($parser, $xml); +xml_parser_free($parser); +?> +--EXPECT-- +string(24) "http://example.com/foo@a" +string(24) "http://example.com/bar@b" +string(24) "http://example.com/foo@c" diff --git a/ext/xml/tests/xml010.phpt b/ext/xml/tests/xml010.phpt new file mode 100644 index 0000000..e968442 --- /dev/null +++ b/ext/xml/tests/xml010.phpt @@ -0,0 +1,39 @@ +--TEST-- +XML parser test, attributes +--SKIPIF-- +<?php +require_once("skipif.inc"); +if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this plattform");} +?> +--FILE-- +<?php +function start_elem($parser,$name,$attribs) { + print "$name "; + + foreach($attribs as $key => $value) { + print "$key = $value "; + } + print "\n"; +} +function end_elem() +{ +} + +$xml = <<<HERE +<a xmlns="http://example.com/foo" + xmlns:bar="http://example.com/bar"> + <bar:b foo="bar"/> + <bar:c bar:nix="null" foo="bar"/> +</a> +HERE; + +$parser = xml_parser_create_ns("ISO-8859-1","@"); +xml_set_element_handler($parser,'start_elem','end_elem'); +xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); +xml_parse($parser, $xml); +xml_parser_free($parser); +?> +--EXPECT-- +http://example.com/foo@a +http://example.com/bar@b foo = bar +http://example.com/bar@c http://example.com/bar@nix = null foo = bar diff --git a/ext/xml/tests/xml011.phpt b/ext/xml/tests/xml011.phpt new file mode 100644 index 0000000..9c4cfca --- /dev/null +++ b/ext/xml/tests/xml011.phpt @@ -0,0 +1,71 @@ +--TEST-- +XML Parser test: concat character data and set empty handlers +--SKIPIF-- +<?php +require_once("skipif.inc"); +?> +--FILE-- +<?php +function start_elem($parser,$name,$attribs) { + echo "<$name>"; +} +function end_elem() +{ + echo "</$name>"; +} + +$xml = '<text>start<b /> This & that</text>'; + +$parser = xml_parser_create(); +xml_parse_into_struct($parser, $xml, $vals, $index); +print_r($vals); +xml_parser_free($parser); + +echo "\nChange to empty end handler\n"; +$parser = xml_parser_create(); +xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); +xml_set_element_handler($parser,'start_elem','end_elem'); +xml_set_element_handler($parser,'start_elem',NULL); +xml_parse($parser, $xml, TRUE); + +xml_parser_free($parser); +echo "\nDone\n"; +?> +--EXPECT-- +Array +( + [0] => Array + ( + [tag] => TEXT + [type] => open + [level] => 1 + [value] => start + ) + + [1] => Array + ( + [tag] => B + [type] => complete + [level] => 2 + ) + + [2] => Array + ( + [tag] => TEXT + [value] => This & that + [type] => cdata + [level] => 1 + ) + + [3] => Array + ( + [tag] => TEXT + [type] => close + [level] => 1 + ) + +) + +Change to empty end handler +<text><b> +Done diff --git a/ext/xml/tests/xml_closures_001.phpt b/ext/xml/tests/xml_closures_001.phpt new file mode 100644 index 0000000..37df254 --- /dev/null +++ b/ext/xml/tests/xml_closures_001.phpt @@ -0,0 +1,45 @@ +--TEST-- +XML parser test using closures as callbacks +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +chdir(dirname(__FILE__)); + +$start_element = function ($xp, $elem, $attribs) +{ + print "<$elem"; + if (sizeof($attribs)) { + while (list($k, $v) = each($attribs)) { + print " $k=\"$v\""; + } + } + print ">\n"; +}; + +$end_element = function ($xp, $elem) +{ + print "</$elem>\n"; +}; + +$xp = xml_parser_create(); +xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false); +xml_set_element_handler($xp, $start_element, $end_element); +$fp = fopen("xmltest.xml", "r"); +while ($data = fread($fp, 4096)) { + xml_parse($xp, $data, feof($fp)); +} +xml_parser_free($xp); + +?> +--EXPECT-- +<root id="elem1"> +<elem1> +<elem2> +<elem3> +<elem4> +</elem4> +</elem3> +</elem2> +</elem1> +</root> diff --git a/ext/xml/tests/xml_error_string_error.phpt b/ext/xml/tests/xml_error_string_error.phpt new file mode 100644 index 0000000..866346f --- /dev/null +++ b/ext/xml/tests/xml_error_string_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test xml_error_string() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto string xml_error_string(int code) + * Description: Get XML parser error string + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_error_string() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing xml_error_string() function with Zero arguments --\n"; +var_dump( xml_error_string() ); + +//Test xml_error_string with one more than the expected number of arguments +echo "\n-- Testing xml_error_string() function with more than expected no. of arguments --\n"; +$code = 10; +$extra_arg = 10; +var_dump( xml_error_string($code, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_error_string() : error conditions *** + +-- Testing xml_error_string() function with Zero arguments -- + +Warning: xml_error_string() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing xml_error_string() function with more than expected no. of arguments -- + +Warning: xml_error_string() expects exactly 1 parameter, 2 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_error_string_variation1.phpt b/ext/xml/tests/xml_error_string_variation1.phpt new file mode 100644 index 0000000..40b542c --- /dev/null +++ b/ext/xml/tests/xml_error_string_variation1.phpt @@ -0,0 +1,179 @@ +--TEST-- +Test xml_error_string() function : usage variations - test different types for code +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto string xml_error_string(int code) + * Description: Get XML parser error string + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_error_string() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} + +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for code + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_error_string($value) ); +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_error_string() : usage variations *** + +Arg value 10.5 +string(22) "XML_ERR_CHARREF_AT_EOF" + +Arg value -10.5 +string(7) "Unknown" + +Arg value 101234567000 +string(7) "Unknown" + +Arg value 1.07654321E-9 +string(8) "No error" + +Arg value 0.5 +string(8) "No error" + +Arg value Array + +Warning: xml_error_string() expects parameter 1 to be long, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_error_string() expects parameter 1 to be long, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_error_string() expects parameter 1 to be long, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_error_string() expects parameter 1 to be long, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_error_string() expects parameter 1 to be long, array given in %s on line %d +NULL + +Arg value +string(8) "No error" + +Arg value +string(8) "No error" + +Arg value 1 +string(9) "No memory" + +Arg value +string(8) "No error" + +Arg value 1 +string(9) "No memory" + +Arg value +string(8) "No error" + +Arg value + +Warning: xml_error_string() expects parameter 1 to be long, string given in %s on line %d +NULL + +Arg value + +Warning: xml_error_string() expects parameter 1 to be long, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_error_string() expects parameter 1 to be long, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_error_string() expects parameter 1 to be long, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_error_string() expects parameter 1 to be long, object given in %s on line %d +NULL + +Arg value +string(8) "No error" + +Arg value +string(8) "No error" +Done + + diff --git a/ext/xml/tests/xml_get_current_byte_index_error.phpt b/ext/xml/tests/xml_get_current_byte_index_error.phpt new file mode 100644 index 0000000..74fa2e7 --- /dev/null +++ b/ext/xml/tests/xml_get_current_byte_index_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test xml_get_current_byte_index() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_get_current_byte_index(resource parser) + * Description: Get current byte index for an XML parser + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_get_current_byte_index() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing xml_get_current_byte_index() function with Zero arguments --\n"; +var_dump( xml_get_current_byte_index() ); + +//Test xml_get_current_byte_index with one more than the expected number of arguments +echo "\n-- Testing xml_get_current_byte_index() function with more than expected no. of arguments --\n"; + +$extra_arg = 10; +var_dump( xml_get_current_byte_index(null, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_get_current_byte_index() : error conditions *** + +-- Testing xml_get_current_byte_index() function with Zero arguments -- + +Warning: xml_get_current_byte_index() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing xml_get_current_byte_index() function with more than expected no. of arguments -- + +Warning: xml_get_current_byte_index() expects exactly 1 parameter, 2 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_get_current_byte_index_variation1.phpt b/ext/xml/tests/xml_get_current_byte_index_variation1.phpt new file mode 100644 index 0000000..b5c83d7 --- /dev/null +++ b/ext/xml/tests/xml_get_current_byte_index_variation1.phpt @@ -0,0 +1,240 @@ +--TEST-- +Test xml_get_current_byte_index() function : usage variations - <type here specifics of this variation> +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_get_current_byte_index(resource parser) + * Description: Get current byte index for an XML parser + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_get_current_byte_index() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for parser + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_get_current_byte_index($value) ); +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_get_current_byte_index() : usage variations *** + +Arg value 0 + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 12345 + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value -2345 + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 10.5 + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value -10.5 + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 101234567000 + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 1.07654321E-9 + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 0.5 + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value Array + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, object given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_get_current_byte_index(): supplied resource is not a valid XML Parser resource in %s on line %d +bool(false) + +Arg value + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_byte_index() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_get_current_column_number_error.phpt b/ext/xml/tests/xml_get_current_column_number_error.phpt new file mode 100644 index 0000000..1fd28cc --- /dev/null +++ b/ext/xml/tests/xml_get_current_column_number_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test xml_get_current_column_number() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_get_current_column_number(resource parser) + * Description: Get current column number for an XML parser + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_get_current_column_number() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing xml_get_current_column_number() function with Zero arguments --\n"; +var_dump( xml_get_current_column_number() ); + +//Test xml_get_current_column_number with one more than the expected number of arguments +echo "\n-- Testing xml_get_current_column_number() function with more than expected no. of arguments --\n"; + +$extra_arg = 10; +var_dump( xml_get_current_column_number(null, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_get_current_column_number() : error conditions *** + +-- Testing xml_get_current_column_number() function with Zero arguments -- + +Warning: xml_get_current_column_number() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing xml_get_current_column_number() function with more than expected no. of arguments -- + +Warning: xml_get_current_column_number() expects exactly 1 parameter, 2 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_get_current_column_number_variation1.phpt b/ext/xml/tests/xml_get_current_column_number_variation1.phpt new file mode 100644 index 0000000..0eeb8d0 --- /dev/null +++ b/ext/xml/tests/xml_get_current_column_number_variation1.phpt @@ -0,0 +1,241 @@ +--TEST-- +Test xml_get_current_column_number() function : usage variations +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_get_current_column_number(resource parser) + * Description: Get current column number for an XML parser + * Source code: ext/xml/xml.c + * Alias to functions: + */ + + +echo "*** Testing xml_get_current_column_number() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for parser + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_get_current_column_number($value) ); +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_get_current_column_number() : usage variations *** + +Arg value 0 + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 12345 + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value -2345 + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 10.5 + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value -10.5 + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 101234567000 + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 1.07654321E-9 + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 0.5 + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value Array + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, object given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_get_current_column_number(): supplied resource is not a valid XML Parser resource in %s on line %d +bool(false) + +Arg value + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_column_number() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_get_current_line_number_error.phpt b/ext/xml/tests/xml_get_current_line_number_error.phpt new file mode 100644 index 0000000..282c120 --- /dev/null +++ b/ext/xml/tests/xml_get_current_line_number_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test xml_get_current_line_number() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_get_current_line_number(resource parser) + * Description: Get current line number for an XML parser + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_get_current_line_number() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing xml_get_current_line_number() function with Zero arguments --\n"; +var_dump( xml_get_current_line_number() ); + +//Test xml_get_current_line_number with one more than the expected number of arguments +echo "\n-- Testing xml_get_current_line_number() function with more than expected no. of arguments --\n"; + +$extra_arg = 10; +var_dump( xml_get_current_line_number(null, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_get_current_line_number() : error conditions *** + +-- Testing xml_get_current_line_number() function with Zero arguments -- + +Warning: xml_get_current_line_number() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing xml_get_current_line_number() function with more than expected no. of arguments -- + +Warning: xml_get_current_line_number() expects exactly 1 parameter, 2 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_get_current_line_number_variation1.phpt b/ext/xml/tests/xml_get_current_line_number_variation1.phpt new file mode 100644 index 0000000..af41c6f --- /dev/null +++ b/ext/xml/tests/xml_get_current_line_number_variation1.phpt @@ -0,0 +1,240 @@ +--TEST-- +Test xml_get_current_line_number() function : usage variations +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_get_current_line_number(resource parser) + * Description: Get current line number for an XML parser + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_get_current_line_number() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for parser + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_get_current_line_number($value) ); +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_get_current_line_number() : usage variations *** + +Arg value 0 + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 12345 + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value -2345 + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 10.5 + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value -10.5 + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 101234567000 + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 1.07654321E-9 + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 0.5 + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value Array + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, object given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_get_current_line_number(): supplied resource is not a valid XML Parser resource in %s on line %d +bool(false) + +Arg value + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_get_current_line_number() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_get_error_code_error.phpt b/ext/xml/tests/xml_get_error_code_error.phpt new file mode 100644 index 0000000..683734a --- /dev/null +++ b/ext/xml/tests/xml_get_error_code_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test xml_get_error_code() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_get_error_code(resource parser) + * Description: Get XML parser error code + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_get_error_code() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing xml_get_error_code() function with Zero arguments --\n"; +var_dump( xml_get_error_code() ); + +//Test xml_get_error_code with one more than the expected number of arguments +echo "\n-- Testing xml_get_error_code() function with more than expected no. of arguments --\n"; + +$extra_arg = 10; +var_dump( xml_get_error_code(null, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_get_error_code() : error conditions *** + +-- Testing xml_get_error_code() function with Zero arguments -- + +Warning: xml_get_error_code() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing xml_get_error_code() function with more than expected no. of arguments -- + +Warning: xml_get_error_code() expects exactly 1 parameter, 2 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_get_error_code_variation1.phpt b/ext/xml/tests/xml_get_error_code_variation1.phpt new file mode 100644 index 0000000..4749214 --- /dev/null +++ b/ext/xml/tests/xml_get_error_code_variation1.phpt @@ -0,0 +1,240 @@ +--TEST-- +Test xml_get_error_code() function : usage variations +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_get_error_code(resource parser) + * Description: Get XML parser error code + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_get_error_code() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for parser + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_get_error_code($value) ); +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_get_error_code() : usage variations *** + +Arg value 0 + +Warning: xml_get_error_code() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_get_error_code() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 12345 + +Warning: xml_get_error_code() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value -2345 + +Warning: xml_get_error_code() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 10.5 + +Warning: xml_get_error_code() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value -10.5 + +Warning: xml_get_error_code() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 101234567000 + +Warning: xml_get_error_code() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 1.07654321E-9 + +Warning: xml_get_error_code() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 0.5 + +Warning: xml_get_error_code() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value Array + +Warning: xml_get_error_code() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_get_error_code() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_get_error_code() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_get_error_code() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_get_error_code() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value + +Warning: xml_get_error_code() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_get_error_code() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_get_error_code() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_get_error_code() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_get_error_code() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_get_error_code() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_get_error_code() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value + +Warning: xml_get_error_code() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_get_error_code() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_get_error_code() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_get_error_code() expects parameter 1 to be resource, object given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_get_error_code(): supplied resource is not a valid XML Parser resource in %s on line %d +bool(false) + +Arg value + +Warning: xml_get_error_code() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_get_error_code() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_parse_error.phpt b/ext/xml/tests/xml_parse_error.phpt new file mode 100644 index 0000000..d8d8fff --- /dev/null +++ b/ext/xml/tests/xml_parse_error.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test xml_parse() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_parse(resource parser, string data [, int isFinal]) + * Description: Start parsing an XML document + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_parse() : error conditions ***\n"; + + +//Test xml_parse with one more than the expected number of arguments +echo "\n-- Testing xml_parse() function with more than expected no. of arguments --\n"; + +$data = 'string_val'; +$isFinal = false; +$extra_arg = 10; +var_dump( xml_parse(null, $data, $isFinal, $extra_arg) ); + +// Testing xml_parse with one less than the expected number of arguments +echo "\n-- Testing xml_parse() function with less than expected no. of arguments --\n"; + +var_dump( xml_parse(null) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_parse() : error conditions *** + +-- Testing xml_parse() function with more than expected no. of arguments -- + +Warning: xml_parse() expects at most 3 parameters, 4 given in %s on line %d +NULL + +-- Testing xml_parse() function with less than expected no. of arguments -- + +Warning: xml_parse() expects at least 2 parameters, 1 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_parse_into_struct_error.phpt b/ext/xml/tests/xml_parse_into_struct_error.phpt new file mode 100644 index 0000000..82a26ad --- /dev/null +++ b/ext/xml/tests/xml_parse_into_struct_error.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test xml_parse_into_struct() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_parse_into_struct(resource parser, string data, array &struct, array &index) + * Description: Parsing a XML document + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_parse_into_struct() : error conditions ***\n"; + +//Test xml_parse_into_struct with one more than the expected number of arguments +echo "\n-- Testing xml_parse_into_struct() function with more than expected no. of arguments --\n"; + +$data = 'string_val'; +$struct = array(1, 2); +$index = array(1, 2); +$extra_arg = 10; +var_dump( xml_parse_into_struct(null, $data, $struct, $index, $extra_arg) ); + +// Testing xml_parse_into_struct with one less than the expected number of arguments +echo "\n-- Testing xml_parse_into_struct() function with less than expected no. of arguments --\n"; + +$data = 'string_val'; +var_dump( xml_parse_into_struct(null, $data) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_parse_into_struct() : error conditions *** + +-- Testing xml_parse_into_struct() function with more than expected no. of arguments -- + +Warning: xml_parse_into_struct() expects at most 4 parameters, 5 given in %s on line %d +NULL + +-- Testing xml_parse_into_struct() function with less than expected no. of arguments -- + +Warning: xml_parse_into_struct() expects at least 3 parameters, 2 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_parse_into_struct_variation.phpt b/ext/xml/tests/xml_parse_into_struct_variation.phpt new file mode 100644 index 0000000..a353e51 --- /dev/null +++ b/ext/xml/tests/xml_parse_into_struct_variation.phpt @@ -0,0 +1,120 @@ +--TEST-- +Test xml_parse_into_struct() function : variation +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_parse_into_struct(resource parser, string data, array &struct, array &index) + * Description: Parsing a XML document + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_parse_into_struct() : variation ***\n"; + +$simple = "<main><para><note>simple note</note></para><para><note>simple note</note></para></main>"; +$p = xml_parser_create(); +xml_parse_into_struct($p, $simple, $vals, $index); +xml_parser_free($p); +echo "Index array\n"; +print_r($index); +echo "\nVals array\n"; +print_r($vals); + + +echo "Done"; +?> +--EXPECT-- +*** Testing xml_parse_into_struct() : variation *** +Index array +Array +( + [MAIN] => Array + ( + [0] => 0 + [1] => 7 + ) + + [PARA] => Array + ( + [0] => 1 + [1] => 3 + [2] => 4 + [3] => 6 + ) + + [NOTE] => Array + ( + [0] => 2 + [1] => 5 + ) + +) + +Vals array +Array +( + [0] => Array + ( + [tag] => MAIN + [type] => open + [level] => 1 + ) + + [1] => Array + ( + [tag] => PARA + [type] => open + [level] => 2 + ) + + [2] => Array + ( + [tag] => NOTE + [type] => complete + [level] => 3 + [value] => simple note + ) + + [3] => Array + ( + [tag] => PARA + [type] => close + [level] => 2 + ) + + [4] => Array + ( + [tag] => PARA + [type] => open + [level] => 2 + ) + + [5] => Array + ( + [tag] => NOTE + [type] => complete + [level] => 3 + [value] => simple note + ) + + [6] => Array + ( + [tag] => PARA + [type] => close + [level] => 2 + ) + + [7] => Array + ( + [tag] => MAIN + [type] => close + [level] => 1 + ) + +) +Done
\ No newline at end of file diff --git a/ext/xml/tests/xml_parse_into_struct_variation1.phpt b/ext/xml/tests/xml_parse_into_struct_variation1.phpt new file mode 100644 index 0000000..fa1e8d2 --- /dev/null +++ b/ext/xml/tests/xml_parse_into_struct_variation1.phpt @@ -0,0 +1,241 @@ +--TEST-- +Test xml_parse_into_struct() function : usage variations - different types for parser +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_parse_into_struct(resource parser, string data, array &struct, array &index) + * Description: Parsing a XML document + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_parse_into_struct() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} +// Initialise function arguments not being substituted (if any) +$data = 'string_val'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for parser + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_parse_into_struct($value, $data, $struct, $index) ); +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_parse_into_struct() : usage variations *** + +Arg value 0 + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 12345 + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value -2345 + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 10.5 + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value -10.5 + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 101234567000 + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 1.07654321E-9 + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 0.5 + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, object given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_parse_into_struct(): supplied resource is not a valid XML Parser resource in %s on line %d +bool(false) + +Arg value + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_parse_into_struct() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_parse_variation1.phpt b/ext/xml/tests/xml_parse_variation1.phpt new file mode 100644 index 0000000..cf36666 --- /dev/null +++ b/ext/xml/tests/xml_parse_variation1.phpt @@ -0,0 +1,242 @@ +--TEST-- +Test xml_parse() function : usage variations - different types of parser +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_parse(resource parser, string data [, int isFinal]) + * Description: Start parsing an XML document + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_parse() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} +// Initialise function arguments not being substituted (if any) +$data = 'string_val'; +$isFinal = 10; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for parser + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_parse($value, $data, $isFinal) ); +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_parse() : usage variations *** + +Arg value 0 + +Warning: xml_parse() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_parse() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 12345 + +Warning: xml_parse() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value -2345 + +Warning: xml_parse() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 10.5 + +Warning: xml_parse() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value -10.5 + +Warning: xml_parse() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 101234567000 + +Warning: xml_parse() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 1.07654321E-9 + +Warning: xml_parse() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 0.5 + +Warning: xml_parse() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parse() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parse() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parse() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parse() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parse() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value + +Warning: xml_parse() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_parse() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_parse() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_parse() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_parse() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_parse() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_parse() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value + +Warning: xml_parse() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_parse() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_parse() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_parse() expects parameter 1 to be resource, object given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_parse(): supplied resource is not a valid XML Parser resource in %s on line %d +bool(false) + +Arg value + +Warning: xml_parse() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_parse() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_parser_create_error.phpt b/ext/xml/tests/xml_parser_create_error.phpt new file mode 100644 index 0000000..571350e --- /dev/null +++ b/ext/xml/tests/xml_parser_create_error.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test xml_parser_create() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto resource xml_parser_create([string encoding]) + * Description: Create an XML parser + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_parser_create() : error conditions ***\n"; + + +//Test xml_parser_create with one more than the expected number of arguments +echo "\n-- Testing xml_parser_create() function with more than expected no. of arguments --\n"; +$encoding = 'utf-8'; +$extra_arg = 10; +var_dump( xml_parser_create($encoding, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_parser_create() : error conditions *** + +-- Testing xml_parser_create() function with more than expected no. of arguments -- + +Warning: xml_parser_create() expects at most 1 parameter, 2 given in %s on line %d +bool(false) +Done diff --git a/ext/xml/tests/xml_parser_create_ns_error.phpt b/ext/xml/tests/xml_parser_create_ns_error.phpt new file mode 100644 index 0000000..fd50f29 --- /dev/null +++ b/ext/xml/tests/xml_parser_create_ns_error.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test xml_parser_create_ns() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto resource xml_parser_create_ns([string encoding [, string sep]]) + * Description: Create an XML parser + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_parser_create_ns() : error conditions ***\n"; + + +//Test xml_parser_create_ns with one more than the expected number of arguments +echo "\n-- Testing xml_parser_create_ns() function with more than expected no. of arguments --\n"; +$encoding = 'string_val'; +$sep = 'string_val'; +$extra_arg = 10; +var_dump( xml_parser_create_ns($encoding, $sep, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_parser_create_ns() : error conditions *** + +-- Testing xml_parser_create_ns() function with more than expected no. of arguments -- + +Warning: xml_parser_create_ns() expects at most 2 parameters, 3 given in %s on line %d +bool(false) +Done
\ No newline at end of file diff --git a/ext/xml/tests/xml_parser_create_ns_variation1.phpt b/ext/xml/tests/xml_parser_create_ns_variation1.phpt new file mode 100644 index 0000000..2818b82 --- /dev/null +++ b/ext/xml/tests/xml_parser_create_ns_variation1.phpt @@ -0,0 +1,245 @@ +--TEST-- +Test xml_parser_create_ns() function : usage variations +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto resource xml_parser_create_ns([string encoding [, string sep]]) + * Description: Create an XML parser + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_parser_create_ns() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + "ISO-8859-1", + "UTF-8", + "US-ASCII", + "UTF-32", + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for encoding + +foreach($values as $value) { + echo @"\nArg value $value \n"; + $res = xml_parser_create_ns($value); + var_dump($res); + if ($res !== false) { + xml_parser_free($res); + } +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_parser_create_ns() : usage variations *** + +Arg value 0 + +Warning: xml_parser_create_ns(): unsupported source encoding "0" in %s on line %d +bool(false) + +Arg value 1 + +Warning: xml_parser_create_ns(): unsupported source encoding "1" in %s on line %d +bool(false) + +Arg value 12345 + +Warning: xml_parser_create_ns(): unsupported source encoding "12345" in %s on line %d +bool(false) + +Arg value -2345 + +Warning: xml_parser_create_ns(): unsupported source encoding "-2345" in %s on line %d +bool(false) + +Arg value 10.5 + +Warning: xml_parser_create_ns(): unsupported source encoding "10.5" in %s on line %d +bool(false) + +Arg value -10.5 + +Warning: xml_parser_create_ns(): unsupported source encoding "-10.5" in %s on line %d +bool(false) + +Arg value 101234567000 + +Warning: xml_parser_create_ns(): unsupported source encoding "101234567000" in %s on line %d +bool(false) + +Arg value 1.07654321E-9 + +Warning: xml_parser_create_ns(): unsupported source encoding "1.07654321E-9" in %s on line %d +bool(false) + +Arg value 0.5 + +Warning: xml_parser_create_ns(): unsupported source encoding "0.5" in %s on line %d +bool(false) + +Arg value Array + +Warning: xml_parser_create_ns() expects parameter 1 to be string, array given in %s on line %d +bool(false) + +Arg value Array + +Warning: xml_parser_create_ns() expects parameter 1 to be string, array given in %s on line %d +bool(false) + +Arg value Array + +Warning: xml_parser_create_ns() expects parameter 1 to be string, array given in %s on line %d +bool(false) + +Arg value Array + +Warning: xml_parser_create_ns() expects parameter 1 to be string, array given in %s on line %d +bool(false) + +Arg value Array + +Warning: xml_parser_create_ns() expects parameter 1 to be string, array given in %s on line %d +bool(false) + +Arg value +resource(%d) of type (xml) + +Arg value +resource(%d) of type (xml) + +Arg value 1 + +Warning: xml_parser_create_ns(): unsupported source encoding "1" in %s on line %d +bool(false) + +Arg value +resource(%d) of type (xml) + +Arg value 1 + +Warning: xml_parser_create_ns(): unsupported source encoding "1" in %s on line %d +bool(false) + +Arg value +resource(%d) of type (xml) + +Arg value +resource(%d) of type (xml) + +Arg value +resource(%d) of type (xml) + +Arg value string + +Warning: xml_parser_create_ns(): unsupported source encoding "string" in %s on line %d +bool(false) + +Arg value string + +Warning: xml_parser_create_ns(): unsupported source encoding "string" in %s on line %d +bool(false) + +Arg value ISO-8859-1 +resource(%d) of type (xml) + +Arg value UTF-8 +resource(%d) of type (xml) + +Arg value US-ASCII +resource(%d) of type (xml) + +Arg value UTF-32 + +Warning: xml_parser_create_ns(): unsupported source encoding "UTF-32" in %s on line %d +bool(false) + +Arg value Some Ascii Data + +Warning: xml_parser_create_ns(): unsupported source encoding "Some Ascii Data" in %s on line %d +bool(false) + +Arg value Resource id %s + +Warning: xml_parser_create_ns() expects parameter 1 to be string, resource given in %s on line %d +bool(false) + +Arg value +resource(%d) of type (xml) + +Arg value +resource(%d) of type (xml) +Done diff --git a/ext/xml/tests/xml_parser_create_variation1.phpt b/ext/xml/tests/xml_parser_create_variation1.phpt new file mode 100644 index 0000000..c5d588f --- /dev/null +++ b/ext/xml/tests/xml_parser_create_variation1.phpt @@ -0,0 +1,245 @@ +--TEST-- +Test xml_parser_create() function : usage variations +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto resource xml_parser_create([string encoding]) + * Description: Create an XML parser + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_parser_create() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + "ISO-8859-1", + "UTF-8", + "US-ASCII", + "UTF-32", + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for encoding + +foreach($values as $value) { + echo @"\nArg value $value \n"; + $res = xml_parser_create($value); + var_dump($res); + if ($res !== false) { + xml_parser_free($res); + } +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_parser_create() : usage variations *** + +Arg value 0 + +Warning: xml_parser_create(): unsupported source encoding "0" in %s on line %d +bool(false) + +Arg value 1 + +Warning: xml_parser_create(): unsupported source encoding "1" in %s on line %d +bool(false) + +Arg value 12345 + +Warning: xml_parser_create(): unsupported source encoding "12345" in %s on line %d +bool(false) + +Arg value -2345 + +Warning: xml_parser_create(): unsupported source encoding "-2345" in %s on line %d +bool(false) + +Arg value 10.5 + +Warning: xml_parser_create(): unsupported source encoding "10.5" in %s on line %d +bool(false) + +Arg value -10.5 + +Warning: xml_parser_create(): unsupported source encoding "-10.5" in %s on line %d +bool(false) + +Arg value 101234567000 + +Warning: xml_parser_create(): unsupported source encoding "101234567000" in %s on line %d +bool(false) + +Arg value 1.07654321E-9 + +Warning: xml_parser_create(): unsupported source encoding "1.07654321E-9" in %s on line %d +bool(false) + +Arg value 0.5 + +Warning: xml_parser_create(): unsupported source encoding "0.5" in %s on line %d +bool(false) + +Arg value Array + +Warning: xml_parser_create() expects parameter 1 to be string, array given in %s on line %d +bool(false) + +Arg value Array + +Warning: xml_parser_create() expects parameter 1 to be string, array given in %s on line %d +bool(false) + +Arg value Array + +Warning: xml_parser_create() expects parameter 1 to be string, array given in %s on line %d +bool(false) + +Arg value Array + +Warning: xml_parser_create() expects parameter 1 to be string, array given in %s on line %d +bool(false) + +Arg value Array + +Warning: xml_parser_create() expects parameter 1 to be string, array given in %s on line %d +bool(false) + +Arg value +resource(%d) of type (xml) + +Arg value +resource(%d) of type (xml) + +Arg value 1 + +Warning: xml_parser_create(): unsupported source encoding "1" in %s on line %d +bool(false) + +Arg value +resource(%d) of type (xml) + +Arg value 1 + +Warning: xml_parser_create(): unsupported source encoding "1" in %s on line %d +bool(false) + +Arg value +resource(%d) of type (xml) + +Arg value +resource(%d) of type (xml) + +Arg value +resource(%d) of type (xml) + +Arg value string + +Warning: xml_parser_create(): unsupported source encoding "string" in %s on line %d +bool(false) + +Arg value string + +Warning: xml_parser_create(): unsupported source encoding "string" in %s on line %d +bool(false) + +Arg value ISO-8859-1 +resource(%d) of type (xml) + +Arg value UTF-8 +resource(%d) of type (xml) + +Arg value US-ASCII +resource(%d) of type (xml) + +Arg value UTF-32 + +Warning: xml_parser_create(): unsupported source encoding "UTF-32" in %s on line %d +bool(false) + +Arg value Some Ascii Data + +Warning: xml_parser_create(): unsupported source encoding "Some Ascii Data" in %s on line %d +bool(false) + +Arg value Resource id %s + +Warning: xml_parser_create() expects parameter 1 to be string, resource given in %s on line %d +bool(false) + +Arg value +resource(%d) of type (xml) + +Arg value +resource(%d) of type (xml) +Done
\ No newline at end of file diff --git a/ext/xml/tests/xml_parser_free_error.phpt b/ext/xml/tests/xml_parser_free_error.phpt new file mode 100644 index 0000000..13afb95 --- /dev/null +++ b/ext/xml/tests/xml_parser_free_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test xml_parser_free() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_parser_free(resource parser) + * Description: Free an XML parser + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_parser_free() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing xml_parser_free() function with Zero arguments --\n"; +var_dump( xml_parser_free() ); + +//Test xml_parser_free with one more than the expected number of arguments +echo "\n-- Testing xml_parser_free() function with more than expected no. of arguments --\n"; + +$extra_arg = 10; +var_dump( xml_parser_free(null, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_parser_free() : error conditions *** + +-- Testing xml_parser_free() function with Zero arguments -- + +Warning: xml_parser_free() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing xml_parser_free() function with more than expected no. of arguments -- + +Warning: xml_parser_free() expects exactly 1 parameter, 2 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_parser_free_variation1.phpt b/ext/xml/tests/xml_parser_free_variation1.phpt new file mode 100644 index 0000000..0ecb109 --- /dev/null +++ b/ext/xml/tests/xml_parser_free_variation1.phpt @@ -0,0 +1,240 @@ +--TEST-- +Test xml_parser_free() function : usage variations +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_parser_free(resource parser) + * Description: Free an XML parser + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_parser_free() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for parser + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_parser_free($value) ); +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_parser_free() : usage variations *** + +Arg value 0 + +Warning: xml_parser_free() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_parser_free() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 12345 + +Warning: xml_parser_free() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value -2345 + +Warning: xml_parser_free() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 10.5 + +Warning: xml_parser_free() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value -10.5 + +Warning: xml_parser_free() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 101234567000 + +Warning: xml_parser_free() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 1.07654321E-9 + +Warning: xml_parser_free() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 0.5 + +Warning: xml_parser_free() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_free() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_free() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_free() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_free() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_free() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_free() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_free() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_parser_free() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_free() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_parser_free() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_free() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_free() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_free() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_parser_free() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_parser_free() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_parser_free() expects parameter 1 to be resource, object given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_parser_free(): supplied resource is not a valid XML Parser resource in %s on line %d +bool(false) + +Arg value + +Warning: xml_parser_free() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_free() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_parser_get_option_error.phpt b/ext/xml/tests/xml_parser_get_option_error.phpt new file mode 100644 index 0000000..a355369 --- /dev/null +++ b/ext/xml/tests/xml_parser_get_option_error.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test xml_parser_get_option() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_parser_get_option(resource parser, int option) + * Description: Get options from an XML parser + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_parser_get_option() : error conditions ***\n"; + + +//Test xml_parser_get_option with one more than the expected number of arguments +echo "\n-- Testing xml_parser_get_option() function with more than expected no. of arguments --\n"; + +$option = 10; +$extra_arg = 10; +var_dump( xml_parser_get_option(null, $option, $extra_arg) ); + +// Testing xml_parser_get_option with one less than the expected number of arguments +echo "\n-- Testing xml_parser_get_option() function with less than expected no. of arguments --\n"; + +var_dump( xml_parser_get_option(null) ); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_parser_get_option() : error conditions *** + +-- Testing xml_parser_get_option() function with more than expected no. of arguments -- + +Warning: xml_parser_get_option() expects exactly 2 parameters, 3 given in %s on line %d +NULL + +-- Testing xml_parser_get_option() function with less than expected no. of arguments -- + +Warning: xml_parser_get_option() expects exactly 2 parameters, 1 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_parser_get_option_variation1.phpt b/ext/xml/tests/xml_parser_get_option_variation1.phpt new file mode 100644 index 0000000..b53f803 --- /dev/null +++ b/ext/xml/tests/xml_parser_get_option_variation1.phpt @@ -0,0 +1,241 @@ +--TEST-- +Test xml_parser_get_option() function : usage variations +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_parser_get_option(resource parser, int option) + * Description: Get options from an XML parser + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_parser_get_option() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} +// Initialise function arguments not being substituted (if any) +$option = 10; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for parser + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_parser_get_option($value, $option) ); +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_parser_get_option() : usage variations *** + +Arg value 0 + +Warning: xml_parser_get_option() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_parser_get_option() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 12345 + +Warning: xml_parser_get_option() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value -2345 + +Warning: xml_parser_get_option() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 10.5 + +Warning: xml_parser_get_option() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value -10.5 + +Warning: xml_parser_get_option() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 101234567000 + +Warning: xml_parser_get_option() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 1.07654321E-9 + +Warning: xml_parser_get_option() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 0.5 + +Warning: xml_parser_get_option() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_get_option() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_get_option() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_get_option() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_get_option() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_get_option() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_get_option() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_get_option() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_parser_get_option() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_get_option() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_parser_get_option() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_get_option() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_get_option() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_get_option() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_parser_get_option() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_parser_get_option() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_parser_get_option() expects parameter 1 to be resource, object given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_parser_get_option(): supplied resource is not a valid XML Parser resource in %s on line %d +bool(false) + +Arg value + +Warning: xml_parser_get_option() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_get_option() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_parser_get_option_variation2.phpt b/ext/xml/tests/xml_parser_get_option_variation2.phpt new file mode 100644 index 0000000..2341c41 --- /dev/null +++ b/ext/xml/tests/xml_parser_get_option_variation2.phpt @@ -0,0 +1,226 @@ +--TEST-- +Test xml_parser_get_option() function : usage variations +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_parser_get_option(resource parser, int option) + * Description: Get options from an XML parser + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_parser_get_option() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} +// Initialise function arguments not being substituted (if any) +$parser = xml_parser_create(); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // outside of range int data + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for option + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_parser_get_option($parser, $value) ); +}; + +fclose($fp); +xml_parser_free($parser); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_parser_get_option() : usage variations *** + +Arg value 12345 + +Warning: xml_parser_get_option(): Unknown option in %s on line %d +bool(false) + +Arg value -2345 + +Warning: xml_parser_get_option(): Unknown option in %s on line %d +bool(false) + +Arg value 10.5 + +Warning: xml_parser_get_option(): Unknown option in %s on line %d +bool(false) + +Arg value -10.5 + +Warning: xml_parser_get_option(): Unknown option in %s on line %d +bool(false) + +Arg value 101234567000 + +Warning: xml_parser_get_option(): Unknown option in %s on line %d +bool(false) + +Arg value 1.07654321E-9 + +Warning: xml_parser_get_option(): Unknown option in %s on line %d +bool(false) + +Arg value 0.5 + +Warning: xml_parser_get_option(): Unknown option in %s on line %d +bool(false) + +Arg value Array + +Warning: xml_parser_get_option() expects parameter 2 to be long, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_get_option() expects parameter 2 to be long, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_get_option() expects parameter 2 to be long, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_get_option() expects parameter 2 to be long, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_get_option() expects parameter 2 to be long, array given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_get_option(): Unknown option in %s on line %d +bool(false) + +Arg value + +Warning: xml_parser_get_option(): Unknown option in %s on line %d +bool(false) + +Arg value 1 +int(1) + +Arg value + +Warning: xml_parser_get_option(): Unknown option in %s on line %d +bool(false) + +Arg value 1 +int(1) + +Arg value + +Warning: xml_parser_get_option(): Unknown option in %s on line %d +bool(false) + +Arg value + +Warning: xml_parser_get_option() expects parameter 2 to be long, string given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_get_option() expects parameter 2 to be long, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_parser_get_option() expects parameter 2 to be long, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_parser_get_option() expects parameter 2 to be long, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_parser_get_option() expects parameter 2 to be long, object given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_parser_get_option() expects parameter 2 to be long, resource given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_get_option(): Unknown option in %s on line %d +bool(false) + +Arg value + +Warning: xml_parser_get_option(): Unknown option in %s on line %d +bool(false) +Done + diff --git a/ext/xml/tests/xml_parser_set_option_basic.phpt b/ext/xml/tests/xml_parser_set_option_basic.phpt new file mode 100644 index 0000000..61316a4 --- /dev/null +++ b/ext/xml/tests/xml_parser_set_option_basic.phpt @@ -0,0 +1,57 @@ +--TEST-- +Test xml_set_notation_decl_handler function : basic +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto bool xml_set_notation_decl_handler ( resource $parser , callback $handler ) + * Description: Sets the notation declaration handler function for the XML parser. + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "Simple testcase for xml_parser_get_option() function\n"; + +$parser = xml_parser_create_ns(); + +var_dump(xml_parser_get_option($parser, XML_OPTION_CASE_FOLDING)); +var_dump(xml_parser_get_option($parser, XML_OPTION_TARGET_ENCODING)); + +var_dump(xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 1)); +var_dump(xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1")); + +var_dump(xml_parser_get_option($parser, XML_OPTION_CASE_FOLDING)); +var_dump(xml_parser_get_option($parser, XML_OPTION_TARGET_ENCODING)); + +var_dump(xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0)); +var_dump(xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8")); + +var_dump(xml_parser_get_option($parser, XML_OPTION_CASE_FOLDING)); +var_dump(xml_parser_get_option($parser, XML_OPTION_TARGET_ENCODING)); + +var_dump(xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "US-ASCII")); +var_dump(xml_parser_get_option($parser, XML_OPTION_TARGET_ENCODING)); + +xml_parser_free( $parser ); + +echo "Done\n"; +?> +--EXPECT-- +Simple testcase for xml_parser_get_option() function +int(1) +string(5) "UTF-8" +bool(true) +bool(true) +int(1) +string(10) "ISO-8859-1" +bool(true) +bool(true) +int(0) +string(5) "UTF-8" +bool(true) +string(8) "US-ASCII" +Done diff --git a/ext/xml/tests/xml_parser_set_option_error.phpt b/ext/xml/tests/xml_parser_set_option_error.phpt new file mode 100644 index 0000000..28829bc --- /dev/null +++ b/ext/xml/tests/xml_parser_set_option_error.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test xml_parser_set_option() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_parser_set_option(resource parser, int option, mixed value) + * Description: Set options in an XML parser + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_parser_set_option() : error conditions ***\n"; + + +//Test xml_parser_set_option with one more than the expected number of arguments +echo "\n-- Testing xml_parser_set_option() function with more than expected no. of arguments --\n"; + +$option = 10; +$value = 1; +$extra_arg = 10; +var_dump( xml_parser_set_option(null, $option, $value, $extra_arg) ); + +// Testing xml_parser_set_option with one less than the expected number of arguments +echo "\n-- Testing xml_parser_set_option() function with less than expected no. of arguments --\n"; + +$option = 10; +var_dump( xml_parser_set_option(null, $option) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_parser_set_option() : error conditions *** + +-- Testing xml_parser_set_option() function with more than expected no. of arguments -- + +Warning: xml_parser_set_option() expects exactly 3 parameters, 4 given in %s on line %d +NULL + +-- Testing xml_parser_set_option() function with less than expected no. of arguments -- + +Warning: xml_parser_set_option() expects exactly 3 parameters, 2 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_parser_set_option_variation1.phpt b/ext/xml/tests/xml_parser_set_option_variation1.phpt new file mode 100644 index 0000000..6cfce0b --- /dev/null +++ b/ext/xml/tests/xml_parser_set_option_variation1.phpt @@ -0,0 +1,241 @@ +--TEST-- +Test xml_parser_set_option() function : usage variations +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_parser_set_option(resource parser, int option, mixed value) + * Description: Set options in an XML parser + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_parser_set_option() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} +// Initialise function arguments not being substituted (if any) +$option = 10; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for parser + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_parser_set_option($value, $option, 1) ); +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_parser_set_option() : usage variations *** + +Arg value 0 + +Warning: xml_parser_set_option() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_parser_set_option() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 12345 + +Warning: xml_parser_set_option() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value -2345 + +Warning: xml_parser_set_option() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 10.5 + +Warning: xml_parser_set_option() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value -10.5 + +Warning: xml_parser_set_option() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 101234567000 + +Warning: xml_parser_set_option() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 1.07654321E-9 + +Warning: xml_parser_set_option() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 0.5 + +Warning: xml_parser_set_option() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_set_option() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_set_option() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_set_option() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_set_option() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_set_option() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_set_option() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_set_option() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_parser_set_option() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_set_option() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_parser_set_option() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_set_option() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_set_option() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_set_option() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_parser_set_option() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_parser_set_option() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_parser_set_option() expects parameter 1 to be resource, object given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_parser_set_option(): supplied resource is not a valid XML Parser resource in %s on line %d +bool(false) + +Arg value + +Warning: xml_parser_set_option() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_set_option() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_parser_set_option_variation2.phpt b/ext/xml/tests/xml_parser_set_option_variation2.phpt new file mode 100644 index 0000000..9900d6f --- /dev/null +++ b/ext/xml/tests/xml_parser_set_option_variation2.phpt @@ -0,0 +1,215 @@ +--TEST-- +Test xml_parser_set_option() function : usage variations +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_parser_set_option(resource parser, int option, mixed value) + * Description: Set options in an XML parser + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_parser_set_option() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} +// Initialise function arguments not being substituted (if any) +$parser = xml_parser_create(); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // outside of range int data + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for option + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_parser_set_option($parser, $value, 1) ); +}; + +xml_parser_free($parser); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_parser_set_option() : usage variations *** + +Arg value 12345 + +Warning: xml_parser_set_option(): Unknown option in %s on line %d +bool(false) + +Arg value -2345 + +Warning: xml_parser_set_option(): Unknown option in %s on line %d +bool(false) + +Arg value 10.5 + +Warning: xml_parser_set_option(): Unknown option in %s on line %d +bool(false) + +Arg value -10.5 + +Warning: xml_parser_set_option(): Unknown option in %s on line %d +bool(false) + +Arg value 101234567000 + +Warning: xml_parser_set_option(): Unknown option in %s on line %d +bool(false) + +Arg value 1.07654321E-9 + +Warning: xml_parser_set_option(): Unknown option in %s on line %d +bool(false) + +Arg value 0.5 + +Warning: xml_parser_set_option(): Unknown option in %s on line %d +bool(false) + +Arg value Array + +Warning: xml_parser_set_option() expects parameter 2 to be long, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_set_option() expects parameter 2 to be long, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_set_option() expects parameter 2 to be long, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_set_option() expects parameter 2 to be long, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_parser_set_option() expects parameter 2 to be long, array given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_set_option(): Unknown option in %s on line %d +bool(false) + +Arg value + +Warning: xml_parser_set_option(): Unknown option in %s on line %d +bool(false) + +Arg value 1 +bool(true) + +Arg value + +Warning: xml_parser_set_option(): Unknown option in %s on line %d +bool(false) + +Arg value 1 +bool(true) + +Arg value + +Warning: xml_parser_set_option(): Unknown option in %s on line %d +bool(false) + +Arg value + +Warning: xml_parser_set_option() expects parameter 2 to be long, string given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_set_option() expects parameter 2 to be long, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_parser_set_option() expects parameter 2 to be long, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_parser_set_option() expects parameter 2 to be long, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_parser_set_option() expects parameter 2 to be long, object given in %s on line %d +NULL + +Arg value + +Warning: xml_parser_set_option(): Unknown option in %s on line %d +bool(false) + +Arg value + +Warning: xml_parser_set_option(): Unknown option in %s on line %d +bool(false) +Done + diff --git a/ext/xml/tests/xml_parser_set_option_variation3.phpt b/ext/xml/tests/xml_parser_set_option_variation3.phpt new file mode 100644 index 0000000..c215ef5 --- /dev/null +++ b/ext/xml/tests/xml_parser_set_option_variation3.phpt @@ -0,0 +1,187 @@ +--TEST-- +Test xml_parser_set_option() function : usage variations +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_parser_set_option(resource parser, int option, mixed value) + * Description: Set options in an XML parser + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_parser_set_option() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} +// Initialise function arguments not being substituted (if any) + +$parser = xml_parser_create(); +$option = 1; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for value + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_parser_set_option($parser, $option, $value) ); +}; + +fclose($fp); +xml_parser_free($parser); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_parser_set_option() : usage variations *** + +Arg value 0 +bool(true) + +Arg value 1 +bool(true) + +Arg value 12345 +bool(true) + +Arg value -2345 +bool(true) + +Arg value 10.5 +bool(true) + +Arg value -10.5 +bool(true) + +Arg value 101234567000 +bool(true) + +Arg value 1.07654321E-9 +bool(true) + +Arg value 0.5 +bool(true) + +Arg value Array +bool(true) + +Arg value Array +bool(true) + +Arg value Array +bool(true) + +Arg value Array +bool(true) + +Arg value Array +bool(true) + +Arg value +bool(true) + +Arg value +bool(true) + +Arg value 1 +bool(true) + +Arg value +bool(true) + +Arg value 1 +bool(true) + +Arg value +bool(true) + +Arg value +bool(true) + +Arg value +bool(true) + +Arg value string +bool(true) + +Arg value string +bool(true) + +Arg value Some Ascii Data +bool(true) + +Arg value Resource id %s +bool(true) + +Arg value +bool(true) + +Arg value +bool(true) +Done diff --git a/ext/xml/tests/xml_set_character_data_handler_error.phpt b/ext/xml/tests/xml_set_character_data_handler_error.phpt new file mode 100644 index 0000000..16faaa4 --- /dev/null +++ b/ext/xml/tests/xml_set_character_data_handler_error.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test xml_set_character_data_handler() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_character_data_handler(resource parser, string hdl) + * Description: Set up character data handler + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_character_data_handler() : error conditions ***\n"; + + +//Test xml_set_character_data_handler with one more than the expected number of arguments +echo "\n-- Testing xml_set_character_data_handler() function with more than expected no. of arguments --\n"; + +$hdl = 'string_val'; +$extra_arg = 10; +var_dump( xml_set_character_data_handler(null, $hdl, $extra_arg) ); + +// Testing xml_set_character_data_handler with one less than the expected number of arguments +echo "\n-- Testing xml_set_character_data_handler() function with less than expected no. of arguments --\n"; + +var_dump( xml_set_character_data_handler(null) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_character_data_handler() : error conditions *** + +-- Testing xml_set_character_data_handler() function with more than expected no. of arguments -- + +Warning: xml_set_character_data_handler() expects exactly 2 parameters, 3 given in %s on line %d +NULL + +-- Testing xml_set_character_data_handler() function with less than expected no. of arguments -- + +Warning: xml_set_character_data_handler() expects exactly 2 parameters, 1 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_set_character_data_handler_variation1.phpt b/ext/xml/tests/xml_set_character_data_handler_variation1.phpt new file mode 100644 index 0000000..40cff91 --- /dev/null +++ b/ext/xml/tests/xml_set_character_data_handler_variation1.phpt @@ -0,0 +1,245 @@ +--TEST-- +Test xml_set_character_data_handler() function : usage variations +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_character_data_handler(resource parser, string hdl) + * Description: Set up character data handler + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_character_data_handler() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} + +function validHandler(resource $parser ,string $data) { +} + +// Initialise function arguments not being substituted (if any) +$hdl = 'validHandler'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for parser + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_set_character_data_handler($value, $hdl) ); +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_character_data_handler() : usage variations *** + +Arg value 0 + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 12345 + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value -2345 + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 10.5 + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value -10.5 + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 101234567000 + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 1.07654321E-9 + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 0.5 + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, object given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_set_character_data_handler(): supplied resource is not a valid XML Parser resource in %s on line %d +bool(false) + +Arg value + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_character_data_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_set_default_handler_error.phpt b/ext/xml/tests/xml_set_default_handler_error.phpt new file mode 100644 index 0000000..a4b1b7c --- /dev/null +++ b/ext/xml/tests/xml_set_default_handler_error.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test xml_set_default_handler() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_default_handler(resource parser, string hdl) + * Description: Set up default handler + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_default_handler() : error conditions ***\n"; + + +//Test xml_set_default_handler with one more than the expected number of arguments +echo "\n-- Testing xml_set_default_handler() function with more than expected no. of arguments --\n"; + +$hdl = 'string_val'; +$extra_arg = 10; +var_dump( xml_set_default_handler(null, $hdl, $extra_arg) ); + +// Testing xml_set_default_handler with one less than the expected number of arguments +echo "\n-- Testing xml_set_default_handler() function with less than expected no. of arguments --\n"; + +var_dump( xml_set_default_handler(null) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_default_handler() : error conditions *** + +-- Testing xml_set_default_handler() function with more than expected no. of arguments -- + +Warning: xml_set_default_handler() expects exactly 2 parameters, 3 given in %s on line %d +NULL + +-- Testing xml_set_default_handler() function with less than expected no. of arguments -- + +Warning: xml_set_default_handler() expects exactly 2 parameters, 1 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_set_default_handler_variation1.phpt b/ext/xml/tests/xml_set_default_handler_variation1.phpt new file mode 100644 index 0000000..35089a0 --- /dev/null +++ b/ext/xml/tests/xml_set_default_handler_variation1.phpt @@ -0,0 +1,245 @@ +--TEST-- +Test xml_set_default_handler() function : usage variations - test different types for parser +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_default_handler(resource parser, string hdl) + * Description: Set up default handler + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_default_handler() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} + +function validHandler(resource $parser ,string $data) { +} + +// Initialise function arguments not being substituted (if any) +$hdl = 'validHandler'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for parser + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_set_default_handler($value, $hdl) ); +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_default_handler() : usage variations *** + +Arg value 0 + +Warning: xml_set_default_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_default_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 12345 + +Warning: xml_set_default_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value -2345 + +Warning: xml_set_default_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 10.5 + +Warning: xml_set_default_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value -10.5 + +Warning: xml_set_default_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 101234567000 + +Warning: xml_set_default_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 1.07654321E-9 + +Warning: xml_set_default_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 0.5 + +Warning: xml_set_default_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_default_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_default_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_default_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_default_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_default_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value + +Warning: xml_set_default_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_default_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_default_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_default_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_default_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_default_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_default_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value + +Warning: xml_set_default_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_default_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_default_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_set_default_handler() expects parameter 1 to be resource, object given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_set_default_handler(): supplied resource is not a valid XML Parser resource in %s on line %d +bool(false) + +Arg value + +Warning: xml_set_default_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_default_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_set_element_handler_error.phpt b/ext/xml/tests/xml_set_element_handler_error.phpt new file mode 100644 index 0000000..6ccaea1 --- /dev/null +++ b/ext/xml/tests/xml_set_element_handler_error.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test xml_set_element_handler() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_element_handler(resource parser, string shdl, string ehdl) + * Description: Set up start and end element handlers + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_element_handler() : error conditions ***\n"; + + +//Test xml_set_element_handler with one more than the expected number of arguments +echo "\n-- Testing xml_set_element_handler() function with more than expected no. of arguments --\n"; + +$hdl = 'string_val'; +$extra_arg = 10; +var_dump( xml_set_element_handler(null, $hdl, $hdl, $extra_arg) ); + +// Testing xml_set_element_handler with one less than the expected number of arguments +echo "\n-- Testing xml_set_element_handler() function with less than expected no. of arguments --\n"; + +var_dump( xml_set_element_handler(null) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_element_handler() : error conditions *** + +-- Testing xml_set_element_handler() function with more than expected no. of arguments -- + +Warning: xml_set_element_handler() expects exactly 3 parameters, 4 given in %s on line %d +NULL + +-- Testing xml_set_element_handler() function with less than expected no. of arguments -- + +Warning: xml_set_element_handler() expects exactly 3 parameters, 1 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_set_element_handler_variation1.phpt b/ext/xml/tests/xml_set_element_handler_variation1.phpt new file mode 100644 index 0000000..225cf77 --- /dev/null +++ b/ext/xml/tests/xml_set_element_handler_variation1.phpt @@ -0,0 +1,245 @@ +--TEST-- +Test xml_set_element_handler() function : usage variations - test different types for parser +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_element_handler(resource parser, string shdl, string ehdl) + * Description: Set up start and end element handlers + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_element_handler() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} + +function validHandler(resource $parser ,string $data) { +} + +// Initialise function arguments not being substituted (if any) +$hdl = 'validHandler'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for parser + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_set_element_handler($value, $hdl, $hdl) ); +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_element_handler() : usage variations *** + +Arg value 0 + +Warning: xml_set_element_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_element_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 12345 + +Warning: xml_set_element_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value -2345 + +Warning: xml_set_element_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 10.5 + +Warning: xml_set_element_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value -10.5 + +Warning: xml_set_element_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 101234567000 + +Warning: xml_set_element_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 1.07654321E-9 + +Warning: xml_set_element_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 0.5 + +Warning: xml_set_element_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_element_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_element_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_element_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_element_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_element_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value + +Warning: xml_set_element_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_element_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_element_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_element_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_element_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_element_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_element_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value + +Warning: xml_set_element_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_element_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_element_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_set_element_handler() expects parameter 1 to be resource, object given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_set_element_handler(): supplied resource is not a valid XML Parser resource in %s on line %d +bool(false) + +Arg value + +Warning: xml_set_element_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_element_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_set_end_namespace_decl_handler_error.phpt b/ext/xml/tests/xml_set_end_namespace_decl_handler_error.phpt new file mode 100644 index 0000000..81bb3f6 --- /dev/null +++ b/ext/xml/tests/xml_set_end_namespace_decl_handler_error.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test xml_set_end_namespace_decl_handler() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_end_namespace_decl_handler(resource parser, string hdl) + * Description: Set up character data handler + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_end_namespace_decl_handler() : error conditions ***\n"; + + +//Test xml_set_end_namespace_decl_handler with one more than the expected number of arguments +echo "\n-- Testing xml_set_end_namespace_decl_handler() function with more than expected no. of arguments --\n"; + +$hdl = 'string_val'; +$extra_arg = 10; +var_dump( xml_set_end_namespace_decl_handler(null, $hdl, $extra_arg) ); + +// Testing xml_set_end_namespace_decl_handler with one less than the expected number of arguments +echo "\n-- Testing xml_set_end_namespace_decl_handler() function with less than expected no. of arguments --\n"; + +var_dump( xml_set_end_namespace_decl_handler(null) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_end_namespace_decl_handler() : error conditions *** + +-- Testing xml_set_end_namespace_decl_handler() function with more than expected no. of arguments -- + +Warning: xml_set_end_namespace_decl_handler() expects exactly 2 parameters, 3 given in %s on line %d +NULL + +-- Testing xml_set_end_namespace_decl_handler() function with less than expected no. of arguments -- + +Warning: xml_set_end_namespace_decl_handler() expects exactly 2 parameters, 1 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_set_end_namespace_decl_handler_variation1.phpt b/ext/xml/tests/xml_set_end_namespace_decl_handler_variation1.phpt new file mode 100644 index 0000000..c7c2f6f --- /dev/null +++ b/ext/xml/tests/xml_set_end_namespace_decl_handler_variation1.phpt @@ -0,0 +1,245 @@ +--TEST-- +Test xml_set_end_namespace_decl_handler() function : usage variations +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_end_namespace_decl_handler(resource parser, string hdl) + * Description: Set up character data handler + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_end_namespace_decl_handler() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} + +function validHandler(resource $parser ,string $data) { +} + +// Initialise function arguments not being substituted (if any) +$hdl = 'validHandler'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for parser + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_set_end_namespace_decl_handler($value, $hdl) ); +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_end_namespace_decl_handler() : usage variations *** + +Arg value 0 + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 12345 + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value -2345 + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 10.5 + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value -10.5 + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 101234567000 + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 1.07654321E-9 + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 0.5 + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, object given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_set_end_namespace_decl_handler(): supplied resource is not a valid XML Parser resource in %s on line %d +bool(false) + +Arg value + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_set_external_entity_ref_handler_error.phpt b/ext/xml/tests/xml_set_external_entity_ref_handler_error.phpt new file mode 100644 index 0000000..6dd400a --- /dev/null +++ b/ext/xml/tests/xml_set_external_entity_ref_handler_error.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test xml_set_external_entity_ref_handler() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_external_entity_ref_handler(resource parser, string hdl) + * Description: Set up external entity reference handler + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_external_entity_ref_handler() : error conditions ***\n"; + + +//Test xml_set_external_entity_ref_handler with one more than the expected number of arguments +echo "\n-- Testing xml_set_external_entity_ref_handler() function with more than expected no. of arguments --\n"; + +$hdl = 'string_val'; +$extra_arg = 10; +var_dump( xml_set_external_entity_ref_handler(null, $hdl, $extra_arg) ); + +// Testing xml_set_external_entity_ref_handler with one less than the expected number of arguments +echo "\n-- Testing xml_set_external_entity_ref_handler() function with less than expected no. of arguments --\n"; + +var_dump( xml_set_external_entity_ref_handler(null) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_external_entity_ref_handler() : error conditions *** + +-- Testing xml_set_external_entity_ref_handler() function with more than expected no. of arguments -- + +Warning: xml_set_external_entity_ref_handler() expects exactly 2 parameters, 3 given in %s on line %d +NULL + +-- Testing xml_set_external_entity_ref_handler() function with less than expected no. of arguments -- + +Warning: xml_set_external_entity_ref_handler() expects exactly 2 parameters, 1 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_set_external_entity_ref_handler_variation1.phpt b/ext/xml/tests/xml_set_external_entity_ref_handler_variation1.phpt new file mode 100644 index 0000000..10835b3 --- /dev/null +++ b/ext/xml/tests/xml_set_external_entity_ref_handler_variation1.phpt @@ -0,0 +1,245 @@ +--TEST-- +Test xml_set_external_entity_ref_handler() function : usage variations +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_external_entity_ref_handler(resource parser, string hdl) + * Description: Set up external entity reference handler + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_external_entity_ref_handler() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} + +function validHandler(resource $parser ,string $data) { +} + +// Initialise function arguments not being substituted (if any) +$hdl = 'validHandler'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for parser + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_set_external_entity_ref_handler($value, $hdl) ); +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_external_entity_ref_handler() : usage variations *** + +Arg value 0 + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 12345 + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value -2345 + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 10.5 + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value -10.5 + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 101234567000 + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 1.07654321E-9 + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 0.5 + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, object given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_set_external_entity_ref_handler(): supplied resource is not a valid XML Parser resource in %s on line %d +bool(false) + +Arg value + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_set_notation_decl_handler_basic.phpt b/ext/xml/tests/xml_set_notation_decl_handler_basic.phpt new file mode 100644 index 0000000..6616681 --- /dev/null +++ b/ext/xml/tests/xml_set_notation_decl_handler_basic.phpt @@ -0,0 +1,102 @@ +--TEST-- +Test xml_set_notation_decl_handler function : basic +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto bool xml_set_notation_decl_handler ( resource $parser , callback $handler ) + * Description: Sets the notation declaration handler function for the XML parser. + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +class XML_Parser +{ + + function unparsed_entity_decl_handler($parser, $entity_name, $base, $system_ID, $public_ID, $notation_name) + { + echo "unparsed_entity_decl_handler called\n"; + echo "...Entity name=" . $entity_name . "\n"; + echo "...Base=" . $base . "\n"; + echo "...System ID=" . $system_ID . "\n"; + echo "...Public ID=" . $public_ID . "\n"; + echo "...Notation name=" . $notation_name . "\n"; + } + + function notation_decl_handler($parser, $name, $base, $system_ID,$public_ID) + { + echo "notation_decl_handler called\n"; + echo "...Name=" . $name . "\n"; + echo "...Base=" . $base . "\n"; + echo "...System ID=" . $system_ID . "\n"; + echo "...Public ID=" . $public_ID . "\n"; + } + + function parse($data) + { + $parser = xml_parser_create(); + xml_set_object($parser, $this); + xml_set_notation_decl_handler($parser, "notation_decl_handler"); + xml_set_unparsed_entity_decl_handler($parser, "unparsed_entity_decl_handler"); + xml_parse($parser, $data, true); + xml_parser_free($parser); + } +} + +$xml = <<<HERE +<?xml version="1.0"?> +<!DOCTYPE dates [ + <!NOTATION USDATE SYSTEM "http://www.schema.net/usdate.not"> + <!NOTATION AUSDATE SYSTEM "http://www.schema.net/ausdate.not"> + <!NOTATION ISODATE SYSTEM "http://www.schema.net/isodate.not"> + <!ENTITY testUS SYSTEM "test_usdate.xml" NDATA USDATE> + <!ENTITY testAUS SYSTEM "test_ausdate.xml" NDATA AUSDATE> + <!ENTITY testISO SYSTEM "test_isodate_xml" NDATA ISODATE>]> +]> +HERE; + +echo "Simple test of xml_set_notation_decl_handler(() function\n"; +$p1 = new Xml_Parser(); +$p1->parse($xml); +echo "Done\n"; +?> +--EXPECT-- +Simple test of xml_set_notation_decl_handler(() function +notation_decl_handler called +...Name=USDATE +...Base= +...System ID=http://www.schema.net/usdate.not +...Public ID= +notation_decl_handler called +...Name=AUSDATE +...Base= +...System ID=http://www.schema.net/ausdate.not +...Public ID= +notation_decl_handler called +...Name=ISODATE +...Base= +...System ID=http://www.schema.net/isodate.not +...Public ID= +unparsed_entity_decl_handler called +...Entity name=testUS +...Base= +...System ID=test_usdate.xml +...Public ID= +...Notation name=USDATE +unparsed_entity_decl_handler called +...Entity name=testAUS +...Base= +...System ID=test_ausdate.xml +...Public ID= +...Notation name=AUSDATE +unparsed_entity_decl_handler called +...Entity name=testISO +...Base= +...System ID=test_isodate_xml +...Public ID= +...Notation name=ISODATE +Done diff --git a/ext/xml/tests/xml_set_notation_decl_handler_error.phpt b/ext/xml/tests/xml_set_notation_decl_handler_error.phpt new file mode 100644 index 0000000..fccc135 --- /dev/null +++ b/ext/xml/tests/xml_set_notation_decl_handler_error.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test xml_set_notation_decl_handler() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_notation_decl_handler(resource parser, string hdl) + * Description: Set up notation declaration handler + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_notation_decl_handler() : error conditions ***\n"; + + +//Test xml_set_notation_decl_handler with one more than the expected number of arguments +echo "\n-- Testing xml_set_notation_decl_handler() function with more than expected no. of arguments --\n"; + +$hdl = 'string_val'; +$extra_arg = 10; +var_dump( xml_set_notation_decl_handler(null, $hdl, $extra_arg) ); + +// Testing xml_set_notation_decl_handler with one less than the expected number of arguments +echo "\n-- Testing xml_set_notation_decl_handler() function with less than expected no. of arguments --\n"; + +var_dump( xml_set_notation_decl_handler(null) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_notation_decl_handler() : error conditions *** + +-- Testing xml_set_notation_decl_handler() function with more than expected no. of arguments -- + +Warning: xml_set_notation_decl_handler() expects exactly 2 parameters, 3 given in %s on line %d +NULL + +-- Testing xml_set_notation_decl_handler() function with less than expected no. of arguments -- + +Warning: xml_set_notation_decl_handler() expects exactly 2 parameters, 1 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_set_notation_decl_handler_variation1.phpt b/ext/xml/tests/xml_set_notation_decl_handler_variation1.phpt new file mode 100644 index 0000000..d41e691 --- /dev/null +++ b/ext/xml/tests/xml_set_notation_decl_handler_variation1.phpt @@ -0,0 +1,245 @@ +--TEST-- +Test xml_set_notation_decl_handler() function : usage variations +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_notation_decl_handler(resource parser, string hdl) + * Description: Set up notation declaration handler + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_notation_decl_handler() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} + +function validHandler(resource $parser ,string $data) { +} + +// Initialise function arguments not being substituted (if any) +$hdl = 'validHandler'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for parser + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_set_notation_decl_handler($value, $hdl) ); +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_notation_decl_handler() : usage variations *** + +Arg value 0 + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 12345 + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value -2345 + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 10.5 + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value -10.5 + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 101234567000 + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 1.07654321E-9 + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 0.5 + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, object given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_set_notation_decl_handler(): supplied resource is not a valid XML Parser resource in %s on line %d +bool(false) + +Arg value + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_set_object_error.phpt b/ext/xml/tests/xml_set_object_error.phpt new file mode 100644 index 0000000..db3266e --- /dev/null +++ b/ext/xml/tests/xml_set_object_error.phpt @@ -0,0 +1,51 @@ +--TEST-- +Test xml_set_object() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_object(resource parser, object &obj) + * Description: Set up object which should be used for callbacks + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_object() : error conditions ***\n"; + + +//Test xml_set_object with one more than the expected number of arguments +echo "\n-- Testing xml_set_object() function with more than expected no. of arguments --\n"; + +//WARNING: Unable to initialise parser of type resource + +$obj = new stdclass(); +$extra_arg = 10; +var_dump( xml_set_object(null, $obj, $extra_arg) ); + +// Testing xml_set_object with one less than the expected number of arguments +echo "\n-- Testing xml_set_object() function with less than expected no. of arguments --\n"; + +//WARNING: Unable to initialise parser of type resource + +var_dump( xml_set_object(null) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_object() : error conditions *** + +-- Testing xml_set_object() function with more than expected no. of arguments -- + +Warning: xml_set_object() expects exactly 2 parameters, 3 given in %s on line %d +NULL + +-- Testing xml_set_object() function with less than expected no. of arguments -- + +Warning: xml_set_object() expects exactly 2 parameters, 1 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_set_object_variation1.phpt b/ext/xml/tests/xml_set_object_variation1.phpt new file mode 100644 index 0000000..851dfaf --- /dev/null +++ b/ext/xml/tests/xml_set_object_variation1.phpt @@ -0,0 +1,241 @@ +--TEST-- +Test xml_set_object() function : usage variations +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_object(resource parser, object &obj) + * Description: Set up object which should be used for callbacks + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_object() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} +// Initialise function arguments not being substituted (if any) +$obj = new aClass(); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for parser + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_set_object($value, $obj) ); +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_object() : usage variations *** + +Arg value 0 + +Warning: xml_set_object() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_object() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 12345 + +Warning: xml_set_object() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value -2345 + +Warning: xml_set_object() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 10.5 + +Warning: xml_set_object() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value -10.5 + +Warning: xml_set_object() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 101234567000 + +Warning: xml_set_object() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 1.07654321E-9 + +Warning: xml_set_object() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 0.5 + +Warning: xml_set_object() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_object() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_object() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_object() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_object() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_object() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value + +Warning: xml_set_object() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_object() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_object() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_object() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_object() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_object() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_object() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value + +Warning: xml_set_object() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_object() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_object() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_set_object() expects parameter 1 to be resource, object given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_set_object(): supplied resource is not a valid XML Parser resource in %s on line %d +bool(false) + +Arg value + +Warning: xml_set_object() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_object() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_set_object_variation2.phpt b/ext/xml/tests/xml_set_object_variation2.phpt new file mode 100644 index 0000000..0844661 --- /dev/null +++ b/ext/xml/tests/xml_set_object_variation2.phpt @@ -0,0 +1,230 @@ +--TEST-- +Test xml_set_object() function : usage variations +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_object(resource parser, object &obj) + * Description: Set up object which should be used for callbacks + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_object() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); +// Initialise function arguments not being substituted (if any) + +$parser = xml_parser_create(); +$fp = fopen(__FILE__, "r"); + + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for obj + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_set_object($parser, $value) ); +}; + +xml_parser_free($parser); +fclose($fp); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_object() : usage variations *** + +Arg value 0 + +Warning: xml_set_object() expects parameter 2 to be object, integer given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_object() expects parameter 2 to be object, integer given in %s on line %d +NULL + +Arg value 12345 + +Warning: xml_set_object() expects parameter 2 to be object, integer given in %s on line %d +NULL + +Arg value -2345 + +Warning: xml_set_object() expects parameter 2 to be object, integer given in %s on line %d +NULL + +Arg value 10.5 + +Warning: xml_set_object() expects parameter 2 to be object, double given in %s on line %d +NULL + +Arg value -10.5 + +Warning: xml_set_object() expects parameter 2 to be object, double given in %s on line %d +NULL + +Arg value 101234567000 + +Warning: xml_set_object() expects parameter 2 to be object, double given in %s on line %d +NULL + +Arg value 1.07654321E-9 + +Warning: xml_set_object() expects parameter 2 to be object, double given in %s on line %d +NULL + +Arg value 0.5 + +Warning: xml_set_object() expects parameter 2 to be object, double given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_object() expects parameter 2 to be object, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_object() expects parameter 2 to be object, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_object() expects parameter 2 to be object, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_object() expects parameter 2 to be object, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_object() expects parameter 2 to be object, array given in %s on line %d +NULL + +Arg value + +Warning: xml_set_object() expects parameter 2 to be object, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_object() expects parameter 2 to be object, null given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_object() expects parameter 2 to be object, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_object() expects parameter 2 to be object, boolean given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_object() expects parameter 2 to be object, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_object() expects parameter 2 to be object, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_object() expects parameter 2 to be object, string given in %s on line %d +NULL + +Arg value + +Warning: xml_set_object() expects parameter 2 to be object, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_object() expects parameter 2 to be object, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_object() expects parameter 2 to be object, string given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_set_object() expects parameter 2 to be object, resource given in %s on line %d +NULL + +Arg value + +Warning: xml_set_object() expects parameter 2 to be object, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_object() expects parameter 2 to be object, null given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_set_processing_instruction_handler_basic.phpt b/ext/xml/tests/xml_set_processing_instruction_handler_basic.phpt new file mode 100644 index 0000000..e5589ce --- /dev/null +++ b/ext/xml/tests/xml_set_processing_instruction_handler_basic.phpt @@ -0,0 +1,52 @@ +--TEST-- +Test xml_set_processing_instruction_handler function : basic +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto bool xml_set_processing_instruction_handler ( resource $parser , callback $handler ) + * Description: Sets the processing instruction (PI) handler function for the XML parser. + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +class XML_Parser +{ + + function PIHandler($parser, $target, $data) + { + echo "Target: " . $target. "\n"; + echo "Data: " . $data . "\n"; + } + + function parse($data) + { + $parser = xml_parser_create(); + xml_set_object($parser, $this); + xml_set_processing_instruction_handler($parser, "PIHandler"); + xml_parse($parser, $data, true); + xml_parser_free($parser); + } + + +} + +$xml = <<<HERE +<?xml version="1.0" encoding="ISO-8859-1"?> +<?xml-stylesheet href="default.xsl" type="text/xml"?> +HERE; + +echo "Simple test of xml_set_processing_instruction_handler() function\n"; +$p1 = new Xml_Parser(); +$p1->parse($xml); +echo "Done\n"; +?> +--EXPECT-- +Simple test of xml_set_processing_instruction_handler() function +Target: xml-stylesheet +Data: href="default.xsl" type="text/xml" +Done
\ No newline at end of file diff --git a/ext/xml/tests/xml_set_processing_instruction_handler_error.phpt b/ext/xml/tests/xml_set_processing_instruction_handler_error.phpt new file mode 100644 index 0000000..f2a8494 --- /dev/null +++ b/ext/xml/tests/xml_set_processing_instruction_handler_error.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test xml_set_processing_instruction_handler() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_processing_instruction_handler(resource parser, string hdl) + * Description: Set up processing instruction (PI) handler + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_processing_instruction_handler() : error conditions ***\n"; + + +//Test xml_set_processing_instruction_handler with one more than the expected number of arguments +echo "\n-- Testing xml_set_processing_instruction_handler() function with more than expected no. of arguments --\n"; + +$hdl = 'string_val'; +$extra_arg = 10; +var_dump( xml_set_processing_instruction_handler(null, $hdl, $extra_arg) ); + +// Testing xml_set_processing_instruction_handler with one less than the expected number of arguments +echo "\n-- Testing xml_set_processing_instruction_handler() function with less than expected no. of arguments --\n"; + +var_dump( xml_set_processing_instruction_handler(null) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_processing_instruction_handler() : error conditions *** + +-- Testing xml_set_processing_instruction_handler() function with more than expected no. of arguments -- + +Warning: xml_set_processing_instruction_handler() expects exactly 2 parameters, 3 given in %s on line %d +NULL + +-- Testing xml_set_processing_instruction_handler() function with less than expected no. of arguments -- + +Warning: xml_set_processing_instruction_handler() expects exactly 2 parameters, 1 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_set_processing_instruction_handler_variation1.phpt b/ext/xml/tests/xml_set_processing_instruction_handler_variation1.phpt new file mode 100644 index 0000000..9da14cc --- /dev/null +++ b/ext/xml/tests/xml_set_processing_instruction_handler_variation1.phpt @@ -0,0 +1,245 @@ +--TEST-- +Test xml_set_processing_instruction_handler() function : usage variations +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_processing_instruction_handler(resource parser, string hdl) + * Description: Set up processing instruction (PI) handler + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_processing_instruction_handler() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} + +function validHandler(resource $parser ,string $data) { +} + +// Initialise function arguments not being substituted (if any) +$hdl = 'validHandler'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for parser + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_set_processing_instruction_handler($value, $hdl) ); +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_processing_instruction_handler() : usage variations *** + +Arg value 0 + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 12345 + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value -2345 + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 10.5 + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value -10.5 + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 101234567000 + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 1.07654321E-9 + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 0.5 + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, object given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_set_processing_instruction_handler(): supplied resource is not a valid XML Parser resource in %s on line %d +bool(false) + +Arg value + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_set_start_namespace_decl_handler_basic.phpt b/ext/xml/tests/xml_set_start_namespace_decl_handler_basic.phpt new file mode 100644 index 0000000..79b8cb8 --- /dev/null +++ b/ext/xml/tests/xml_set_start_namespace_decl_handler_basic.phpt @@ -0,0 +1,61 @@ +--TEST-- +Test xml_set_start_namespace_decl_handler function: basic +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : bool xml_set_start_namespace_decl_handler ( resource $parser , callback $handler ) + * Description: Set up start namespace declaration handler. + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +$xml = <<<HERE +<aw1:book xmlns:aw1="http://www.somewhere.com/namespace1" + xmlns:aw2="file:/DTD/somewhere.dtd"> +<aw1:para>Any old text.</aw1:para> +<aw2:td>An HTML table cell.</aw2:td> +</aw1:book> +HERE; + +$parser = xml_parser_create_ns(); +xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); + +var_dump(xml_set_start_namespace_decl_handler( $parser, "Namespace_Start_Handler" )); +var_dump(xml_set_end_namespace_decl_handler( $parser, "Namespace_End_Handler" )); + +xml_parse( $parser, $xml, true); +xml_parser_free( $parser ); + +echo "Done\n"; + +function Namespace_Start_Handler( $parser, $prefix, $uri ) { + echo "Namespace_Start_Handler called\n"; + echo "...Prefix: ". $prefix . "\n"; + echo "...Uri: ". $uri . "\n"; +} + +function Namespace_End_Handler($parser, $prefix) { + echo "Namespace_End_Handler called\n"; + echo "...Prefix: ". $prefix . "\n\n"; +} + +function DefaultHandler( $parser, $data ) { + print( 'DefaultHandler Called<br/>' ); +} +?> +--EXPECT-- +bool(true) +bool(true) +Namespace_Start_Handler called +...Prefix: aw1 +...Uri: http://www.somewhere.com/namespace1 +Namespace_Start_Handler called +...Prefix: aw2 +...Uri: file:/DTD/somewhere.dtd +Done + diff --git a/ext/xml/tests/xml_set_start_namespace_decl_handler_error.phpt b/ext/xml/tests/xml_set_start_namespace_decl_handler_error.phpt new file mode 100644 index 0000000..221b005 --- /dev/null +++ b/ext/xml/tests/xml_set_start_namespace_decl_handler_error.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test xml_set_start_namespace_decl_handler() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_start_namespace_decl_handler(resource parser, string hdl) + * Description: Set up character data handler + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_start_namespace_decl_handler() : error conditions ***\n"; + + +//Test xml_set_start_namespace_decl_handler with one more than the expected number of arguments +echo "\n-- Testing xml_set_start_namespace_decl_handler() function with more than expected no. of arguments --\n"; + +$hdl = 'string_val'; +$extra_arg = 10; +var_dump( xml_set_start_namespace_decl_handler(null, $hdl, $extra_arg) ); + +// Testing xml_set_start_namespace_decl_handler with one less than the expected number of arguments +echo "\n-- Testing xml_set_start_namespace_decl_handler() function with less than expected no. of arguments --\n"; + +var_dump( xml_set_start_namespace_decl_handler(null) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_start_namespace_decl_handler() : error conditions *** + +-- Testing xml_set_start_namespace_decl_handler() function with more than expected no. of arguments -- + +Warning: xml_set_start_namespace_decl_handler() expects exactly 2 parameters, 3 given in %s on line %d +NULL + +-- Testing xml_set_start_namespace_decl_handler() function with less than expected no. of arguments -- + +Warning: xml_set_start_namespace_decl_handler() expects exactly 2 parameters, 1 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_set_start_namespace_decl_handler_variation1.phpt b/ext/xml/tests/xml_set_start_namespace_decl_handler_variation1.phpt new file mode 100644 index 0000000..684a0fd --- /dev/null +++ b/ext/xml/tests/xml_set_start_namespace_decl_handler_variation1.phpt @@ -0,0 +1,245 @@ +--TEST-- +Test xml_set_start_namespace_decl_handler() function : usage variations +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_start_namespace_decl_handler(resource parser, string hdl) + * Description: Set up character data handler + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_start_namespace_decl_handler() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} + +function validHandler(resource $parser ,string $data) { +} + +// Initialise function arguments not being substituted (if any) +$hdl = 'validHandler'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for parser + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_set_start_namespace_decl_handler($value, $hdl) ); +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_start_namespace_decl_handler() : usage variations *** + +Arg value 0 + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 12345 + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value -2345 + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 10.5 + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value -10.5 + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 101234567000 + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 1.07654321E-9 + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 0.5 + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, object given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_set_start_namespace_decl_handler(): supplied resource is not a valid XML Parser resource in %s on line %d +bool(false) + +Arg value + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_set_unparsed_entity_decl_handler_error.phpt b/ext/xml/tests/xml_set_unparsed_entity_decl_handler_error.phpt new file mode 100644 index 0000000..952a698 --- /dev/null +++ b/ext/xml/tests/xml_set_unparsed_entity_decl_handler_error.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test xml_set_unparsed_entity_decl_handler() function : error conditions +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_unparsed_entity_decl_handler(resource parser, string hdl) + * Description: Set up unparsed entity declaration handler + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_unparsed_entity_decl_handler() : error conditions ***\n"; + + +//Test xml_set_unparsed_entity_decl_handler with one more than the expected number of arguments +echo "\n-- Testing xml_set_unparsed_entity_decl_handler() function with more than expected no. of arguments --\n"; + +$hdl = 'string_val'; +$extra_arg = 10; +var_dump( xml_set_unparsed_entity_decl_handler(null, $hdl, $extra_arg) ); + +// Testing xml_set_unparsed_entity_decl_handler with one less than the expected number of arguments +echo "\n-- Testing xml_set_unparsed_entity_decl_handler() function with less than expected no. of arguments --\n"; + +var_dump( xml_set_unparsed_entity_decl_handler(null) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_unparsed_entity_decl_handler() : error conditions *** + +-- Testing xml_set_unparsed_entity_decl_handler() function with more than expected no. of arguments -- + +Warning: xml_set_unparsed_entity_decl_handler() expects exactly 2 parameters, 3 given in %s on line %d +NULL + +-- Testing xml_set_unparsed_entity_decl_handler() function with less than expected no. of arguments -- + +Warning: xml_set_unparsed_entity_decl_handler() expects exactly 2 parameters, 1 given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xml_set_unparsed_entity_decl_handler_variation1.phpt b/ext/xml/tests/xml_set_unparsed_entity_decl_handler_variation1.phpt new file mode 100644 index 0000000..1804115 --- /dev/null +++ b/ext/xml/tests/xml_set_unparsed_entity_decl_handler_variation1.phpt @@ -0,0 +1,245 @@ +--TEST-- +Test xml_set_unparsed_entity_decl_handler() function : usage variations +--SKIPIF-- +<?php +if (!extension_loaded("xml")) { + print "skip - XML extension not loaded"; +} +?> +--FILE-- +<?php +/* Prototype : proto int xml_set_unparsed_entity_decl_handler(resource parser, string hdl) + * Description: Set up unparsed entity declaration handler + * Source code: ext/xml/xml.c + * Alias to functions: + */ + +echo "*** Testing xml_set_unparsed_entity_decl_handler() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} + +function validHandler(resource $parser ,string $data) { +} + +// Initialise function arguments not being substituted (if any) +$hdl = 'validHandler'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +$fp = fopen(__FILE__, "r"); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new aClass(), + + // resource data + $fp, + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for parser + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( xml_set_unparsed_entity_decl_handler($value, $hdl) ); +}; + +fclose($fp); +echo "Done"; +?> +--EXPECTF-- +*** Testing xml_set_unparsed_entity_decl_handler() : usage variations *** + +Arg value 0 + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 12345 + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value -2345 + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Arg value 10.5 + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value -10.5 + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 101234567000 + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 1.07654321E-9 + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value 0.5 + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value Array + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Arg value + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value 1 + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Arg value + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value string + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Arg value Some Ascii Data + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, object given in %s on line %d +NULL + +Arg value Resource id %s + +Warning: xml_set_unparsed_entity_decl_handler(): supplied resource is not a valid XML Parser resource in %s on line %d +bool(false) + +Arg value + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Arg value + +Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, null given in %s on line %d +NULL +Done + diff --git a/ext/xml/tests/xmltest.xml b/ext/xml/tests/xmltest.xml new file mode 100644 index 0000000..c15d6ea --- /dev/null +++ b/ext/xml/tests/xmltest.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE phptest SYSTEM "notfound.dtd" [ +<!ENTITY % incent SYSTEM "inc.ent"> +%incent; +]> +<root id="elem1"> + Plain text. + <elem1> + <!-- comment --> + <elem2> + <![CDATA[CDATA block]]> + <elem3> + &included-entity; + <elem4> + <?test processing instruction ?> + </elem4> + </elem3> + </elem2> + </elem1> +</root> |