Documentation

TestHelpers
in package

Tags
author

Avtandil Kikabidze akalongman@gmail.com

copyright

Avtandil Kikabidze akalongman@gmail.com

license

http://opensource.org/licenses/mit-license.php The MIT License (MIT)

link
https://github.com/php-telegram-bot/core

Table of Contents

$chat_template  : array<string|int, mixed>
Data template of a chat.
$user_template  : array<string|int, mixed>
Data template of a user.
emptyDb()  : mixed
Empty all tables for the passed database
getFakeChatObject()  : Chat
Return a fake chat object.
getFakeMessageObject()  : Message
Return a fake message object using the passed ids.
getFakeRecordedAudio()  : array<string|int, mixed>
Get fake recorded audio track
getFakeUpdateCommandObject()  : Update
Return a fake command object for the passed command text
getFakeUpdateObject()  : Update
Return a simple fake Update object
getFakeUserObject()  : User
Return a fake user object.
setObjectProperty()  : mixed
Set the value of a private/protected property of an object
setStaticProperty()  : mixed
Set the value of a private/protected static property of a class
startFakeConversation()  : array<string|int, mixed>
Start a fake conversation for the passed command and return the randomly generated ids.

Properties

$chat_template

Data template of a chat.

protected static array<string|int, mixed> $chat_template = ['id' => 1, 'first_name' => 'first', 'last_name' => 'last', 'username' => 'name', 'type' => 'private', 'all_members_are_administrators' => false]

$user_template

Data template of a user.

protected static array<string|int, mixed> $user_template = ['id' => 1, 'first_name' => 'first', 'last_name' => 'last', 'username' => 'user']

Methods

emptyDb()

Empty all tables for the passed database

public static emptyDb(array<string|int, mixed> $credentials) : mixed
Parameters
$credentials : array<string|int, mixed>
Return values
mixed

getFakeChatObject()

Return a fake chat object.

public static getFakeChatObject([array<string|int, mixed> $data = [] ]) : Chat
Parameters
$data : array<string|int, mixed> = []

Pass custom data array if needed

Return values
Chat

getFakeMessageObject()

Return a fake message object using the passed ids.

public static getFakeMessageObject([array<string|int, mixed> $message_data = [] ][, array<string|int, mixed> $user_data = [] ][, array<string|int, mixed> $chat_data = [] ]) : Message
Parameters
$message_data : array<string|int, mixed> = []

Pass custom message data array if needed

$user_data : array<string|int, mixed> = []

Pass custom user data array if needed

$chat_data : array<string|int, mixed> = []

Pass custom chat data array if needed

Return values
Message

getFakeRecordedAudio()

Get fake recorded audio track

public static getFakeRecordedAudio() : array<string|int, mixed>
Return values
array<string|int, mixed>

getFakeUpdateCommandObject()

Return a fake command object for the passed command text

public static getFakeUpdateCommandObject(string $command_text) : Update
Parameters
$command_text : string
Return values
Update

getFakeUpdateObject()

Return a simple fake Update object

public static getFakeUpdateObject([array<string|int, mixed> $data = null ]) : Update
Parameters
$data : array<string|int, mixed> = null

Pass custom data array if needed

Return values
Update

getFakeUserObject()

Return a fake user object.

public static getFakeUserObject([array<string|int, mixed> $data = [] ]) : User
Parameters
$data : array<string|int, mixed> = []

Pass custom data array if needed

Return values
User

setObjectProperty()

Set the value of a private/protected property of an object

public static setObjectProperty(object $object, string $property, mixed $value) : mixed
Parameters
$object : object

Object that contains the property

$property : string

Name of the property who's value we want to set

$value : mixed

The value to set to the property

Return values
mixed

setStaticProperty()

Set the value of a private/protected static property of a class

public static setStaticProperty(string $class, string $property, mixed $value) : mixed
Parameters
$class : string

Class that contains the static property

$property : string

Name of the property who's value we want to set

$value : mixed

The value to set to the property

Return values
mixed

startFakeConversation()

Start a fake conversation for the passed command and return the randomly generated ids.

public static startFakeConversation() : array<string|int, mixed>
Return values
array<string|int, mixed>

Search results