summaryrefslogtreecommitdiff
path: root/Zend/tests
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2007-06-07 08:37:40 +0000
committerAntony Dovgal <tony2001@php.net>2007-06-07 08:37:40 +0000
commit91da96ba71867b72278aeb4d6deaff334c7f3771 (patch)
tree68e66f41a07914481cb3507ab08f4d81d7c2251b /Zend/tests
parent20b5c66e14838928b656419144020ce415e3b25a (diff)
downloadphp-git-91da96ba71867b72278aeb4d6deaff334c7f3771.tar.gz
MFH: change E_NOTICE to E_ERROR when using a class constant from non-existent class
(noticed by Jani) add tests
Diffstat (limited to 'Zend/tests')
-rw-r--r--Zend/tests/class_constants_001.phpt22
-rw-r--r--Zend/tests/class_constants_002.phpt31
-rw-r--r--Zend/tests/class_constants_003.phpt33
3 files changed, 86 insertions, 0 deletions
diff --git a/Zend/tests/class_constants_001.phpt b/Zend/tests/class_constants_001.phpt
new file mode 100644
index 0000000000..45270f6f73
--- /dev/null
+++ b/Zend/tests/class_constants_001.phpt
@@ -0,0 +1,22 @@
+--TEST--
+class constants basic tests
+--FILE--
+<?php
+
+class test {
+ const val = "string";
+ const val2 = 1;
+}
+
+var_dump(test::val);
+var_dump(test::val2);
+
+var_dump(test::val3);
+
+echo "Done\n";
+?>
+--EXPECTF--
+string(6) "string"
+int(1)
+
+Fatal error: Undefined class constant 'val3' in %s on line %d
diff --git a/Zend/tests/class_constants_002.phpt b/Zend/tests/class_constants_002.phpt
new file mode 100644
index 0000000000..9aad8088da
--- /dev/null
+++ b/Zend/tests/class_constants_002.phpt
@@ -0,0 +1,31 @@
+--TEST--
+class constants as default function arguments
+--FILE--
+<?php
+
+class test {
+ const val = 1;
+}
+
+function foo($v = test::val) {
+ var_dump($v);
+}
+
+function bar($b = NoSuchClass::val) {
+ var_dump($b);
+}
+
+foo();
+foo(5);
+
+bar(10);
+bar();
+
+echo "Done\n";
+?>
+--EXPECTF--
+int(1)
+int(5)
+int(10)
+
+Fatal error: Class 'NoSuchClass' not found in %s on line %d
diff --git a/Zend/tests/class_constants_003.phpt b/Zend/tests/class_constants_003.phpt
new file mode 100644
index 0000000000..c2782ff1c9
--- /dev/null
+++ b/Zend/tests/class_constants_003.phpt
@@ -0,0 +1,33 @@
+--TEST--
+class constants as default function arguments and dynamically loaded classes
+--FILE--
+<?php
+
+$class_data = <<<DATA
+<?php
+class test {
+ const val = 1;
+}
+?>
+DATA;
+
+$filename = dirname(__FILE__)."/cc003.dat";
+file_put_contents($filename, $class_data);
+
+function foo($v = test::val) {
+ var_dump($v);
+}
+
+include $filename;
+
+foo();
+foo(5);
+
+unlink($filename);
+
+echo "Done\n";
+?>
+--EXPECTF--
+int(1)
+int(5)
+Done