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
JSON.sh
halloween

View File

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

View File

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

View File

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