This commit is contained in:
Daniil Gentili 2024-04-01 17:39:42 +02:00
parent 34338dba16
commit 44b83e2ed0
4 changed files with 26 additions and 23 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.phpunit.cache
MadelineProtoPhar MadelineProtoPhar
JSON.sh JSON.sh
halloween halloween

View File

@ -14,7 +14,7 @@
"php-64bit": ">=8.1" "php-64bit": ">=8.1"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^9", "phpunit/phpunit": "^11",
"amphp/php-cs-fixer-config": "^2", "amphp/php-cs-fixer-config": "^2",
"vimeo/psalm": "dev-master" "vimeo/psalm": "dev-master"
}, },

View File

@ -1,20 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.0/phpunit.xsd" bootstrap="vendor/autoload.php"
backupGlobals="false" cacheDirectory=".phpunit.cache"
backupStaticAttributes="false" beStrictAboutCoverageMetadata="true"
bootstrap="vendor/autoload.php" beStrictAboutOutputDuringTests="true"
colors="true" requireCoverageMetadata="false"
convertErrorsToExceptions="true" failOnRisky="true"
convertNoticesToExceptions="true" executionOrder="random"
convertWarningsToExceptions="true" failOnWarning="true">
processIsolation="false"
stopOnFailure="false"
>
<testsuites> <testsuites>
<testsuite name="Main"> <testsuite name="default">
<directory>tests</directory> <directory>tests</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory>src</directory>
</include>
</source>
</phpunit> </phpunit>

View File

@ -6,14 +6,13 @@ use CURLFile;
use danog\Decoder\FileId; use danog\Decoder\FileId;
use danog\Decoder\FileIdType; use danog\Decoder\FileIdType;
use danog\Decoder\UniqueFileId; use danog\Decoder\UniqueFileId;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
/** @api */ /** @api */
class IntegrationTest extends TestCase class IntegrationTest extends TestCase
{ {
/** #[DataProvider('provideFileIdsAndType')]
* @dataProvider provideFileIdsAndType
*/
public function testAll(FileIdType $type, string $fileIdStr, string $uniqueFileIdStr): void public function testAll(FileIdType $type, string $fileIdStr, string $uniqueFileIdStr): void
{ {
$fileId = FileId::fromBotAPI($fileIdStr); $fileId = FileId::fromBotAPI($fileIdStr);
@ -29,7 +28,7 @@ class IntegrationTest extends TestCase
} }
/** @psalm-suppress MixedArrayAccess, MixedAssignment, PossiblyInvalidArgument, MixedArgument */ /** @psalm-suppress MixedArrayAccess, MixedAssignment, PossiblyInvalidArgument, MixedArgument */
public function provideFileIdsAndType(): \Generator public static function provideFileIdsAndType(): \Generator
{ {
foreach (['CAADBAADwwADmFmqDf6xBrPTReqHFgQ', 'CAACAgQAAxkBAAIC4l9CWDGzVUcDejU0TETLWbOdfsCoAALDAAOYWaoN_rEGs9NF6ocbBA', 'CAADBAADwwADmFmqDf6xBrPTReqHAg'] as $fileId) { foreach (['CAADBAADwwADmFmqDf6xBrPTReqHFgQ', 'CAACAgQAAxkBAAIC4l9CWDGzVUcDejU0TETLWbOdfsCoAALDAAOYWaoN_rEGs9NF6ocbBA', 'CAADBAADwwADmFmqDf6xBrPTReqHAg'] as $fileId) {
yield [ yield [
@ -41,7 +40,7 @@ class IntegrationTest extends TestCase
$dest = \getenv('DEST'); $dest = \getenv('DEST');
$token = \getenv('TOKEN'); $token = \getenv('TOKEN');
foreach ($this->provideChats() as $chat) { foreach (self::provideChats() as $chat) {
/** /**
* @var array{ * @var array{
* small_file_id: string, * small_file_id: string,
@ -62,7 +61,7 @@ class IntegrationTest extends TestCase
$result['big_file_unique_id'], $result['big_file_unique_id'],
]; ];
} }
foreach ($this->provideUrls() as $type => $url) { foreach (self::provideUrls() as $type => $url) {
if ($type === 'video_note') { if ($type === 'video_note') {
\copy($url, \basename($url)); \copy($url, \basename($url));
@ -104,11 +103,11 @@ class IntegrationTest extends TestCase
* @psalm-suppress InvalidReturnStatement, InvalidReturnType * @psalm-suppress InvalidReturnStatement, InvalidReturnType
* @return list<string> * @return list<string>
*/ */
public function provideChats(): array public static function provideChats(): array
{ {
return [\getenv('DEST'), '@MadelineProto']; return [\getenv('DEST'), '@MadelineProto'];
} }
public function provideUrls(): array public static function provideUrls(): array
{ {
return [ return [
'sticker' => 'https://github.com/danog/MadelineProto/raw/v8/tests/lel.webp?raw=true', 'sticker' => 'https://github.com/danog/MadelineProto/raw/v8/tests/lel.webp?raw=true',