FAQ
helly Fri Apr 8 09:34:31 2005 EDT

Added files:
/php-src/tests/classes property_exists.phpt
Log:
- Add new test


http://cvs.php.net/co.php/php-src/tests/classes/property_exists.phpt?r=1.1&p=1
Index: php-src/tests/classes/property_exists.phpt
+++ php-src/tests/classes/property_exists.phpt
--TEST--
ZE2 property_exists()
--FILE--
<?php

class A
{
public $a = 1;
protected $b = 2;
private $c = 3;

function __toString()
{
return 'obj(' . get_class($this) . ')';
}

static function test($oc, $props)
{
echo '===' . __CLASS__ . "===\n";
foreach($props as $p2) {
echo $oc, '::$' , $p2, "\n";
var_dump(property_exists($oc, $p2));
}
}
}

class B extends A
{
private $c = 4;

static function test($oc, $props)
{
echo '===' . __CLASS__ . "===\n";
foreach($props as $p2) {
echo $oc, '::$' , $p2, "\n";
var_dump(property_exists($oc, $p2));
}
}
}

class C extends B
{
private $d = 5;

static function test($oc, $props)
{
echo '===' . __CLASS__ . "===\n";
foreach($props as $p2) {
echo $oc, '::$' , $p2, "\n";
var_dump(property_exists($oc, $p2));
}
}
}

$oA = new A;
$oA->e = 6;

$oC = new C;

$pc = array($oA, 'A', 'B', 'C', $oC);
$pr = array('a', 'b', 'c', 'd', 'e');

foreach($pc as $p1) {
if (is_object($p1)) {
$p1->test($p1, $pr);
} else {
$r = new ReflectionMethod($p1, 'test');
$r->invoke(NULL, $p1, $pr);
}
echo "===GLOBAL===\n";
foreach($pr as $p2) {
echo $p1, '::$' , $p2, "\n";
var_dump(property_exists($p1, $p2));
}
}

?>
===DONE===
<?php exit(0); ?>
--EXPECT--
===A===
obj(A)::$a
bool(true)
obj(A)::$b
bool(true)
obj(A)::$c
bool(true)
obj(A)::$d
bool(false)
obj(A)::$e
bool(true)
===GLOBAL===
obj(A)::$a
bool(true)
obj(A)::$b
bool(false)
obj(A)::$c
bool(false)
obj(A)::$d
bool(false)
obj(A)::$e
bool(true)
===A===
A::$a
bool(true)
A::$b
bool(true)
A::$c
bool(true)
A::$d
bool(false)
A::$e
bool(false)
===GLOBAL===
A::$a
bool(true)
A::$b
bool(false)
A::$c
bool(false)
A::$d
bool(false)
A::$e
bool(false)
===B===
B::$a
bool(true)
B::$b
bool(true)
B::$c
bool(true)
B::$d
bool(false)
B::$e
bool(false)
===GLOBAL===
B::$a
bool(true)
B::$b
bool(false)
B::$c
bool(false)
B::$d
bool(false)
B::$e
bool(false)
===C===
C::$a
bool(true)
C::$b
bool(true)
C::$c
bool(false)
C::$d
bool(true)
C::$e
bool(false)
===GLOBAL===
C::$a
bool(true)
C::$b
bool(false)
C::$c
bool(false)
C::$d
bool(false)
C::$e
bool(false)
===C===
obj(C)::$a
bool(true)
obj(C)::$b
bool(true)
obj(C)::$c
bool(false)
obj(C)::$d
bool(true)
obj(C)::$e
bool(false)
===GLOBAL===
obj(C)::$a
bool(true)
obj(C)::$b
bool(false)
obj(C)::$c
bool(false)
obj(C)::$d
bool(false)
obj(C)::$e
bool(false)
===DONE===

