当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::generateGeneralFakeServerResponse方法代码示例

本文整理汇总了PHP中Longman\TelegramBot\Request::generateGeneralFakeServerResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::generateGeneralFakeServerResponse方法的具体用法?PHP Request::generateGeneralFakeServerResponse怎么用?PHP Request::generateGeneralFakeServerResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Longman\TelegramBot\Request的用法示例。


在下文中一共展示了Request::generateGeneralFakeServerResponse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSetGeneralTestFakeResponse

 /**
  * @test
  */
 public function testSetGeneralTestFakeResponse()
 {
     //setWebhook ok
     $fake_response = Request::generateGeneralFakeServerResponse();
     $this->server = new ServerResponse($fake_response, 'testbot');
     $this->assertTrue($this->server->isOk());
     $this->assertTrue($this->server->getResult());
     $this->assertNull($this->server->getErrorCode());
     $this->assertEquals('', $this->server->getDescription());
     //sendMessage ok
     $fake_response = Request::generateGeneralFakeServerResponse(['chat_id' => 123456789, 'text' => 'hello']);
     $this->server = new ServerResponse($fake_response, 'testbot');
     $this->assertTrue($this->server->isOk());
     $this->assertInstanceOf('\\Longman\\TelegramBot\\Entities\\Message', $this->server->getResult());
     $this->assertNull($this->server->getErrorCode());
     $this->assertNull($this->server->getDescription());
     //Message
     $this->assertEquals('1234', $this->server->getResult()->getMessageId());
     $this->assertEquals('1441378360', $this->server->getResult()->getDate());
     $this->assertEquals('hello', $this->server->getResult()->getText());
     //Message //User
     $this->assertEquals('123456789', $this->server->getResult()->getFrom()->getId());
     $this->assertEquals('botname', $this->server->getResult()->getFrom()->getFirstName());
     $this->assertEquals('namebot', $this->server->getResult()->getFrom()->getUserName());
     //Message //Chat
     $this->assertEquals('123456789', $this->server->getResult()->getChat()->getId());
     $this->assertEquals('', $this->server->getResult()->getChat()->getFirstName());
     $this->assertEquals('', $this->server->getResult()->getChat()->getUserName());
     //... they are not finished...
 }
开发者ID:gentlejo,项目名称:php-telegram-bot,代码行数:33,代码来源:ServerResponseTest.php


注:本文中的Longman\TelegramBot\Request::generateGeneralFakeServerResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。