gron                                     Wed, 17 Nov 2010 23:05:20 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=305473

Log:
Added tests to for static support of traits.
# This was not tested and documented yet.
# Updated documentation in the RFC http://wiki.php.net/rfc/horizontalreuse

Changed paths:
    A   php/php-src/trunk/Zend/tests/traits/static_001.phpt
    A   php/php-src/trunk/Zend/tests/traits/static_002.phpt
    A   php/php-src/trunk/Zend/tests/traits/static_003.phpt
    A   php/php-src/trunk/Zend/tests/traits/static_004.phpt
    A   php/php-src/trunk/Zend/tests/traits/static_forward_static_call.phpt
    A   php/php-src/trunk/Zend/tests/traits/static_get_called_class.phpt

Added: php/php-src/trunk/Zend/tests/traits/static_001.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/traits/static_001.phpt                         
(rev 0)
+++ php/php-src/trunk/Zend/tests/traits/static_001.phpt 2010-11-17 23:05:20 UTC 
(rev 305473)
@@ -0,0 +1,22 @@
+--TEST--
+Traits with static methods.
+--CREDITS--
+Simas Toleikis sim...@gmail.com
+--FILE--
+<?php
+
+       trait TestTrait {
+               public static function test() {
+                       return 'Test';
+               }
+       }
+
+       class A {
+               use TestTrait;
+       }
+
+       echo A::test();
+
+?>
+--EXPECT--
+Test
\ No newline at end of file

Added: php/php-src/trunk/Zend/tests/traits/static_002.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/traits/static_002.phpt                         
(rev 0)
+++ php/php-src/trunk/Zend/tests/traits/static_002.phpt 2010-11-17 23:05:20 UTC 
(rev 305473)
@@ -0,0 +1,23 @@
+--TEST--
+Traits with static methods referenced using variable.
+--CREDITS--
+Simas Toleikis sim...@gmail.com
+--FILE--
+<?php
+
+       trait TestTrait {
+               public static function test() {
+                       return 'Test';
+               }
+       }
+
+       class A {
+               use TestTrait;
+       }
+
+       $class = "A";
+       echo $class::test();
+
+?>
+--EXPECT--
+Test
\ No newline at end of file

Added: php/php-src/trunk/Zend/tests/traits/static_003.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/traits/static_003.phpt                         
(rev 0)
+++ php/php-src/trunk/Zend/tests/traits/static_003.phpt 2010-11-17 23:05:20 UTC 
(rev 305473)
@@ -0,0 +1,27 @@
+--TEST--
+Traits with late static bindings.
+--CREDITS--
+Simas Toleikis sim...@gmail.com
+--FILE--
+<?php
+
+       trait TestTrait {
+               public static function test() {
+                       return static::$test;
+               }
+       }
+
+       class A {
+               use TestTrait;
+               protected static $test = "Test A";
+       }
+
+       class B extends A {
+               protected static $test = "Test B";
+       }
+
+       echo B::test();
+
+?>
+--EXPECT--
+Test B
\ No newline at end of file

Added: php/php-src/trunk/Zend/tests/traits/static_004.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/traits/static_004.phpt                         
(rev 0)
+++ php/php-src/trunk/Zend/tests/traits/static_004.phpt 2010-11-17 23:05:20 UTC 
(rev 305473)
@@ -0,0 +1,22 @@
+--TEST--
+Traits with __callStatic magic method.
+--CREDITS--
+Simas Toleikis sim...@gmail.com
+--FILE--
+<?php
+
+       trait TestTrait {
+               public static function __callStatic($name, $arguments) {
+                       return $name;
+               }
+       }
+
+       class A {
+               use TestTrait;
+       }
+
+       echo A::Test();
+
+?>
+--EXPECT--
+Test
\ No newline at end of file

Added: php/php-src/trunk/Zend/tests/traits/static_forward_static_call.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/traits/static_forward_static_call.phpt         
                (rev 0)
+++ php/php-src/trunk/Zend/tests/traits/static_forward_static_call.phpt 
2010-11-17 23:05:20 UTC (rev 305473)
@@ -0,0 +1,28 @@
+--TEST--
+Traits and forward_static_call().
+--CREDITS--
+Simas Toleikis sim...@gmail.com
+--FILE--
+<?php
+
+       trait TestTrait {
+               public static function test() {
+                       return 'Forwarded '.forward_static_call(array('A', 
'test'));
+               }
+       }
+
+       class A {
+               public static function test() {
+                       return "Test A";
+               }
+       }
+
+       class B extends A {
+               use TestTrait;
+       }
+
+       echo B::test();
+
+?>
+--EXPECT--
+Forwarded Test A
\ No newline at end of file

Added: php/php-src/trunk/Zend/tests/traits/static_get_called_class.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/traits/static_get_called_class.phpt            
                (rev 0)
+++ php/php-src/trunk/Zend/tests/traits/static_get_called_class.phpt    
2010-11-17 23:05:20 UTC (rev 305473)
@@ -0,0 +1,24 @@
+--TEST--
+Traits and get_called_class().
+--CREDITS--
+Simas Toleikis sim...@gmail.com
+--FILE--
+<?php
+
+       trait TestTrait {
+               public static function test() {
+                       return get_called_class();
+               }
+       }
+
+       class A {
+               use TestTrait;
+       }
+
+       class B extends A { }
+
+       echo B::test();
+
+?>
+--EXPECT--
+B
\ No newline at end of file

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to