1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 05:58:58 +01:00

Improve tests

This commit is contained in:
Daniil Gentili 2023-08-05 23:09:40 +02:00
parent 5255cf3460
commit 9ba8af106a
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
7 changed files with 13 additions and 9 deletions

View File

@ -113,8 +113,9 @@
"@psalm"
],
"check": [
"@test",
"@cs",
"@test"
"@psalm"
],
"test-php7": "tests/test-conversion.sh 70",
"test-php56": "tests/test-conversion.sh 5",
@ -123,7 +124,7 @@
"psalm": "psalm.phar --no-cache",
"docs": "php tools/build_docs.php",
"docs-fix": "tools/fix_docs.sh",
"test": "@php -dzend.assertions=1 -dassert.exception=1 ./vendor/bin/phpunit --coverage-text --config tests/phpunit.xml",
"test": "@php -dzend.assertions=1 -dassert.exception=1 ./vendor/bin/phpunit --coverage-text",
"bin": "echo 'bin not installed'",
"post-install-cmd": ["@composer bin all install --ansi"],
"post-update-cmd": ["@composer bin all update --ansi"]

2
docs

@ -1 +1 @@
Subproject commit 11ac3836aef519d0bcfe34ba7240d60f7b51945f
Subproject commit 07535f4de8d8ee6b845ef36ff572bbc2ff1d6fe5

View File

@ -339,7 +339,7 @@ final class Connection
$arguments['peer'] = 'me';
}
}
if (\is_array($arguments['media'])) {
if (\is_array($arguments['media']) && isset($arguments['media']['_'])) {
if ($arguments['media']['_'] === 'inputMediaPhotoExternal') {
$arguments['media']['_'] = 'inputMediaUploadedPhoto';
$arguments['media']['file'] = new RemoteUrl($arguments['media']['url']);

View File

@ -78,7 +78,7 @@ class EntitiesTest extends MadelineTestCase
public function provideEntities(): array
{
$this->setUpBeforeClass();
$mention = self::$MadelineProto->getPwrChat(\getenv('TEST_USERNAME'));
$mention = self::$MadelineProto->getPwrChat(\getenv('TEST_USERNAME'), false);
return [
[
'html',

View File

@ -22,7 +22,7 @@ class FileIdTest extends MadelineTestCase
*/
public static function stripFileReference(string $fileId): string
{
return FileId::fromBotAPI($fileId)->setFileReference('');
return (string) FileId::fromBotAPI($fileId)->setFileReference('');
}
/**
* Strip access hash (and possibly ID) from file ID.
@ -31,7 +31,7 @@ class FileIdTest extends MadelineTestCase
*/
public static function stripForChat(string $fileId): string
{
return FileId::fromBotAPI($fileId)->setAccessHash(0);
return (string) FileId::fromBotAPI($fileId)->setAccessHash(0);
}
/**

View File

@ -61,6 +61,7 @@ k
rm -rf madeline.phar testing.madeline*
composer update
composer test
#vendor/bin/phpunit tests/danog/MadelineProto/EntitiesTest.php
COMPOSER_TAG="$TAG"

View File

@ -282,7 +282,7 @@ $MadelineProto->loop(function () use ($MadelineProto) {
$media['document'] = ['_' => 'inputMediaUploadedDocument', 'file' => __DIR__.'/60', 'mime_type' => 'magic/magic', 'attributes' => [['_' => 'documentAttributeFilename', 'file_name' => 'magic.magic']]];
// Document by URL
$media['document'] = ['_' => 'inputMediaUploadedDocument', 'url' => 'https://github.com/danog/MadelineProto/raw/v8/tests/60'];
$media['document'] = ['_' => 'inputMediaDocumentExternal', 'url' => 'https://github.com/danog/MadelineProto/raw/v8/tests/60'];
$message = 'yay '.PHP_VERSION_ID;
$mention = yield $MadelineProto->getInfo(getenv('TEST_USERNAME')); // Returns an array with all of the constructors that can be extracted from a username or an id
@ -307,7 +307,9 @@ $MadelineProto->loop(function () use ($MadelineProto) {
['_' => 'inputSingleMedia', 'media' => $inputMedia, 'message' => '['.$message.'](mention:'.$mention.')', 'parse_mode' => 'markdown'],
]]);
}
$fileOrig = read($inputMedia['file']);
$fileOrig = isset($inputMedia['file'])
? read($inputMedia['file'])
: $MadelineProto->fileGetContents($inputMedia['url']);
$MadelineProto->logger("Sending $type");
$dl = $MadelineProto->extractMessage(yield $MadelineProto->messages->sendMedia(['peer' => $peer, 'media' => $inputMedia, 'message' => '['.$message.'](mention:'.$mention.')', 'parse_mode' => 'markdown']));