generateGeneralFakeServerResponse() public static method

Generate general fake server response
public static generateGeneralFakeServerResponse ( array $data = [] ) : array
$data array Data to add to fake response
return array Fake response data
コード例 #1
0
 /**
  * @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...
 }