1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-26 19:24:42 +01:00

Further improve tests

This commit is contained in:
Daniil Gentili 2023-11-30 17:58:48 +01:00
parent 01effbd42f
commit 4148d58c42
5 changed files with 42 additions and 62 deletions

View File

@ -57,3 +57,4 @@ steps:
- apk add bash - apk add bash
- tests/test.sh - tests/test.sh
- php tests/handshake.php - php tests/handshake.php
- composer test-light

View File

@ -115,15 +115,19 @@
"@psalm" "@psalm"
], ],
"test": [ "test": [
"paratest", "@paratest",
"phpunit" "@phpunit"
],
"test-light": [
"@paratest-light"
], ],
"cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php -d pcre.jit=0 vendor/bin/php-cs-fixer fix -v", "cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php -d pcre.jit=0 vendor/bin/php-cs-fixer fix -v",
"psalm": "psalm --no-cache --threads=10", "psalm": "psalm --no-cache --threads=10",
"docs": "php tools/build_docs.php", "docs": "php tools/build_docs.php",
"docs-fix": "tools/fix_docs.sh", "docs-fix": "tools/fix_docs.sh",
"phpunit": "@php -dzend.assertions=1 ./vendor/bin/phpunit --coverage-text -c phpunit-noparallel.xml", "phpunit": "@php -dzend.assertions=1 ./vendor/bin/phpunit -c phpunit-noparallel.xml",
"paratest": "@php -dzend.assertions=1 ./vendor/bin/paratest --coverage-text", "paratest": "@php -dzend.assertions=1 ./vendor/bin/paratest",
"paratest-light": "@php -dzend.assertions=1 ./vendor/bin/paratest -c phpunit-light.xml",
"bin": "echo 'bin not installed'", "bin": "echo 'bin not installed'",
"post-install-cmd": ["@composer bin all install --ansi"], "post-install-cmd": ["@composer bin all install --ansi"],
"post-update-cmd": ["@composer bin all update --ansi"] "post-update-cmd": ["@composer bin all update --ansi"]

25
phpunit-light.xml Normal file
View File

