mirror of
https://github.com/danog/MadelineProto.git
synced 2025-01-22 16:31:11 +01:00
Add more tests
This commit is contained in:
parent
3195056c2c
commit
ee14d6cf27
92
tests/danog/MadelineProto/EntitiesTest.php
Normal file
92
tests/danog/MadelineProto/EntitiesTest.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace danog\MadelineProto\Test;
|
||||
|
||||
use CURLFile;
|
||||
use danog\Decoder\FileId;
|
||||
use danog\MadelineProto\API;
|
||||
use danog\MadelineProto\Logger;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class EntitiesTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* MadelineProto instance.
|
||||
*
|
||||
* @var API
|
||||
*/
|
||||
protected static $MadelineProto;
|
||||
|
||||
/**
|
||||
* Setup MadelineProto instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
self::$MadelineProto = new API(
|
||||
'testing.madeline',
|
||||
[
|
||||
'app_info' => [
|
||||
'api_id' => \getenv('API_ID'),
|
||||
'api_hash' => \getenv('API_HASH'),
|
||||
],
|
||||
'logger' => [
|
||||
'logger' => Logger::FILE_LOGGER,
|
||||
'logger_param' => __DIR__.'/../../MadelineProto.log',
|
||||
'logger_level' => Logger::ULTRA_VERBOSE
|
||||
]
|
||||
]
|
||||
);
|
||||
self::$MadelineProto->botLogin(\getenv('BOT_TOKEN'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Teardown.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function tearDownAfterClass(): void
|
||||
{
|
||||
self::$MadelineProto = null;
|
||||
}
|
||||
/**
|
||||
* @dataProvider provideEntities
|
||||
*/
|
||||
public function testEntities(string $mode, string $html, string $bare, array $entities)
|
||||
{
|
||||
$result = self::$MadelineProto->messages->sendMessage(peer: getenv('DEST'), message: $html, parse_mode: $mode);
|
||||
$result = self::$MadelineProto->MTProtoToBotAPI($result);
|
||||
$this->assertEquals($bare, $result['text']);
|
||||
$this->assertEquals($entities, $result['entities']);
|
||||
}
|
||||
public function provideEntities(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'html',
|
||||
'<b>test</b>',
|
||||
'test',
|
||||
[
|
||||
[
|
||||
'offset' => 0,
|
||||
'length' => 4,
|
||||
'type' => 'bold'
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
'html',
|
||||
'🇺🇦<b>🇺🇦</b>',
|
||||
'🇺🇦🇺🇦',
|
||||
[
|
||||
[
|
||||
'offset' => 4,
|
||||
'length' => 4,
|
||||
'type' => 'bold'
|
||||
]
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
@ -125,26 +125,23 @@ reset()
|
||||
sed 's|phar.madelineproto.xyz|empty.madelineproto.xyz|g;s|MADELINE_RELEASE_URL|disable|g' -i madeline.php
|
||||
cp madeline.php madelineBackup.php
|
||||
}
|
||||
|
||||
k
|
||||
rm -f madeline.phar testing.madeline*
|
||||
|
||||
tail -F MadelineProto.log &
|
||||
export ACTIONS_FORCE_PREVIOUS=1
|
||||
|
||||
echo "Testing with previous version..."
|
||||
export ACTIONS_FORCE_PREVIOUS=1
|
||||
cp tools/phar.php madeline.php
|
||||
runTest
|
||||
db mysql
|
||||
k
|
||||
|
||||
echo "Testing with new version (upgrade)..."
|
||||
php tools/makephar.php $madelinePath/../phar "madeline$php$branch.phar" "$COMMIT-$php"
|
||||
cp "madeline$php$branch.phar" "madeline-$COMMIT-$php.phar"
|
||||
echo -n "$COMMIT-$php" > "madeline-$php.phar.version"
|
||||
export ACTIONS_PHAR=1
|
||||
reset
|
||||
|
||||
runTest
|
||||
db mysql
|
||||
k
|
||||
|
||||
reset
|
||||
runTestSimple
|
||||
cycledb
|
||||
|
@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="../vendor/autoload.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="true">
|
||||
<coverage>
|
||||
<include>
|
||||
<directory suffix=".php">../src</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
<testsuites>
|
||||
<testsuite name="Main">
|
||||
<directory>../tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
Loading…
x
Reference in New Issue
Block a user