]> granicus.if.org Git - php/commitdiff
MFH tests
authorHannes Magnusson <bjori@php.net>
Mon, 9 Oct 2006 16:02:34 +0000 (16:02 +0000)
committerHannes Magnusson <bjori@php.net>
Mon, 9 Oct 2006 16:02:34 +0000 (16:02 +0000)
19 files changed:
ext/calendar/tests/cal_from_jd.phpt [new file with mode: 0644]
ext/calendar/tests/cal_info.phpt [new file with mode: 0644]
ext/calendar/tests/easter_date.phpt [new file with mode: 0644]
ext/calendar/tests/gregoriantojd.phpt [new file with mode: 0644]
ext/calendar/tests/jddayofweek.phpt [new file with mode: 0644]
ext/calendar/tests/jdmonthname.phpt [new file with mode: 0644]
ext/calendar/tests/jdtofrench.phpt [new file with mode: 0644]
ext/calendar/tests/jdtogregorian.phpt [new file with mode: 0644]
ext/calendar/tests/jdtojulian.phpt [new file with mode: 0644]
ext/calendar/tests/jdtounix.phpt [new file with mode: 0644]
ext/calendar/tests/jewishtojd.phpt [new file with mode: 0644]
ext/calendar/tests/juliantojd.phpt [new file with mode: 0644]
ext/calendar/tests/unixtojd.phpt [new file with mode: 0644]
ext/dom/tests/domattributes.phpt [new file with mode: 0644]
ext/dom/tests/domchardata.phpt [new file with mode: 0644]
ext/dom/tests/domelement.phpt [new file with mode: 0644]
ext/zip/tests/bug38943.phpt [moved from ext/zip/tests/38943.phpt with 100% similarity]
tests/lang/catchable_error_001.phpt [new file with mode: 0644]
tests/lang/catchable_error_002.phpt [new file with mode: 0644]

