wiki.techinc.nl/tests/phpunit/data/helpers/WellProtectedClass.php
Brad Jorsch 1e21a4bcab Fix TestingAccessWrapper private property access and parent classes
PHP's reflection mechanism is weird: reflecting on a private method will
find it even if it's defined in a parent class, while reflecting on a
private property just fails.

It would likely be more useful if TestingAccessWrapper could find
private properties defined in parent classes, so let's make that happen.

Change-Id: I9cfdde2694136d0e4559cc419a528762ea14ae4b
2015-09-09 11:44:03 -04:00

48 lines
931 B
PHP

<?php
class WellProtectedParentClass {
private $privateParentProperty;
public function __construct() {
$this->privateParentProperty = 9000;
}
private function incrementPrivateParentPropertyValue() {
$this->privateParentProperty++;
}
public function getPrivateParentProperty() {
return $this->privateParentProperty;
}
}
class WellProtectedClass extends WellProtectedParentClass {
protected $property;
private $privateProperty;
public function __construct() {
parent::__construct();
$this->property = 1;
$this->privateProperty = 42;
}
protected function incrementPropertyValue() {
$this->property++;
}
private function incrementPrivatePropertyValue() {
$this->privateProperty++;
}
public function getProperty() {
return $this->property;
}
public function getPrivateProperty() {
return $this->privateProperty;
}
protected function whatSecondArg( $a, $b = false ) {
return $b;
}
}