Added: php/php-src/trunk/Zend/tests/traits/bugs/abstract-methods01.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/bugs/abstract-methods01.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/bugs/abstract-methods01.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,19 @@ +--TEST-- +Abstract Trait Methods should behave like common abstract methods. +--FILE-- +hello(); +?> +--EXPECTF-- +Fatal error: Class %s contains %d abstract method and must therefore be declared abstract or implement the remaining methods (%s) in %s on line %d \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/bugs/abstract-methods02.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/bugs/abstract-methods02.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/bugs/abstract-methods02.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,26 @@ +--TEST-- +Abstract Trait Methods should behave like common abstract methods. +--FILE-- +hello(); +?> +--EXPECTF-- +Hello \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/bugs/abstract-methods03.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/bugs/abstract-methods03.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/bugs/abstract-methods03.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,22 @@ +--TEST-- +Abstract Trait Methods should behave like common abstract methods. +--FILE-- +hello(); +?> +--EXPECTF-- +Hello \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/bugs/abstract-methods04.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/bugs/abstract-methods04.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/bugs/abstract-methods04.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,36 @@ +--TEST-- +Abstract Trait Methods should behave like common abstract methods and +implementstion may be provided by other traits. Sorting order shouldn't influence result. +--FILE-- +hello(); + +class TraitsTest2 { + use THelloImpl; + use THello; +} + +$test = new TraitsTest2(); +$test->hello(); + +?> +--EXPECTF-- +HelloHello \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/bugs/alias-semantics.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/bugs/alias-semantics.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/bugs/alias-semantics.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,23 @@ +--TEST-- +Semantic of alias operation is to provide an additional identifier for the method body of the original method. +--FILE-- +a(); +$test->b(); + +?> +--EXPECTF-- +AA \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/bugs/case-sensitive.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/bugs/case-sensitive.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/bugs/case-sensitive.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,25 @@ +--TEST-- +Check for problems with case sensitivity in compositions +--FILE-- + +--EXPECTF-- +Warning: Trait method M1 has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d + +Warning: Trait method M2 has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/bugs/interfaces.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/bugs/interfaces.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/bugs/interfaces.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,19 @@ +--TEST-- +Make sure trait does not implement an interface. +--FILE-- + +--EXPECTF-- +Fatal error: Cannot use 'MyInterface' as interface on 'THello' since it is a Trait in %s on line %d \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/bugs/missing-trait.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/bugs/missing-trait.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/bugs/missing-trait.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,15 @@ +--TEST-- +Check error message for missing traits +--FILE-- + +--EXPECTF-- +Fatal error: Trait 'THello' not found in %s on line %d \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/bugs/overridding-conflicting-methods.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/bugs/overridding-conflicting-methods.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/bugs/overridding-conflicting-methods.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,31 @@ +--TEST-- +Overridding Conflicting Methods should not result in a notice/warning about collisions +--FILE-- +hello(); +?> +--EXPECTF-- +Hello \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/conflict001.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/conflict001.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/conflict001.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,25 @@ +--TEST-- +Method conflict in traits +--FILE-- + +--EXPECTF-- +Warning: Trait method hello has not been applied, because there are collisions with other trait methods on TraitsTest in %s on line %d \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/conflict002.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/conflict002.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/conflict002.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,32 @@ +--TEST-- +Overwridden methods do not cause a conflict. +--FILE-- +sayHello(); // echos Hello Universe! +?> +--EXPECTF-- +Hello Universe! \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/conflict003.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/conflict003.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/conflict003.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,33 @@ +--TEST-- +Two methods resulting in a conflict, should be reported both. +--FILE-- + +--EXPECTF-- +Warning: Trait method smallTalk has not been applied, because there are collisions with other trait methods on Talker in %s on line %d + +Warning: Trait method bigTalk has not been applied, because there are collisions with other trait methods on Talker in %s on line %d \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/flattening001.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/flattening001.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/flattening001.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,42 @@ +--TEST-- +Methods using object properties +--FILE-- +text; + } +} + +trait T2 { + public function setTextT2($val) { + $this->text = $val; + } +} + +class TraitsTest { + use T1; + use T2; + private $text = 'test'; + public function setText($val) { + $this->text = $val; + } +} + +$o = new TraitsTest(); +var_dump($o->getText()); + +$o->setText('foo'); + +var_dump($o->getText()); + +$o->setText('bar'); + +var_dump($o->getText()); +?> +--EXPECTF-- +string(4) "test" +string(3) "foo" +string(3) "bar" \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/flattening002.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/flattening002.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/flattening002.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,28 @@ +--TEST-- +parent:: works like in a method defined without traits. +--FILE-- +sayHello(); +?> +--EXPECTF-- +Hello World! \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/flattening003.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/flattening003.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/flattening003.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,32 @@ +--TEST-- +Traits are flattened recurivly. +--FILE-- +sayHello(); +$o->sayWorld(); +?> +--EXPECTF-- +Hello World! \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/inheritance001.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/inheritance001.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/inheritance001.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,24 @@ +--TEST-- +Trait method overwridden by a method defined in the class. +--FILE-- +sayHello(); // echos Hello Universe! +?> +--EXPECTF-- +Hello Universe! \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/inheritance002.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/inheritance002.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/inheritance002.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,27 @@ +--TEST-- +Trait method overriddes base class method +--FILE-- +sayHello(); +?> +--EXPECTF-- +World! \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/inheritance003.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/inheritance003.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/inheritance003.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,38 @@ +--TEST-- +Trait method overriddes base class method and satisfies prototype +--FILE-- +sayHello(array()); + + +trait SayWorld { + public function sayHello(Base $d) { + echo 'World!'; + } +} + +class MyHelloWorld extends Base { + use SayWorld; +} + +$o = new MyHelloWorld(); +$o->sayHello(array()); + +?> +--EXPECTF-- +World! + +Fatal error: Declaration of MyHelloWorld::sayHello() must be compatible with that of Base::sayHello() in %s on line %d Added: php/php-src/trunk/Zend/tests/traits/language001.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/language001.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/language001.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,21 @@ +--TEST-- +Single Trait with simple trait method +--FILE-- +hello(); +?> +--EXPECTF-- +Hello Added: php/php-src/trunk/Zend/tests/traits/language002.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/language002.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/language002.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,32 @@ +--TEST-- +Use multiple traits. +--FILE-- +sayHello(); +$o->sayWorld(); +$o->sayExclamationMark(); +?> +--EXPECTF-- +Hello World! \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/language003.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/language003.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/language003.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,29 @@ +--TEST-- +Use instead to solve a conflict. +--FILE-- +saySomething(); +?> +--EXPECTF-- +Hello \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/language004.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/language004.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/language004.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,31 @@ +--TEST-- +Use instead to solve a conflict and as to access the method. +--FILE-- +saySomething(); +$o->sayWorld(); +?> +--EXPECTF-- +Hello World \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/language005.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/language005.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/language005.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,40 @@ +--TEST-- +Use instead to solve a conflict and as to access the method. +--FILE-- +smallTalk(); +$t->bigTalk(); +$t->talk(); + +?> +--EXPECTF-- +bAB \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/language006.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/language006.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/language006.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,31 @@ +--TEST-- +Express requirements of a trait by abstract methods. +--FILE-- +getWorld(); + } + abstract public function getWorld(); + } + +class MyHelloWorld { + private $world; + use Hello; + public function getWorld() { + return $this->world; + } + public function setWorld($val) { + $this->world = $val; + } +} + +$o = new MyHelloWorld(); +$o->setWorld(' World!'); +$o->sayHelloWorld(); + +?> +--EXPECTF-- +Hello World! \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/language007.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/language007.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/language007.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,30 @@ +--TEST-- +Traits can fulfill the requirements of abstract base classes. +--FILE-- +sayHello(); +$o->sayWorld(); + +?> +--EXPECTF-- +Hello World! \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/language008a.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/language008a.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/language008a.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,23 @@ +--TEST-- +Visibility can be changed with the as aliasing construct as well. +--FILE-- +sayHello(); + +?> +--EXPECTF-- +Fatal error: Call to protected method MyClass::sayHello() from context '' in %s on line %d \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/language008b.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/language008b.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/language008b.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,30 @@ +--TEST-- +Visibility can be changed with the as aliasing construct as well. +--FILE-- +sayHelloWorld(); + } +} + +$o = new MyClass(); +$o->sayHello(); +$o->callPrivateAlias(); +$o->sayHelloWorld(); + + +?> +--EXPECTF-- +Hello World!Hello World! +Fatal error: Call to private method MyClass::sayHelloWorld() from context '' in %s on line %d \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/language009.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/language009.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/language009.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,36 @@ +--TEST-- +In instead definitions all trait whose methods are meant to be hidden can be listed. +--FILE-- +foo(); + +?> +--EXPECTF-- +b \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/language010.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/language010.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/language010.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,32 @@ +--TEST-- +Aliasing leading to conflict should result in error message +--FILE-- +hello(); +$o->world(); + +?> +--EXPECTF-- +Warning: Trait method world has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d +Hello +Fatal error: Call to undefined method MyClass::world() in %s on line %d \ No newline at end of file Added: php/php-src/trunk/Zend/tests/traits/language011.phpt =================================================================== --- php/php-src/trunk/Zend/tests/traits/language011.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/language011.phpt 2010-04-15 21:39:20 UTC (rev 298062) @@ -0,0 +1,34 @@ +--TEST-- +Aliasing leading to conflict should result in error message +--FILE-- +sayHello(); +$o->sayWorld(); + +?> +--EXPECTF-- +Warning: Trait method sayWorld has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d + +Warning: Trait method sayHello has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d + +Fatal error: Call to undefined method MyClass::sayHello() in %s on line %d \ No newline at end of file