diff --git a/ext/calendar/tests/cal_from_jd.phpt b/ext/calendar/tests/cal_from_jd.phpt
new file mode 100644 (file)
index 0000000..9614522
--- /dev/null
@@ -0,0 +1,60 @@
+--TEST--
+cal_from_jd()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+print_r(cal_from_jd(1748326, CAL_GREGORIAN));
+print_r(cal_from_jd(1748324, CAL_JULIAN));
+print_r(cal_from_jd( 374867, CAL_JEWISH));
+print_r(cal_from_jd(      0, CAL_FRENCH));
+?>
+--EXPECT--
+Array
+(
+    [date] => 8/26/74
+    [month] => 8
+    [day] => 26
+    [year] => 74
+    [dow] => 0
+    [abbrevdayname] => Sun
+    [dayname] => Sunday
+    [abbrevmonth] => Aug
+    [monthname] => August
+)
+Array
+(
+    [date] => 8/26/74
+    [month] => 8
+    [day] => 26
+    [year] => 74
+    [dow] => 5
+    [abbrevdayname] => Fri
+    [dayname] => Friday
+    [abbrevmonth] => Aug
+    [monthname] => August
+)
+Array
+(
+    [date] => 8/26/74
+    [month] => 8
+    [day] => 26
+    [year] => 74
+    [dow] => 4
+    [abbrevdayname] => Thu
+    [dayname] => Thursday
+    [abbrevmonth] => Nisan
+    [monthname] => Nisan
+)
+Array
+(
+    [date] => 0/0/0
+    [month] => 0
+    [day] => 0
+    [year] => 0
+    [dow] => 1
+    [abbrevdayname] => Mon
+    [dayname] => Monday
+    [abbrevmonth] => 
+    [monthname] => 
+)
diff --git a/ext/calendar/tests/cal_info.phpt b/ext/calendar/tests/cal_info.phpt
new file mode 100644 (file)
index 0000000..2e3e612
--- /dev/null
@@ -0,0 +1,216 @@
+--TEST--
+cal_info()
+--INI--
+date.timezone=UTC
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+  print_r(cal_info());
+  print_r(cal_info(1));
+  print_r(cal_info(99999));
+?>
+--EXPECTF--
+Array
+(
+    [0] => Array
+        (
+            [months] => Array
+                (
+                    [1] => January
+                    [2] => February
+                    [3] => March
+                    [4] => April
+                    [5] => May
+                    [6] => June
+                    [7] => July
+                    [8] => August
+                    [9] => September
+                    [10] => October
+                    [11] => November
+                    [12] => December
+                )
+
+            [abbrevmonths] => Array
+                (
+                    [1] => Jan
+                    [2] => Feb
+                    [3] => Mar
+                    [4] => Apr
+                    [5] => May
+                    [6] => Jun
+                    [7] => Jul
+                    [8] => Aug
+                    [9] => Sep
+                    [10] => Oct
+                    [11] => Nov
+                    [12] => Dec
+                )
+
+            [maxdaysinmonth] => 31
+            [calname] => Gregorian
+            [calsymbol] => CAL_GREGORIAN
+        )
+
+    [1] => Array
+        (
+            [months] => Array
+                (
+                    [1] => January
+                    [2] => February
+                    [3] => March
+                    [4] => April
+                    [5] => May
+                    [6] => June
+                    [7] => July
+                    [8] => August
+                    [9] => September
+                    [10] => October
+                    [11] => November
+                    [12] => December
+                )
+
+            [abbrevmonths] => Array
+                (
+                    [1] => Jan
+                    [2] => Feb
+                    [3] => Mar
+                    [4] => Apr
+                    [5] => May
+                    [6] => Jun
+                    [7] => Jul
+                    [8] => Aug
+                    [9] => Sep
+                    [10] => Oct
+                    [11] => Nov
+                    [12] => Dec
+                )
+
+            [maxdaysinmonth] => 31
+            [calname] => Julian
+            [calsymbol] => CAL_JULIAN
+        )
+
+    [2] => Array
+        (
+            [months] => Array
+                (
+                    [1] => Tishri
+                    [2] => Heshvan
+                    [3] => Kislev
+                    [4] => Tevet
+                    [5] => Shevat
+                    [6] => AdarI
+                    [7] => AdarII
+                    [8] => Nisan
+                    [9] => Iyyar
+                    [10] => Sivan
+                    [11] => Tammuz
+                    [12] => Av
+                    [13] => Elul
+                )
+
+            [abbrevmonths] => Array
+                (
+                    [1] => Tishri
+                    [2] => Heshvan
+                    [3] => Kislev
+                    [4] => Tevet
+                    [5] => Shevat
+                    [6] => AdarI
+                    [7] => AdarII
+                    [8] => Nisan
+                    [9] => Iyyar
+                    [10] => Sivan
+                    [11] => Tammuz
+                    [12] => Av
+                    [13] => Elul
+                )
+
+            [maxdaysinmonth] => 30
+            [calname] => Jewish
+            [calsymbol] => CAL_JEWISH
+        )
+
+    [3] => Array
+        (
+            [months] => Array
+                (
+                    [1] => Vendemiaire
+                    [2] => Brumaire
+                    [3] => Frimaire
+                    [4] => Nivose
+                    [5] => Pluviose
+                    [6] => Ventose
+                    [7] => Germinal
+                    [8] => Floreal
+                    [9] => Prairial
+                    [10] => Messidor
+                    [11] => Thermidor
+                    [12] => Fructidor
+                    [13] => Extra
+                )
+
+            [abbrevmonths] => Array
+                (
+                    [1] => Vendemiaire
+                    [2] => Brumaire
+                    [3] => Frimaire
+                    [4] => Nivose
+                    [5] => Pluviose
+                    [6] => Ventose
+                    [7] => Germinal
+                    [8] => Floreal
+                    [9] => Prairial
+                    [10] => Messidor
+                    [11] => Thermidor
+                    [12] => Fructidor
+                    [13] => Extra
+                )
+
+            [maxdaysinmonth] => 30
+            [calname] => French
+            [calsymbol] => CAL_FRENCH
+        )
+
+)
+Array
+(
+    [months] => Array
+        (
+            [1] => January
+            [2] => February
+            [3] => March
+            [4] => April
+            [5] => May
+            [6] => June
+            [7] => July
+            [8] => August
+            [9] => September
+            [10] => October
+            [11] => November
+            [12] => December
+        )
+
+    [abbrevmonths] => Array
+        (
+            [1] => Jan
+            [2] => Feb
+            [3] => Mar
+            [4] => Apr
+            [5] => May
+            [6] => Jun
+            [7] => Jul
+            [8] => Aug
+            [9] => Sep
+            [10] => Oct
+            [11] => Nov
+            [12] => Dec
+        )
+
+    [maxdaysinmonth] => 31
+    [calname] => Julian
+    [calsymbol] => CAL_JULIAN
+)
+
+Warning: cal_info(): invalid calendar ID 99999. in %s on line %d
diff --git a/ext/calendar/tests/easter_date.phpt b/ext/calendar/tests/easter_date.phpt
new file mode 100644 (file)
index 0000000..55a3670
--- /dev/null
@@ -0,0 +1,20 @@
+--TEST--
+easter_date()
+--INI--
+date.timezone=UTC
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+echo date("Y-m-d", easter_date(2000))."\n";       
+echo date("Y-m-d", easter_date(2001))."\n";      
+echo date("Y-m-d", easter_date(2002))."\n";      
+echo date("Y-m-d", easter_date(1492))."\n";
+?>
+--EXPECTF--
+2000-04-22
+2001-04-14
+2002-03-30
+
+Warning: easter_date(): This function is only valid for years between 1970 and 2037 inclusive in %s on line %d
+1970-01-01
diff --git a/ext/calendar/tests/gregoriantojd.phpt b/ext/calendar/tests/gregoriantojd.phpt
new file mode 100644 (file)
index 0000000..ec3628e
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+gregoriantojd()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+echo gregoriantojd( 0, 0,    0). "\n";
+echo gregoriantojd( 1, 1, 1582). "\n";
+echo gregoriantojd(10, 5, 1582). "\n";
+echo gregoriantojd( 1, 1, 1970). "\n";
+echo gregoriantojd( 1, 1, 2999). "\n";
+?>
+--EXPECT--
+0
+2298874
+2299151
+2440588
+2816423
\ No newline at end of file
diff --git a/ext/calendar/tests/jddayofweek.phpt b/ext/calendar/tests/jddayofweek.phpt
new file mode 100644 (file)
index 0000000..c33d598
--- /dev/null
@@ -0,0 +1,130 @@
+--TEST--
+jddayofweek()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+foreach (array(2440588, 2452162, 2453926, -1000) as $jd) {
+  echo "### JD $jd ###\n";
+  for ($mode = 0; $mode <= 2; $mode++) {
+    echo "--- mode $mode ---\n";
+    for ($offset = 0; $offset <= 7; $offset++) {
+      echo jddayofweek($jd + $offset, $mode). "\n";
+    }
+  }
+}
+?>
+--EXPECT--
+### JD 2440588 ###
+--- mode 0 ---
+4
+5
+6
+0
+1
+2
+3
+4
+--- mode 1 ---
+Thursday
+Friday
+Saturday
+Sunday
+Monday
+Tuesday
+Wednesday
+Thursday
+--- mode 2 ---
+Thu
+Fri
+Sat
+Sun
+Mon
+Tue
+Wed
+Thu
+### JD 2452162 ###
+--- mode 0 ---
+0
+1
+2
+3
+4
+5
+6
+0
+--- mode 1 ---
+Sunday
+Monday
+Tuesday
+Wednesday
+Thursday
+Friday
+Saturday
+Sunday
+--- mode 2 ---
+Sun
+Mon
+Tue
+Wed
+Thu
+Fri
+Sat
+Sun
+### JD 2453926 ###
+--- mode 0 ---
+0
+1
+2
+3
+4
+5
+6
+0
+--- mode 1 ---
+Sunday
+Monday
+Tuesday
+Wednesday
+Thursday
+Friday
+Saturday
+Sunday
+--- mode 2 ---
+Sun
+Mon
+Tue
+Wed
+Thu
+Fri
+Sat
+Sun
+### JD -1000 ###
+--- mode 0 ---
+2
+3
+4
+5
+6
+0
+1
+2
+--- mode 1 ---
+Tuesday
+Wednesday
+Thursday
+Friday
+Saturday
+Sunday
+Monday
+Tuesday
+--- mode 2 ---
+Tue
+Wed
+Thu
+Fri
+Sat
+Sun
+Mon
+Tue
+
diff --git a/ext/calendar/tests/jdmonthname.phpt b/ext/calendar/tests/jdmonthname.phpt
new file mode 100644 (file)
index 0000000..d05d3c5
--- /dev/null
@@ -0,0 +1,314 @@
+--TEST--
+jdmonthname()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+foreach (array(2440588, 2452162, 2453926) as $jd) {
+  echo "### JD $jd ###\n";
+  for ($mode = 0; $mode <= 6; $mode++) {
+    echo "--- mode $mode ---\n";
+    for ($offset = 0; $offset <= 12; $offset++) {
+      echo jdmonthname($jd + $offset * 30, $mode). "\n";
+    }
+  }
+}
+?>
+--EXPECT--
+### JD 2440588 ###
+--- mode 0 ---
+Jan
+Jan
+Mar
+Apr
+May
+May
+Jun
+Jul
+Aug
+Sep
+Oct
+Nov
+Dec
+--- mode 1 ---
+January
+January
+March
+April
+May
+May
+June
+July
+August
+September
+October
+November
+December
+--- mode 2 ---
+Dec
+Jan
+Feb
+Mar
+Apr
+May
+Jun
+Jul
+Aug
+Sep
+Oct
+Nov
+Dec
+--- mode 3 ---
+December
+January
+February
+March
+April
+May
+June
+July
+August
+September
+October
+November
+December
+--- mode 4 ---
+Tevet
+Shevat
+AdarI
+AdarII
+Nisan
+Iyyar
+Sivan
+Tammuz
+Av
+Elul
+Tishri
+Heshvan
+Kislev
+--- mode 5 ---
+
+
+
+
+
+
+
+
+
+
+
+
+
+--- mode 6 ---
+Jan
+Jan
+Mar
+Apr
+May
+May
+Jun
+Jul
+Aug
+Sep
+Oct
+Nov
+Dec
+### JD 2452162 ###
+--- mode 0 ---
+Sep
+Oct
+Nov
+Dec
+Jan
+Feb
+Mar
+Apr
+May
+Jun
+Jul
+Aug
+Sep
+--- mode 1 ---
+September
+October
+November
+December
+January
+February
+March
+April
+May
+June
+July
+August
+September
+--- mode 2 ---
+Aug
+Sep
+Oct
+Nov
+Dec
+Jan
+Feb
+Mar
+Apr
+May
+Jun
+Jul
+Aug
+--- mode 3 ---
+August
+September
+October
+November
+December
+January
+February
+March
+April
+May
+June
+July
+August
+--- mode 4 ---
+Elul
+Tishri
+Heshvan
+Kislev
+Tevet
+Shevat
+AdarI
+Nisan
+Iyyar
+Sivan
+Tammuz
+Av
+Elul
+--- mode 5 ---
+
+
+
+
+
+
+
+
+
+
+
+
+
+--- mode 6 ---
+Sep
+Oct
+Nov
+Dec
+Jan
+Feb
+Mar
+Apr
+May
+Jun
+Jul
+Aug
+Sep
+### JD 2453926 ###
+--- mode 0 ---
+Jul
+Aug
+Sep
+Oct
+Nov
+Dec
+Jan
+Feb
+Mar
+Apr
+May
+Jun
+Jul
+--- mode 1 ---
+July
+August
+September
+October
+November
+December
+January
+February
+March
+April
+May
+June
+July
+--- mode 2 ---
+Jun
+Jul
+Aug
+Sep
+Oct
+Nov
+Dec
+Jan
+Feb
+Mar
+Apr
+May
+Jun
+--- mode 3 ---
+June
+July
+August
+September
+October
+November
+December
+January
+February
+March
+April
+May
+June
+--- mode 4 ---
+Tammuz
+Av
+Elul
+Tishri
+Heshvan
+Kislev
+Tevet
+Shevat
+AdarI
+Nisan
+Iyyar
+Sivan
+Tammuz
+--- mode 5 ---
+
+
+
+
+
+
+
+
+
+
+
+
+
+--- mode 6 ---
+Jul
+Aug
+Sep
+Oct
+Nov
+Dec
+Jan
+Feb
+Mar
+Apr
+May
+Jun
+Jul
diff --git a/ext/calendar/tests/jdtofrench.phpt b/ext/calendar/tests/jdtofrench.phpt
new file mode 100644 (file)
index 0000000..2794409
--- /dev/null
@@ -0,0 +1,20 @@
+--TEST--
+jdtofrench()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+echo jdtofrench(0). "\n";
+echo jdtofrench(2375840). "\n";
+echo jdtofrench(2375850). "\n";
+echo jdtofrench(2375940). "\n";
+echo jdtofrench(2376345). "\n";
+echo jdtofrench(2385940). "\n";
+?>
+--EXPECT--
+0/0/0
+1/1/1
+1/11/1
+4/11/1
+5/21/2
+0/0/0
\ No newline at end of file
diff --git a/ext/calendar/tests/jdtogregorian.phpt b/ext/calendar/tests/jdtogregorian.phpt
new file mode 100644 (file)
index 0000000..6b1956f
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+jdtogregorian()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+echo jdtogregorian(0). "\n";
+echo jdtogregorian(2298874). "\n";
+echo jdtogregorian(2299151). "\n";
+echo jdtogregorian(2440588). "\n";
+echo jdtogregorian(2816423). "\n";
+?>
+--EXPECT--
+0/0/0
+1/1/1582
+10/5/1582
+1/1/1970
+1/1/2999
\ No newline at end of file
diff --git a/ext/calendar/tests/jdtojulian.phpt b/ext/calendar/tests/jdtojulian.phpt
new file mode 100644 (file)
index 0000000..6c87aa7
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+jdtojulian()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+echo jdtojulian(0). "\n";
+echo jdtojulian(2298874). "\n";
+echo jdtojulian(2299151). "\n";
+echo jdtojulian(2440588). "\n";
+echo jdtojulian(2816423). "\n";
+?>
+--EXPECT--
+0/0/0
+12/22/1581
+9/25/1582
+12/19/1969
+12/12/2998
\ No newline at end of file
diff --git a/ext/calendar/tests/jdtounix.phpt b/ext/calendar/tests/jdtounix.phpt
new file mode 100644 (file)
index 0000000..8d85543
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+jdtounix()
+--INI--
+date.timezone=UTC
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+echo date("Y-m-d",jdtounix(2440588)). "\n";
+echo date("Y-m-d",jdtounix(2452162)). "\n";
+echo date("Y-m-d",jdtounix(2453926)). "\n";
+?>
+--EXPECT--
+1970-01-01
+2001-09-09
+2006-07-09
diff --git a/ext/calendar/tests/jewishtojd.phpt b/ext/calendar/tests/jewishtojd.phpt
new file mode 100644 (file)
index 0000000..a9a2ff0
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+jewishtojd()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+echo jewishtojd(-1,-1,-1). "\n";
+echo jewishtojd(0,0,0). "\n";
+echo jewishtojd(1,1,1). "\n";
+echo jewishtojd(2,22,5763). "\n";
+?>
+--EXPECT--
+0
+0
+347998
+2452576
\ No newline at end of file
diff --git a/ext/calendar/tests/juliantojd.phpt b/ext/calendar/tests/juliantojd.phpt
new file mode 100644 (file)
index 0000000..9563e04
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+juliantojd()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+echo juliantojd( 0, 0,    0). "\n";
+echo juliantojd( 1, 1, 1582). "\n";
+echo juliantojd(10, 5, 1582). "\n";
+echo juliantojd( 1, 1, 1970). "\n";
+echo juliantojd( 1, 1, 2999). "\n";
+?>
+--EXPECT--
+0
+2298884
+2299161
+2440601
+2816443
\ No newline at end of file
diff --git a/ext/calendar/tests/unixtojd.phpt b/ext/calendar/tests/unixtojd.phpt
new file mode 100644 (file)
index 0000000..567a8c2
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+unixtojd()
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+echo unixtojd(40000). "\n";
+echo unixtojd(1000000000). "\n";
+echo unixtojd(1152459009). "\n";
+?>
+--EXPECT--
+2440588
+2452162
+2453926
diff --git a/ext/dom/tests/domattributes.phpt b/ext/dom/tests/domattributes.phpt
new file mode 100644 (file)
index 0000000..9097a88
--- /dev/null
@@ -0,0 +1,43 @@
+--TEST--
+Attributes: DOMAttribute functionality
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+require_once("dom_test.inc");
+
+$dom = new DOMDocument;
+$dom->loadXML($xmlstr);
+if(!$dom) {
+  echo "Error while parsing the document\n";
+  exit;
+}
+
+$node = $dom->documentElement;
+
+$lang = $node->getAttributeNode('language');
+echo "Language: ".$lang->value."\n";
+
+$lang->value = 'en-US';
+echo "Language: ".$lang->value."\n";
+
+$parent = $lang->ownerElement;
+
+$chapter = new DOMAttr("num", "1");
+$parent->setAttributeNode($chapter);
+
+echo "Is ID?: ".($chapter->isId()?'YES':'NO')."\n";
+
+$top_element = $node->cloneNode();
+
+print $dom->saveXML($top_element);
+
+
+?>
+--EXPECT--
+
+Language: en
+Language: en-US
+Is ID?: NO
+<chapter language="en-US" num="1"/>
+
diff --git a/ext/dom/tests/domchardata.phpt b/ext/dom/tests/domchardata.phpt
new file mode 100644 (file)
index 0000000..6baff6d
--- /dev/null
@@ -0,0 +1,76 @@
+--TEST--
+CharData: DOMCharacterData and related functionality
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+require_once("dom_test.inc");
+
+$dom = new DOMDocument;
+$dom->loadXML($xmlstr);
+if(!$dom) {
+  echo "Error while parsing the document\n";
+  exit;
+}
+
+$node = $dom->documentElement;
+
+$charnode = $dom->createElement('charnode');
+$node->appendChild($charnode);
+
+/* DOMComment */
+$comment = new DOMComment('Testing character data and extending nodes');
+$charnode->appendChild($comment);
+
+echo "Comment Length: ".$comment->length."\n";
+
+$comment->data = 'Updated comment';
+echo "New Comment Length: ".$comment->length."\n";
+echo "New Comment Data: ".$comment->data."\n";
+
+/* DOMCDataSection */
+$cdata = new DOMCDataSection('Chars: <>&"');
+$charnode->appendChild($cdata);
+
+echo "Substring: ".$cdata->substringData(7, 4)."\n";
+$cdata->replaceData(10, 1, "'");
+echo "New Substring: ".$cdata->substringData(7, 4)."\n";
+
+/* DOMCharacterData using DOMComment */
+$comment = new DOMComment('instructions');
+echo "Comment Value: ".$comment->data."\n";
+$comment->data = 'some more instructions';
+echo "New Comment Value: ".$comment->data."\n";
+
+$comment->insertData(10, 'pi ');
+$comment->replaceData(18, 5, 'i');
+$comment->insertData(20, 'g');
+$comment->deleteData(13, 2);
+$comment->deleteData(10, 3);
+$comment->insertData(10, 'comment ');
+echo "Updated Comment Value: ".$comment->data."\n";
+
+/* DOMText */
+$text = new DOMText('some text characters');
+
+echo "Whole Text: ".$text->wholeText."\n";
+$text2 = $text->splitText(9);
+
+echo "Split text: ".$text2->wholeText."\n";
+$text3 = $text2->splitText(1);
+
+echo "Is Whitespace?: ".($text2->isElementContentWhitespace()?'YES':'NO');
+?>
+--EXPECT--
+
+Comment Length: 42
+New Comment Length: 15
+New Comment Data: Updated comment
+Substring: <>&"
+New Substring: <>&'
+Comment Value: instructions
+New Comment Value: some more instructions
+Updated Comment Value: some more comment strings
+Whole Text: some text characters
+Split text:  characters
+Is Whitespace?: YES
diff --git a/ext/dom/tests/domelement.phpt b/ext/dom/tests/domelement.phpt
new file mode 100644 (file)
index 0000000..bc69af6
--- /dev/null
@@ -0,0 +1,114 @@
+--TEST--
+Elements: DOMElement functionality
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+require_once("dom_test.inc");
+
+$dom = new DOMDocument;
+$dom->loadXML($xmlstr);
+if(!$dom) {
+  echo "Error while parsing the document\n";
+  exit;
+}
+
+$node = $dom->documentElement;
+echo "Tag Name: ".$node->tagName."\n";
+
+
+$node->setAttribute('num', '1');
+echo "Chapter: ".$node->getAttribute('num')."\n";
+echo 'Attribute num exists?: '.($node->hasAttribute('num')?'Yes':'No')."\n";
+$node->removeAttribute('num');
+echo "Chapter: ".$node->getAttribute('num')."\n";
+echo 'Attribute num exists?: '.($node->hasAttribute('num')?'Yes':'No')."\n";
+
+echo "Language: ".$node->getAttribute('language')."\n";
+$lang = $node->getAttributeNode('language');
+$lang->nodeValue = 'en-US';
+$node->setAttributeNode($lang);
+echo "Language: ".$node->getAttribute('language')."\n";
+$node->removeAttributeNode($lang);
+echo "Language: ".$node->getAttribute('language')."\n";
+
+echo "\n-- xml:lang --\n";
+$node->setAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:lang', 'en');
+echo "Language: ".$node->getAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang')."\n";
+echo 'Attribute xml:lang exists?: '.($node->hasAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang')?'Yes':'No')."\n";
+
+$node->removeAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang');
+echo "Language: ".$node->getAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang')."\n";
+echo 'Attribute xml:lang exists?: '.($node->hasAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang')?'Yes':'No')."\n";
+
+$lang = $dom->createAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:lang');
+$lang->nodeValue = 'en-GB';
+$node->setAttributeNodeNS($lang);
+unset($lang);
+echo "Language: ".$node->getAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang')."\n";
+$lang = $node->getAttributeNodeNS('http://www.w3.org/XML/1998/namespace', 'lang');
+echo "Language: ".$lang->value."\n";
+
+echo "\n-- Elements --\n";
+$rows = $node->getElementsByTagName('row');
+echo "Row Count: ".$rows->length."\n";
+
+$element_ns = new DOMElement('newns:myelement', 'default content', 'urn::dummyns');
+$node->appendChild($element_ns);
+$element_ns = new DOMElement('newns2:myelement', 'second default content', 'urn::dummyns');
+$node->appendChild($element_ns);
+
+$myelements = $node->getElementsByTagNameNS('urn::dummyns', 'myelement');
+$mylen = $myelements->length;
+echo "myelements Count: ".$mylen."\n";
+
+echo "\n-- IDs --\n";
+$node->setAttribute('idatt', 'n1');
+$node->setIdAttribute('idatt', TRUE);
+
+for ($x = 0; $x < $mylen; $x++) {
+       $current = $myelements->item($x);
+       $current->setAttributeNS('urn::dummyns', 'newns:idatt', 'n'.($x+2))."\n";
+       $current->setIdAttributeNS('urn::dummyns', 'idatt', TRUE);
+}
+
+echo 'Element Name: '.(($elem = $dom->getElementByID('n1'))?$elem->localName:'Not Found')."\n";
+$idatt = $node->getAttributeNode('idatt');
+$node->setIdAttributeNode($idatt, FALSE);
+echo 'Element Name: '.(($elem = $dom->getElementByID('n1'))?$elem->localName:'Not Found')."\n";
+
+echo 'Element Name: '.(($elem = $dom->getElementByID('n3'))?$elem->nodeName:'Not Found')."\n";
+for ($x = 0; $x < $mylen; $x++) {
+       $node = $myelements->item($x);
+       $node->setIdAttributeNS('urn::dummyns', 'idatt', FALSE);
+}
+echo 'Element Name: '.(($elem = $dom->getElementByID('n3'))?$elem->nodeName:'Not Found')."\n";
+?>
+--EXPECT--
+
+Tag Name: chapter
+Chapter: 1
+Attribute num exists?: Yes
+Chapter: 
+Attribute num exists?: No
+Language: en
+Language: en-US
+Language: 
+
+-- xml:lang --
+Language: en
+Attribute xml:lang exists?: Yes
+Language: 
+Attribute xml:lang exists?: No
+Language: en-GB
+Language: en-GB
+
+-- Elements --
+Row Count: 3
+myelements Count: 2
+
+-- IDs --
+Element Name: chapter
+Element Name: Not Found
+Element Name: newns2:myelement
+Element Name: Not Found
diff --git a/tests/lang/catchable_error_001.phpt b/tests/lang/catchable_error_001.phpt
new file mode 100644 (file)
index 0000000..f6bbdd9
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Catchable fatal error [1]
+--FILE--
+<?php
+       class Foo {
+       }
+
+       function blah (Foo $a)
+       {
+       }
+
+       function error()
+       {
+               $a = func_get_args();
+               var_dump($a);
+       }
+
+       blah (new StdClass);
+       echo "ALIVE!\n";
+?>
+--EXPECTF--
+Catchable fatal error: Argument 1 passed to blah() must be an instance of Foo, instance of stdClass given, called in %scatchable_error_001.php on line 15 and defined in %scatchable_error_001.php on line 5
diff --git a/tests/lang/catchable_error_002.phpt b/tests/lang/catchable_error_002.phpt
new file mode 100644 (file)
index 0000000..c1762b2
--- /dev/null
@@ -0,0 +1,37 @@
+--TEST--
+Catchable fatal error [2]
+--FILE--
+<?php
+       class Foo {
+       }
+
+       function blah (Foo $a)
+       {
+       }
+
+       function error()
+       {
+               $a = func_get_args();
+               var_dump($a);
+       }
+
+       set_error_handler('error');
+
+       blah (new StdClass);
+       echo "ALIVE!\n";
+?>
+--EXPECTF--
+array(5) {
+  [0]=>
+  int(4096)
+  [1]=>
+  string(%d) "Argument 1 passed to blah() must be an instance of Foo, instance of stdClass given, called in %scatchable_error_002.php on line %d and defined"
+  [2]=>
+  string(%d) "%scatchable_error_002.php"
+  [3]=>
+  int(5)
+  [4]=>
+  array(0) {
+  }
+}
+ALIVE!