test --enable-openssl option for skipped

This commit is contained in:
crazywhalecc
2022-04-02 02:45:24 +08:00
parent f5cbce5195
commit 299f36dcc0

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Tests\ZM\Utils; namespace Tests\ZM\Utils;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Throwable;
use ZM\Annotation\CQ\CQCommand; use ZM\Annotation\CQ\CQCommand;
use ZM\API\CQ; use ZM\API\CQ;
use ZM\Event\EventManager; use ZM\Event\EventManager;
@@ -157,16 +158,27 @@ class MessageUtilTest extends TestCase
]; ];
} }
/**
* @throws Throwable
*/
public function testDownloadCQImage(): void public function testDownloadCQImage(): void
{ {
if (file_exists(DataProvider::getDataFolder('images') . '/test.jpg')) { if (file_exists(DataProvider::getDataFolder('images') . '/test.jpg')) {
unlink(DataProvider::getDataFolder('images') . '/test.jpg'); unlink(DataProvider::getDataFolder('images') . '/test.jpg');
} }
$msg = '[CQ:image,file=test.jpg,url=https://zhamao.xin/file/hello.jpg]'; $msg = '[CQ:image,file=test.jpg,url=https://zhamao.xin/file/hello.jpg]';
$result = MessageUtil::downloadCQImage($msg);
$this->assertIsArray($result); try {
$this->assertCount(1, $result); $result = MessageUtil::downloadCQImage($msg);
$this->assertFileExists(DataProvider::getDataFolder('images') . '/test.jpg'); $this->assertIsArray($result);
unlink(DataProvider::getDataFolder('images') . '/test.jpg'); $this->assertCount(1, $result);
$this->assertFileExists(DataProvider::getDataFolder('images') . '/test.jpg');
unlink(DataProvider::getDataFolder('images') . '/test.jpg');
} catch (Throwable $e) {
if (strpos($e->getMessage(), 'enable-openssl') !== false) {
$this->markTestSkipped('OpenSSL is not enabled');
}
throw $e;
}
} }
} }