summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2008-05-12 13:30:50 +0000
committerFelipe Pena <felipe@php.net>2008-05-12 13:30:50 +0000
commitc065d7e7e7174554a966ee32039cf5512c769f38 (patch)
treed5e12819a24610f1859aa07624191f2bf6ced037
parent7416b0cd91dd214485e51351cca67734dd281f19 (diff)
downloadphp-git-c065d7e7e7174554a966ee32039cf5512c769f38.tar.gz
- New tests
-rw-r--r--Zend/tests/class_alias_001.phpt30
-rw-r--r--Zend/tests/class_alias_002.phpt12
-rw-r--r--Zend/tests/class_alias_003.phpt22
-rw-r--r--Zend/tests/class_alias_004.phpt15
-rw-r--r--Zend/tests/class_alias_005.phpt27
-rw-r--r--Zend/tests/class_alias_006.phpt10
-rw-r--r--Zend/tests/class_alias_007.phpt19
-rw-r--r--Zend/tests/class_alias_008.phpt16
-rw-r--r--Zend/tests/class_alias_009.phpt14
-rw-r--r--Zend/tests/class_alias_010.phpt14
10 files changed, 179 insertions, 0 deletions
diff --git a/Zend/tests/class_alias_001.phpt b/Zend/tests/class_alias_001.phpt
new file mode 100644
index 0000000000..371f08f80b
--- /dev/null
+++ b/Zend/tests/class_alias_001.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Testing class_alias()
+--FILE--
+<?php
+
+class foo { }
+
+class_alias('foo', 'bar');
+
+$a = new foo;
+$b = new bar;
+
+var_dump($a == $b, $a === $b);
+var_dump($a instanceof $b);
+
+var_dump($a instanceof foo);
+var_dump($a instanceof bar);
+
+var_dump($b instanceof foo);
+var_dump($b instanceof bar);
+
+?>
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
diff --git a/Zend/tests/class_alias_002.phpt b/Zend/tests/class_alias_002.phpt
new file mode 100644
index 0000000000..9601cb25e8
--- /dev/null
+++ b/Zend/tests/class_alias_002.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Trying redeclare class with class_alias()
+--FILE--
+<?php
+
+class foo { }
+
+class_alias('foo', 'FOO');
+
+?>
+--EXPECTF--
+Warning: Cannot redeclare class FOO in %s on line %d
diff --git a/Zend/tests/class_alias_003.phpt b/Zend/tests/class_alias_003.phpt
new file mode 100644
index 0000000000..57e2fd572e
--- /dev/null
+++ b/Zend/tests/class_alias_003.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Testing declaration of alias to 'static'
+--FILE--
+<?php
+
+class bar {
+}
+
+class foo {
+ public function test() {
+ class_alias('bar', 'static');
+ return new static;
+ }
+}
+
+$a = new foo;
+var_dump($a->test());
+
+?>
+--EXPECTF--
+object(foo)#%d (0) {
+}
diff --git a/Zend/tests/class_alias_004.phpt b/Zend/tests/class_alias_004.phpt
new file mode 100644
index 0000000000..b7dbabdeb0
--- /dev/null
+++ b/Zend/tests/class_alias_004.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Testing creation of alias using an existing interface name
+--FILE--
+<?php
+
+class foo { }
+
+interface test { }
+
+
+class_alias('foo', 'test');
+
+?>
+--EXPECTF--
+Warning: Cannot redeclare class test in %s on line %d
diff --git a/Zend/tests/class_alias_005.phpt b/Zend/tests/class_alias_005.phpt
new file mode 100644
index 0000000000..47c825b41b
--- /dev/null
+++ b/Zend/tests/class_alias_005.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Testing static call method using the original class name
+--FILE--
+<?php
+
+class foo {
+ static public function msg() {
+ print "hello\n";
+ }
+}
+
+interface test { }
+
+
+class_alias('foo', 'baz');
+
+class bar extends baz {
+ public function __construct() {
+ foo::msg();
+ }
+}
+
+new bar;
+
+?>
+--EXPECT--
+hello
diff --git a/Zend/tests/class_alias_006.phpt b/Zend/tests/class_alias_006.phpt
new file mode 100644
index 0000000000..d14ad7c933
--- /dev/null
+++ b/Zend/tests/class_alias_006.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Testing creation of alias to an internal class
+--FILE--
+<?php
+
+class_alias('stdclass', 'foo');
+
+?>
+--EXPECTF--
+Warning: First argument of class_alias() must be a name of user defined class in %s on line %d
diff --git a/Zend/tests/class_alias_007.phpt b/Zend/tests/class_alias_007.phpt
new file mode 100644
index 0000000000..247398e2ed
--- /dev/null
+++ b/Zend/tests/class_alias_007.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing class_alias() using autoload
+--FILE--
+<?php
+
+function __autoload($a) {
+ class foo { }
+}
+
+class_alias('foo', 'bar', 1);
+
+var_dump(new foo, new bar);
+
+?>
+--EXPECTF--
+object(foo)#%d (0) {
+}
+object(foo)#%d (0) {
+}
diff --git a/Zend/tests/class_alias_008.phpt b/Zend/tests/class_alias_008.phpt
new file mode 100644
index 0000000000..8ee8fa03f8
--- /dev/null
+++ b/Zend/tests/class_alias_008.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Testing class_alias() with abstract class using an arbitrary class name as alias
+--FILE--
+<?php
+
+abstract class foo { }
+
+class_alias('foo', "\0");
+
+$a = "\0";
+
+new $a;
+
+?>
+--EXPECTF--
+Fatal error: Cannot instantiate abstract class foo in %s on line %d
diff --git a/Zend/tests/class_alias_009.phpt b/Zend/tests/class_alias_009.phpt
new file mode 100644
index 0000000000..f17769e1f4
--- /dev/null
+++ b/Zend/tests/class_alias_009.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Testing interface declaration using the original and alias class name
+--FILE--
+<?php
+
+interface a { }
+
+class_alias('a', 'b');
+
+interface c extends a, b { }
+
+?>
+--EXPECTF--
+Fatal error: Class c cannot implement previously implemented interface a in %s on line %d
diff --git a/Zend/tests/class_alias_010.phpt b/Zend/tests/class_alias_010.phpt
new file mode 100644
index 0000000000..38590b664a
--- /dev/null
+++ b/Zend/tests/class_alias_010.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Trying use an existing alias name in class declaration
+--FILE--
+<?php
+
+interface a { }
+
+class_alias('a', 'b');
+
+class b { }
+
+?>
+--EXPECTF--
+Warning: Cannot redeclare class b in %s on line %d