forked from zenovich/runkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new tests were added, old tests were improved
- Loading branch information
Showing
34 changed files
with
707 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
--TEST-- | ||
runkit_default_property_add() add properties to subclasses | ||
--SKIPIF-- | ||
<?php if(!extension_loaded("runkit") || !RUNKIT_FEATURE_MANIPULATION) print "skip"; | ||
if(array_shift(explode('.', PHP_VERSION)) < 5) print "skip"; | ||
?> | ||
--INI-- | ||
error_reporting=E_ALL | ||
display_errors=on | ||
--FILE-- | ||
<?php | ||
class RunkitClass { | ||
public function setPrivate() {$this->privateProperty = "b";} | ||
public function setProtected() {$this->protectedProperty = 1;} | ||
} | ||
|
||
class RunkitSubClass extends RunkitClass {} | ||
class StdSubClass extends stdClass {} | ||
|
||
$className = 'RunkitClass'; | ||
$propName = 'publicProperty'; | ||
$parentObj = new $className; | ||
runkit_default_property_add($className, 'constArray', array('a'=>1)); | ||
runkit_default_property_add($className, $propName, 1, RUNKIT_ACC_PUBLIC); | ||
runkit_default_property_add($className, 'privateProperty', "a", RUNKIT_ACC_PRIVATE); | ||
runkit_default_property_add($className, 'protectedProperty', NULL, RUNKIT_ACC_PROTECTED); | ||
$obj = new RunkitSubClass; | ||
runkit_default_property_add($className, 'dynamic', $obj); | ||
|
||
$parentObj->constArray = array('b'=>2); | ||
$parentObj->publicProperty = 2; | ||
$parentObj->setPrivate(); | ||
$parentObj->setProtected(); | ||
$parentObj->dynamic = $parentObj; | ||
|
||
print_r($obj); | ||
print_r(new RunkitSubClass); | ||
|
||
runkit_default_property_add('StdSubClass', 'str', 'test'); | ||
|
||
$obj = new StdSubClass(); | ||
print_r($obj); | ||
?> | ||
--EXPECTF-- | ||
RunkitSubClass Object | ||
( | ||
[constArray] => Array | ||
( | ||
[a] => 1 | ||
) | ||
|
||
[publicProperty] => 1 | ||
[privateProperty%sprivate] => a | ||
[protectedProperty:protected] =>%w | ||
%w[dynamic] => RunkitSubClass Object | ||
%w*RECURSION*%w | ||
) | ||
RunkitSubClass Object | ||
( | ||
[constArray] => Array | ||
( | ||
[a] => 1 | ||
) | ||
|
||
[publicProperty] => 1 | ||
[privateProperty%sprivate] => a | ||
[protectedProperty:protected] =>%w | ||
[dynamic] => RunkitSubClass Object | ||
( | ||
[constArray] => Array | ||
( | ||
[a] => 1 | ||
) | ||
|
||
[publicProperty] => 1 | ||
[privateProperty%sprivate] => a | ||
[protectedProperty:protected] =>%w | ||
%w[dynamic] => RunkitSubClass Object | ||
%w*RECURSION*%w | ||
) | ||
|
||
) | ||
StdSubClass Object | ||
( | ||
[str] => test | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--TEST-- | ||
runkit_default_property_remove() remove properties from subclasses | ||
--SKIPIF-- | ||
<?php if(!extension_loaded("runkit") || !RUNKIT_FEATURE_MANIPULATION) print "skip"; | ||
if(array_shift(explode(".", PHP_VERSION)) < 5) print "skip"; | ||
?> | ||
--INI-- | ||
error_reporting=E_ALL | ||
display_errors=On | ||
--FILE-- | ||
<?php | ||
class RunkitClass { | ||
public $constArray = array(); | ||
public $publicProperty = 1; | ||
public $publicproperty = 2; | ||
private $privateProperty = "a"; | ||
protected $protectedProperty = "b"; | ||
} | ||
|
||
class RunkitSubClass extends RunkitClass {} | ||
class StdSubClass extends stdClass {} | ||
|
||
ini_set('display_errors', 1); | ||
ini_set('error_reporting', E_ALL); | ||
|
||
$className = 'RunkitClass'; | ||
$obj = new RunkitSubClass(); | ||
runkit_default_property_add($className, 'dynamic', $obj); | ||
|
||
runkit_default_property_remove($className, 'dynamic'); | ||
runkit_default_property_remove($className, 'publicproperty'); | ||
runkit_default_property_remove($className, 'publicproperty'); | ||
runkit_default_property_remove($className, 'privateProperty'); | ||
runkit_default_property_remove($className, 'protectedProperty'); | ||
runkit_default_property_remove($className, 'constArray'); | ||
print_r(new RunkitSubClass()); | ||
|
||
$obj = new StdSubClass(); | ||
runkit_default_property_add('StdSubClass', 'str', "test"); | ||
runkit_default_property_remove('StdSubClass', 'str'); | ||
print_r($obj); | ||
$obj = NULL; | ||
?> | ||
--EXPECTF-- | ||
Warning: runkit_default_property_remove(): RunkitClass::publicproperty does not exist in %s on line %d | ||
RunkitSubClass Object | ||
( | ||
[publicProperty] => 1 | ||
) | ||
StdSubClass Object | ||
( | ||
) |
48 changes: 48 additions & 0 deletions
48
tests/runkit_default_property_remove_from_subclasses4.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--TEST-- | ||
runkit_default_property_remove() remove properties from subclasses (PHP4) | ||
--SKIPIF-- | ||
<?php if(!extension_loaded("runkit") || !RUNKIT_FEATURE_MANIPULATION) print "skip"; | ||
if(array_shift(explode(".", PHP_VERSION)) >= 5) print "skip"; | ||
?> | ||
--INI-- | ||
error_reporting=E_ALL | ||
display_errors=On | ||
--FILE-- | ||
<?php | ||
class RunkitClass { | ||
var $constArray = array(); | ||
var $publicProperty = 1; | ||
var $publicproperty = 2; | ||
} | ||
|
||
class RunkitSubClass extends RunkitClass {} | ||
class StdSubClass extends stdClass {} | ||
|
||
ini_set('display_errors', 1); | ||
ini_set('error_reporting', E_ALL); | ||
|
||
$className = 'RunkitClass'; | ||
$obj = new RunkitSubClass(); | ||
runkit_default_property_add($className, 'dynamic', $obj); | ||
|
||
runkit_default_property_remove($className, 'dynamic'); | ||
runkit_default_property_remove($className, 'publicproperty'); | ||
runkit_default_property_remove($className, 'publicproperty'); | ||
runkit_default_property_remove($className, 'constArray'); | ||
print_r(new RunkitSubClass()); | ||
|
||
$obj = new StdSubClass(); | ||
runkit_default_property_add('StdSubClass', 'str', "test"); | ||
runkit_default_property_remove('StdSubClass', 'str'); | ||
print_r($obj); | ||
$obj = NULL; | ||
?> | ||
--EXPECTF-- | ||
Warning: runkit_default_property_remove(): runkitclass::publicproperty does not exist in %s on line %d | ||
runkitsubclass Object | ||
( | ||
[publicProperty] => 1 | ||
) | ||
stdsubclass Object | ||
( | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--TEST-- | ||
runkit_default_property_remove() remove properties with inheritance | ||
--SKIPIF-- | ||
<?php if(!extension_loaded("runkit") || !RUNKIT_FEATURE_MANIPULATION) print "skip"; | ||
if(array_shift(explode(".", PHP_VERSION)) < 5) print "skip"; | ||
?> | ||
--INI-- | ||
error_reporting=E_ALL | ||
display_errors=On | ||
--FILE-- | ||
<?php | ||
class RunkitClass { | ||
public $publicProperty = 1; | ||
private $privateProperty = "a"; | ||
protected $protectedProperty = "b"; | ||
private static $staticProperty = "s"; | ||
public $removedProperty = "r"; | ||
} | ||
|
||
class RunkitSubClass extends RunkitClass { | ||
public $publicProperty = 2; | ||
private $privateProperty = "aa"; | ||
protected $protectedProperty = "bb"; | ||
protected $staticProperty = "ss"; | ||
} | ||
class RunkitSubSubClass extends RunkitSubClass { | ||
protected $protectedProperty = "cc"; | ||
} | ||
|
||
ini_set('display_errors', 1); | ||
ini_set('error_reporting', E_ALL); | ||
|
||
$className = 'RunkitClass'; | ||
$obj = new RunkitSubSubClass(); | ||
|
||
runkit_default_property_remove($className, 'publicProperty'); | ||
runkit_default_property_remove($className, 'privateProperty'); | ||
runkit_default_property_remove($className, 'protectedProperty'); | ||
runkit_default_property_remove('RunkitSubClass', 'removedProperty'); | ||
runkit_default_property_remove($className, 'removedProperty'); | ||
print_r(new RunkitClass()); | ||
print_r(new RunkitSubClass()); | ||
print_r(new $obj); | ||
?> | ||
--EXPECTF-- | ||
Warning: runkit_default_property_remove(): RunkitSubClass::removedProperty does not exist in %s on line %d | ||
RunkitClass Object | ||
( | ||
) | ||
RunkitSubClass Object | ||
( | ||
[publicProperty] => 2 | ||
[privateProperty%sprivate] => aa | ||
[protectedProperty:protected] => bb | ||
[staticProperty:protected] => ss | ||
) | ||
RunkitSubSubClass Object | ||
( | ||
[protectedProperty:protected] => cc | ||
[publicProperty] => 2 | ||
[privateProperty%sprivate] => aa | ||
[staticProperty:protected] => ss | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.