mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
fix: properties and methods documented
This commit is contained in:
@ -18,3 +18,59 @@ it('gets property values', function () {
|
||||
|
||||
expect($value)->toBe('bar');
|
||||
});
|
||||
|
||||
class Asd
|
||||
{
|
||||
protected $foo = 'bar';
|
||||
|
||||
public function getFoo()
|
||||
{
|
||||
return $this->foo;
|
||||
}
|
||||
}
|
||||
|
||||
trait Zxc
|
||||
{
|
||||
protected $baz = 'qux';
|
||||
|
||||
public function getBaz()
|
||||
{
|
||||
return $this->baz;
|
||||
}
|
||||
}
|
||||
|
||||
class Qwe extends Asd
|
||||
{
|
||||
use Zxc;
|
||||
|
||||
protected $bar = 'baz';
|
||||
|
||||
public function getBar()
|
||||
{
|
||||
return $this->bar;
|
||||
}
|
||||
}
|
||||
|
||||
it('gets properties from classes', function () {
|
||||
$reflectionClass = new ReflectionClass(Qwe::class);
|
||||
|
||||
$properties = Reflection::getPropertiesFromReflectionClass($reflectionClass);
|
||||
|
||||
$properties = array_map(fn ($property) => $property->getName(), $properties);
|
||||
|
||||
expect($properties)->toBe([
|
||||
'bar',
|
||||
]);
|
||||
});
|
||||
|
||||
it('gets methods from classes', function () {
|
||||
$reflectionClass = new ReflectionClass(Qwe::class);
|
||||
|
||||
$methods = Reflection::getMethodsFromReflectionClass($reflectionClass);
|
||||
|
||||
$methods = array_map(fn ($method) => $method->getName(), $methods);
|
||||
|
||||
expect($methods)->toBe([
|
||||
'getBar',
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user