@ -0,0 +1,25 @@
<?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"
>
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Main">
<directory>tests</directory>
<exclude>tests/danog/MadelineProto/DataCenterTest.php</exclude>
<exclude>tests/danog/MadelineProto/FileIdTest.php</exclude>
</testsuite>
</testsuites>
</phpunit>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="dev-master@baa6d5dd7801e24d99d2f57995b58b79e8ad304a"> <files psalm-version="dev-master@efdf425983038f7ef6194df43f3dc18cde13d770">
<file src="src/API.php"> <file src="src/API.php">
<ArgumentTypeCoercion> <ArgumentTypeCoercion>
<code>$settings</code> <code>$settings</code>
@ -1067,6 +1067,7 @@
<code><![CDATA[$this->colors]]></code> <code><![CDATA[$this->colors]]></code>
<code><![CDATA[$this->colors]]></code> <code><![CDATA[$this->colors]]></code>
<code><![CDATA[$this->colors]]></code> <code><![CDATA[$this->colors]]></code>
<code><![CDATA[$this->colors]]></code>
</UninitializedProperty> </UninitializedProperty>
</file> </file>
<file src="src/Loop/Connection/CheckLoop.php"> <file src="src/Loop/Connection/CheckLoop.php">
@ -1838,58 +1839,6 @@
<code>$wrapper</code> <code>$wrapper</code>
</PropertyNotSetInConstructor> </PropertyNotSetInConstructor>
</file> </file>
<file src="src/Ogg.php">
<InaccessibleProperty>
<code><![CDATA[$this->comments]]></code>
<code><![CDATA[$this->vendorString]]></code>
</InaccessibleProperty>
<PossiblyInvalidArgument>
<code>$offset</code>
<code>$offset</code>
<code>$offset</code>
<code>$offset</code>
<code>$offset</code>
<code>$offset</code>
<code>$size</code>
</PossiblyInvalidArgument>
<PossiblyInvalidPropertyAssignmentValue>
<code><![CDATA[$this->currentDuration += $frameDuration]]></code>
<code><![CDATA[$this->currentDuration += $totalDuration]]></code>
</PossiblyInvalidPropertyAssignmentValue>
<PossiblyNullArgument>
<code><![CDATA[($this->stream)($headers['number_page_segments'])]]></code>
<code><![CDATA[($this->stream)(23)]]></code>
</PossiblyNullArgument>
<PossiblyUndefinedVariable>
<code>$cancel</code>
</PossiblyUndefinedVariable>
<PropertyNotSetInConstructor>
<code>$comments</code>
<code>$streamCount</code>
<code>$vendorString</code>
</PropertyNotSetInConstructor>
<RedundantCondition>
<code>$state === self::STATE_READ_COMMENT</code>
</RedundantCondition>
<ReferenceConstraintViolation>
<code>$offset</code>
<code>$offset</code>
<code>$offset</code>
<code>$offset</code>
</ReferenceConstraintViolation>
<TooFewArguments>
<code><![CDATA[($this->stream)($headers['number_page_segments'])]]></code>
<code><![CDATA[($this->stream)($sizeAccumulated)]]></code>
<code><![CDATA[($this->stream)(23)]]></code>
<code><![CDATA[($this->stream)(4)]]></code>
</TooFewArguments>
<UndefinedClass>
<code>?FFI</code>
<code>FFI</code>
<code>FFI</code>
<code>int|CData $err</code>
</UndefinedClass>
</file>
<file src="src/PTSException.php"> <file src="src/PTSException.php">
<MissingParamType> <MissingParamType>
<code>$file</code> <code>$file</code>
@ -2375,6 +2324,7 @@
<file src="src/Tools.php"> <file src="src/Tools.php">
<ArgumentTypeCoercion> <ArgumentTypeCoercion>
<code><![CDATA[static fn (ClassLike $c): bool => $c->name !== null]]></code> <code><![CDATA[static fn (ClassLike $c): bool => $c->name !== null]]></code>
<code><![CDATA[static fn (ClassLike $c): bool => $c->name !== null]]></code>
</ArgumentTypeCoercion> </ArgumentTypeCoercion>
<MissingClosureParamType> <MissingClosureParamType>
<code>$val</code> <code>$val</code>

View File

@ -196,11 +196,11 @@ class FileIdTest extends MadelineTestCase
public function provideUrls(): array public function provideUrls(): array
{ {
$res = [ $res = [
'sticker' => 'https://github.com/danog/MadelineProto/blob/master/tests/lel.webp?raw=true', 'sticker' => 'https://github.com/danog/MadelineProto/raw/v8/tests/lel.webp?raw=true',
'photo' => 'https://github.com/danog/MadelineProto/blob/master/tests/faust.jpg', 'photo' => 'https://github.com/danog/MadelineProto/raw/v8/tests/faust.jpg',
'audio' => 'https://github.com/danog/MadelineProto/blob/master/tests/mosconi.mp3?raw=true', 'audio' => 'https://github.com/danog/MadelineProto/raw/v8/tests/mosconi.mp3?raw=true',
'video' => 'https://github.com/danog/MadelineProto/blob/master/tests/swing.mp4?raw=true', 'video' => 'https://github.com/danog/MadelineProto/raw/v8/tests/swing.mp4?raw=true',
'animation' => 'https://github.com/danog/MadelineProto/blob/master/tests/pony.mp4?raw=true', 'animation' => 'https://github.com/danog/MadelineProto/raw/v8/tests/pony.mp4?raw=true',
'document' => 'https://github.com/danog/danog.github.io/raw/master/lol/index_htm_files/0.gif', 'document' => 'https://github.com/danog/danog.github.io/raw/master/lol/index_htm_files/0.gif',
'voice' => 'https://daniil.it/audio_2020-02-01_18-09-08.ogg', 'voice' => 'https://daniil.it/audio_2020-02-01_18-09-08.ogg',
]; ];