]> granicus.if.org Git - php/commitdiff
- New tests
authorFelipe Pena <felipe@php.net>
Tue, 4 May 2010 19:06:13 +0000 (19:06 +0000)
committerFelipe Pena <felipe@php.net>
Tue, 4 May 2010 19:06:13 +0000 (19:06 +0000)
Zend/tests/traits/error_001.phpt [new file with mode: 0644]
Zend/tests/traits/error_002.phpt [new file with mode: 0644]
Zend/tests/traits/error_003.phpt [new file with mode: 0644]
Zend/tests/traits/error_004.phpt [new file with mode: 0644]
Zend/tests/traits/error_005.phpt [new file with mode: 0644]
Zend/tests/traits/error_006.phpt [new file with mode: 0644]
Zend/tests/traits/error_007.phpt [new file with mode: 0644]
Zend/tests/traits/error_008.phpt [new file with mode: 0644]
Zend/tests/traits/error_009.phpt [new file with mode: 0644]

diff --git a/Zend/tests/traits/error_001.phpt b/Zend/tests/traits/error_001.phpt
new file mode 100644 (file)
index 0000000..307e5c1
--- /dev/null
@@ -0,0 +1,28 @@
+--TEST--
+Trying to use instanceof for a method twice
+--FILE--
+<?php
+
+trait foo {    
+       public function foo() {
+               return 1;
+       }
+}
+
+trait foo2 {
+       public function foo() {
+               return 2;
+       }
+}
+
+
+class A extends foo {
+       use foo {
+               foo2::foo insteadof foo;
+               foo2::foo insteadof foo;
+       }
+}
+
+?>
+--EXPECTF--
+Fatal error: Class A cannot extend from trait foo in %s on line %d
diff --git a/Zend/tests/traits/error_002.phpt b/Zend/tests/traits/error_002.phpt
new file mode 100644 (file)
index 0000000..ac98769
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+Trying to use an undefined trait
+--FILE--
+<?php
+
+class A {
+       use abc;
+}
+
+?>
+--EXPECTF--
+Fatal error: Trait 'abc' not found in %s on line %d
diff --git a/Zend/tests/traits/error_003.phpt b/Zend/tests/traits/error_003.phpt
new file mode 100644 (file)
index 0000000..5122155
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Trying to use an interface as trait
+--FILE--
+<?php
+
+interface abc { 
+}
+
+class A {
+       use abc;
+}
+
+?>
+--EXPECTF--
+Fatal error: A cannot use abc - it is not a trait in %s on line %d
diff --git a/Zend/tests/traits/error_004.phpt b/Zend/tests/traits/error_004.phpt
new file mode 100644 (file)
index 0000000..c7ac916
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Trying to use a class as trait
+--FILE--
+<?php
+
+class abc { 
+}
+
+class A {
+       use abc;
+}
+
+?>
+--EXPECTF--
+Fatal error: A cannot use abc - it is not a trait in %s on line %d
diff --git a/Zend/tests/traits/error_005.phpt b/Zend/tests/traits/error_005.phpt
new file mode 100644 (file)
index 0000000..5aa5e10
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Trying to use a final class as trait
+--FILE--
+<?php
+
+final class abc { 
+}
+
+class A {
+       use abc;
+}
+
+?>
+--EXPECTF--
+Fatal error: A cannot use abc - it is not a trait in %s on line %d
diff --git a/Zend/tests/traits/error_006.phpt b/Zend/tests/traits/error_006.phpt
new file mode 100644 (file)
index 0000000..0169321
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Trying to use an abstract class as trait
+--FILE--
+<?php
+
+abstract class abc { 
+}
+
+class A {
+       use abc;
+}
+
+?>
+--EXPECTF--
+Fatal error: A cannot use abc - it is not a trait in %s on line %d
diff --git a/Zend/tests/traits/error_007.phpt b/Zend/tests/traits/error_007.phpt
new file mode 100644 (file)
index 0000000..82a6a2e
--- /dev/null
@@ -0,0 +1,13 @@
+--TEST--
+Trying to instantiate a trait
+--FILE--
+<?php
+
+trait abc { 
+}
+
+new abc;
+
+?>
+--EXPECTF--
+Fatal error: Cannot instantiate trait abc in %s on line %d
diff --git a/Zend/tests/traits/error_008.phpt b/Zend/tests/traits/error_008.phpt
new file mode 100644 (file)
index 0000000..ee97d75
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+Trying to implement a trait
+--FILE--
+<?php
+
+trait abc { }
+
+class foo implements abc { }
+
+?>
+--EXPECTF--
+Fatal error: foo cannot implement abc - it is not an interface in %s on line %d
diff --git a/Zend/tests/traits/error_009.phpt b/Zend/tests/traits/error_009.phpt
new file mode 100644 (file)
index 0000000..a1eb6b4
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+Trying to extend a trait
+--FILE--
+<?php
+
+trait abc { }
+
+class foo extends abc { }
+
+?>
+--EXPECTF--
+Fatal error: Class foo cannot extend from trait abc in %s on line %d