Fix tests
This commit is contained in:
parent
e0b293b9a1
commit
824b62cd10
@ -197,7 +197,7 @@ class API extends APIFactory
|
||||
Logger::log('Shutting down MadelineProto (normally or due to an exception, idk)');
|
||||
}
|
||||
$this->destructing = true;
|
||||
$this->wait($this->serialize());
|
||||
Tools::wait($this->serialize());
|
||||
}
|
||||
//restore_error_handler();
|
||||
}
|
||||
@ -285,7 +285,7 @@ class API extends APIFactory
|
||||
|
||||
public function serialize($filename = null)
|
||||
{
|
||||
return $this->callFork((function () use ($filename) {
|
||||
return Tools::callFork((function () use ($filename) {
|
||||
if ($filename === null) {
|
||||
$filename = $this->session;
|
||||
}
|
||||
|
@ -120,7 +120,6 @@ class APIFactory extends AsyncConstruct
|
||||
*/
|
||||
public $auth;
|
||||
|
||||
use Tools;
|
||||
public $namespace = '';
|
||||
public $API;
|
||||
public $lua = false;
|
||||
@ -138,17 +137,18 @@ class APIFactory extends AsyncConstruct
|
||||
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
$yielded = $this->call($this->__call_async($name, $arguments));
|
||||
$yielded = Tools::call($this->__call_async($name, $arguments));
|
||||
$async = $this->lua === false && (\is_array(\end($arguments)) && isset(\end($arguments)['async']) ? \end($arguments)['async'] : ($this->async && $name !== 'loop'));
|
||||
|
||||
if ($async) {
|
||||
return $yielded;
|
||||
}
|
||||
if (!$this->lua) {
|
||||
return $this->wait($yielded);
|
||||
return Tools::wait($yielded);
|
||||
}
|
||||
|
||||
try {
|
||||
$yielded = $this->wait($yielded);
|
||||
$yielded = Tools::wait($yielded);
|
||||
Lua::convert_objects($yielded);
|
||||
|
||||
return $yielded;
|
||||
@ -203,7 +203,7 @@ class APIFactory extends AsyncConstruct
|
||||
public function &__get($name)
|
||||
{
|
||||
if ($this->asyncAPIPromise) {
|
||||
$this->wait($this->asyncAPIPromise);
|
||||
Tools::wait($this->asyncAPIPromise);
|
||||
}
|
||||
if ($name === 'settings') {
|
||||
$this->API->flushSettings = true;
|
||||
@ -220,7 +220,7 @@ class APIFactory extends AsyncConstruct
|
||||
public function __set($name, $value)
|
||||
{
|
||||
if ($this->asyncAPIPromise) {
|
||||
$this->wait($this->asyncAPIPromise);
|
||||
Tools::wait($this->asyncAPIPromise);
|
||||
}
|
||||
if ($name === 'settings') {
|
||||
if ($this->API->asyncInitPromise) {
|
||||
@ -236,7 +236,7 @@ class APIFactory extends AsyncConstruct
|
||||
public function __isset($name)
|
||||
{
|
||||
if ($this->asyncAPIPromise) {
|
||||
$this->wait($this->asyncAPIPromise);
|
||||
Tools::wait($this->asyncAPIPromise);
|
||||
}
|
||||
|
||||
return isset($this->API->storage[$name]);
|
||||
@ -245,7 +245,7 @@ class APIFactory extends AsyncConstruct
|
||||
public function __unset($name)
|
||||
{
|
||||
if ($this->asyncAPIPromise) {
|
||||
$this->wait($this->asyncAPIPromise);
|
||||
Tools::wait($this->asyncAPIPromise);
|
||||
}
|
||||
unset($this->API->storage[$name]);
|
||||
}
|
||||
|
@ -29,13 +29,12 @@ use danog\MadelineProto\Tools;
|
||||
*/
|
||||
class AsyncConstruct
|
||||
{
|
||||
use Tools;
|
||||
public $asyncInitPromise;
|
||||
|
||||
public function init()
|
||||
{
|
||||
if ($this->asyncInitPromise) {
|
||||
$this->wait($this->asyncInitPromise);
|
||||
Tools::wait($this->asyncInitPromise);
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,7 +47,7 @@ class AsyncConstruct
|
||||
|
||||
public function setInitPromise($promise)
|
||||
{
|
||||
$this->asyncInitPromise = $this->callFork($promise);
|
||||
$this->asyncInitPromise = Tools::callFork($promise);
|
||||
$this->asyncInitPromise->onResolve(function ($error, $result) {
|
||||
if ($error) {
|
||||
throw $error;
|
||||
|
@ -80,7 +80,7 @@ trait Files
|
||||
$mime = $this->get_mime_from_file($file);
|
||||
|
||||
try {
|
||||
return yield $this->upload_from_stream_async($stream, $size, $stream, $mime, $cb, $encrypted);
|
||||
return yield $this->upload_from_stream_async($stream, $size, $mime, $file_name, $cb, $encrypted);
|
||||
} finally {
|
||||
yield $stream->close();
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ echo 'Loading MadelineProto...'.PHP_EOL;
|
||||
$MadelineProto = new \danog\MadelineProto\API(\getcwd().'/testing.madeline', $settings);
|
||||
$MadelineProto->fileGetContents('https://google.com');
|
||||
$MadelineProto->start();
|
||||
$MadelineProto->async(false);
|
||||
|
||||
try {
|
||||
$MadelineProto->get_self();
|
||||
@ -59,14 +60,6 @@ try {
|
||||
}
|
||||
}
|
||||
|
||||
$inputMediaUploadedPhoto1 = ['_' => 'inputMediaUploadedPhoto','file' => '1.jpg'];
|
||||
$inputMediaUploadedPhoto2 = ['_' => 'inputMediaUploadedPhoto','file' => '2.jpg'];
|
||||
$inputMediaUploadedPhoto3 = ['_' => 'inputMediaUploadedPhoto','file' => '3.jpg'];
|
||||
$inputSingleMedia1 = ['_' => 'inputSingleMedia', 'media' => $inputMediaUploadedPhoto1, 'message' => 'str'];
|
||||
$inputSingleMedia2 = ['_' => 'inputSingleMedia', 'media' => $inputMediaUploadedPhoto2, 'message' => 'str'];
|
||||
$inputSingleMedia3 = ['_' => 'inputSingleMedia', 'media' => $inputMediaUploadedPhoto3, 'message' => 'str'];
|
||||
$Updates = $this->messages->sendMultiMedia(['peer' => 'danogentili','multi_media' => [$inputSingleMedia3, $inputSingleMedia2,$inputSingleMedia1]]);
|
||||
|
||||
//var_dump(count($MadelineProto->get_pwr_chat('@madelineproto')['participants']));
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user