function testSerialize() { $object = new Message(); $object->setMessageId(12); $chat = new Chat(); $chat->setFirstName('Masoud'); $object->setChat($chat); $serialized = DataTransformer::serialize($object); $this->assertEquals(['message_id' => 12, 'chat' => ['first_name' => 'Masoud']], $serialized); $object = new UserProfilePhotos(); $object->setTotalCount(5); $object->setPhotos([(new PhotoSize())->setFileId(10), (new PhotoSize())->setFileId(20)]); $this->assertEquals(['total_count' => 5, 'photos' => [['file_id' => 10], ['file_id' => 20]]], DataTransformer::serialize($object)); $object = new Fixture(); $object->setExpiresAt(new DateTime()); $serialized = DataTransformer::serialize($object); $this->assertEquals(date('c'), $serialized['expires_at']); }
/** * @Api * Send photo * * Use this method to send photos. On success, the sent Message is returned. * * @see https://core.telegram.org/bots/api#sendphoto * * @param int|string $chatId Unique identifier for the target chat or username of the target * channel (in the format @channelusername) * @param InputFile|string $photo Photo to send. You can either pass a file_id as String to resend a * photo that is already on the Telegram servers, or upload a new * photo using multipart/form-data. * @param string $caption Photo caption (may also be used when resending photos by file_id). * @param int $replyToMessageId If the message is a reply, ID of the original message * @param ReplyInterface|null $replyMarkup Additional interface options. A JSON-serialized object for a * custom reply keyboard, instructions to hide keyboard or to force a * reply from the user. * @return Message */ public function sendPhoto($chatId, $photo, $caption = null, $replyToMessageId = null, ReplyInterface $replyMarkup = null) { return $this->uploadFile('sendPhoto', ['chat_id' => $chatId, 'photo' => $photo, 'caption' => $caption, 'reply_to_message_id' => $replyToMessageId, 'reply_markup' => DataTransformer::serialize($replyMarkup)]); }