12
12
13
13
use Longman \TelegramBot \Exception \TelegramException ;
14
14
use Longman \TelegramBot \Entities \ServerResponse ;
15
- use Longman \TelegramBot \Entities \User ;
16
15
17
16
class Request
18
17
{
@@ -74,16 +73,16 @@ public static function send($action, array $data = null)
74
73
}
75
74
76
75
if (defined ('PHPUNIT_TESTSUITE ' )) {
77
- $ fake_response ['ok ' ] = 1 ;
78
-
79
- //some fake data just to let iniatilize the class
80
- $ data ['message_id ' ] = ' 123 ' ;
81
- $ data ['date ' ] = '123 ' ;
82
-
83
- $ data ['from ' ] = array ( 'id ' => 123 , ' first_name ' => ' botname ' , ' username ' => ' namebot ' );
84
-
85
- $ data [ ' chat ' ] = array ( ' id ' => $ data[ ' chat_id ' ] ) ;
86
- $ fake_response [ ' result ' ] = $ data ;
76
+ $ fake_response ['ok ' ] = 1 ; // :)
77
+
78
+ //some fake data just to let iniatilize the class method SendMessage
79
+ if ( isset ( $ data ['chat_id ' ])) {
80
+ $ data ['message_id ' ] = '123 ' ;
81
+ $ data [ ' date ' ] = ' 123 ' ;
82
+ $ data ['chat ' ] = array ('id ' => $ data [ ' chat_id ' ] );
83
+ $ data [ ' from ' ] = array ( ' id ' => 123 , ' first_name ' => ' botname ' , ' username ' => ' namebot ' );
84
+ $ fake_response [ ' result ' ] = $ data ;
85
+ }
87
86
88
87
return new ServerResponse ($ fake_response , self ::$ telegram ->getBotName ());
89
88
}
@@ -112,6 +111,7 @@ public static function send($action, array $data = null)
112
111
$ response ['description ' ] = 'Empty server response ' ;
113
112
}
114
113
114
+ //return json_decode($result, true);
115
115
return new ServerResponse (json_decode ($ result , true ), self ::$ telegram ->getBotName ());
116
116
}
117
117
@@ -135,6 +135,7 @@ public static function getMe()
135
135
136
136
public static function setWebhook ($ url )
137
137
{
138
+
138
139
$ result = self ::send ('setWebhook ' , array ('url ' => $ url ));
139
140
return $ result ;
140
141
}
0 commit comments