Search Discussions

  • Marcus Boerger at Apr 15, 2005 at 6:53 pm
    helly Fri Apr 15 14:53:42 2005 EDT

    Modified files:
    /php-src/tests/classes property_exists.phpt
    Log:
    - Fix even though we already know that the function will be renamed

    http://cvs.php.net/diff.php/php-src/tests/classes/property_exists.phpt?r1=1.1&r2=1.2&ty=u
    Index: php-src/tests/classes/property_exists.phpt
    diff -u php-src/tests/classes/property_exists.phpt:1.1 php-src/tests/classes/property_exists.phpt:1.2
    --- php-src/tests/classes/property_exists.phpt:1.1 Fri Apr 8 09:34:30 2005
    +++ php-src/tests/classes/property_exists.phpt Fri Apr 15 14:53:42 2005
    @@ -9,6 +9,8 @@
    protected $b = 2;
    private $c = 3;

    + public $empty;
    +
    function __toString()
    {
    return 'obj(' . get_class($this) . ')';
    @@ -74,10 +76,16 @@
    }
    }

    +echo "===PROBLEMS===\n";
    +var_dump(property_exists(NULL, 'empty'));
    +var_dump(property_exists(25,'empty'));
    +var_dump(property_exists('',''));
    +var_dump(property_exists('A',''));
    +var_dump(property_exists('A','empty'));
    ?>
    ===DONE===
    <?php exit(0); ?>
    ---EXPECT--
    +--EXPECTF--
    ===A===
    obj(A)::$a
    bool(true)
    @@ -188,4 +196,14 @@
    bool(false)
    obj(C)::$e
    bool(false)
    +===PROBLEMS===
    +
    +Warning: First parameter must either be an object or the name of an existing class in %sproperty_exists.php on line %d
    +NULL
    +
    +Warning: First parameter must either be an object or the name of an existing class in %sproperty_exists.php on line %d
    +NULL
    +bool(false)
    +bool(false)
    +bool(true)
    ===DONE===
  • Marcus Boerger at Apr 17, 2005 at 8:33 pm
    helly Sun Apr 17 16:33:21 2005 EDT

    Modified files:
    /php-src/tests/classes property_exists.phpt
    Log:
    - Add more tests

    http://cvs.php.net/diff.php/php-src/tests/classes/property_exists.phpt?r1=1.2&r2=1.3&ty=u
    Index: php-src/tests/classes/property_exists.phpt
    diff -u php-src/tests/classes/property_exists.phpt:1.2 php-src/tests/classes/property_exists.phpt:1.3
    --- php-src/tests/classes/property_exists.phpt:1.2 Fri Apr 15 14:53:42 2005
    +++ php-src/tests/classes/property_exists.phpt Sun Apr 17 16:33:20 2005
    @@ -10,6 +10,7 @@
    private $c = 3;

    public $empty;
    + public $init = 1;

    function __toString()
    {
    @@ -81,7 +82,13 @@
    var_dump(property_exists(25,'empty'));
    var_dump(property_exists('',''));
    var_dump(property_exists('A',''));
    +var_dump(property_exists('A','123'));
    +var_dump(property_exists('A','init'));
    var_dump(property_exists('A','empty'));
    +var_dump(property_exists(new A, ''));
    +var_dump(property_exists(new A, '123'));
    +var_dump(property_exists(new A, 'init'));
    +var_dump(property_exists(new A, 'empty'));
    ?>
    ===DONE===
    <?php exit(0); ?>
    @@ -205,5 +212,11 @@
    NULL
    bool(false)
    bool(false)
    +bool(false)
    +bool(true)
    +bool(true)
    +bool(false)
    +bool(false)
    +bool(true)
    bool(true)
    ===DONE===

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-cvs @
categoriesphp
postedApr 8, '05 at 1:34p
activeApr 17, '05 at 8:33p
posts3
users1
websitephp.net

1 user in discussion

Marcus Boerger: 3 posts

People

Translate

site design / logo © 2019 Grokbase