setObjectProperty() 공개 정적인 메소드

Set the value of a private/protected property of an object
public static setObjectProperty ( object $object, string $property, mixed $value )
$object object Object that contains the property
$property string Name of the property who's value we want to set
$value mixed The value to set to the property
예제 #1
0
 public function setUp()
 {
     //Default command object
     $this->telegram = new Telegram('apikey', 'testbot');
     $this->command_stub = $this->getMockForAbstractClass($this->command_namespace, [$this->telegram]);
     //Create separate command object that contain a command config
     $this->telegram_with_config = new Telegram('apikey', 'testbot');
     $this->telegram_with_config->setCommandConfig('command_name', ['config_key' => 'config_value']);
     $this->command_stub_with_config = $this->getMockBuilder($this->command_namespace)->disableOriginalConstructor()->getMockForAbstractClass();
     //Set a name for the object property so that the constructor can set the config correctly
     TestHelpers::setObjectProperty($this->command_stub_with_config, 'name', 'command_name');
     $this->command_stub_with_config->__construct($this->telegram_with_config);
 }