Longman\TelegramBot\Commands\Command::__construct PHP Method

__construct() public method

Constructor
public __construct ( Telegram $telegram, Update $update = null )
$telegram Longman\TelegramBot\Telegram
$update Longman\TelegramBot\Entities\Update
    public function __construct(Telegram $telegram, Update $update = null)
    {
        $this->telegram = $telegram;
        $this->setUpdate($update);
        $this->config = $telegram->getCommandConfig($this->name);
    }

Usage Example

Ejemplo n.º 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);
 }