Longman\TelegramBot\Tests\Unit\TestHelpers::setStaticProperty PHP 메소드

setStaticProperty() 공개 정적인 메소드

Set the value of a private/protected static property of a class
public static setStaticProperty ( string $class, string $property, mixed $value )
$class string Class that contains the static property
$property string Name of the property who's value we want to set
$value mixed The value to set to the property
    public static function setStaticProperty($class, $property, $value)
    {
        $ref_property = new \ReflectionProperty($class, $property);
        $ref_property->setAccessible(true);
        $ref_property->setValue(null, $value);
    }

Usage Example

 /**
  * setUp
  */
 protected function setUp()
 {
     // Make sure no monolog instance is set before each test.
     TestHelpers::setStaticProperty('Longman\\TelegramBot\\TelegramLog', 'monolog', null);
 }