使用workman

This commit is contained in:
2025-05-13 15:49:27 +08:00
parent c1547e191c
commit 2ff864b8c8
9 changed files with 446 additions and 13 deletions

View File

@@ -6,34 +6,43 @@ use cn\com\maiyoule\mqttclient\biz\AppUserCreateRequest;
use cn\com\maiyoule\mqttclient\biz\AppUserDeleteRequest;
use cn\com\maiyoule\mqttclient\biz\AppUserUpdateRequest;
use cn\com\maiyoule\mqttclient\exception\ApiException;
use cn\com\maiyoule\mqttclient\MQTTManager;
use cn\com\maiyoule\mqttclient\AuthorServerClient;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\TestCase;
class AppManagerTest extends TestCase
{
private MQTTManager $manager;
private AuthorServerClient $manager;
protected function setUp(): void
{
$this->manager = new MQTTManager();
$this->manager->setAppId('6MMVTLW66D');
$this->manager = new AuthorServerClient();
$this->manager->setAppId('6N6QPV2FYD');
$this->manager->setPrivateKey(file_get_contents(__DIR__ . '/prikey.pem'));
$this->manager->setApi('http://localhost:8000/api/');
$this->manager->setApi('https://mqttauthor_dev.maiyoule.com.cn/api/');
$this->manager->setDebug(true);
}
public function testAdmin()
{
$request = new AppUserCreateRequest();
$request->setPassword('123');
$request->setRole('admin');
$request->setBiz('ch');
$biz = $this->manager->exec($request);
$this->assertTrue($biz->isSuccess(), $biz->getMessage());
}
public function testRunUser()
{
try {
$request = new AppUserCreateRequest();
$request->setPassword('111');
$request->setFettle('');
$request->setRole('admin');
$request->setBiz(['ch','ws']);
$request->setBiz(['ch', 'ws']);
$biz = $this->manager->exec($request);
if (!$biz->isSuccess()) {

View File

@@ -0,0 +1,39 @@
<?php
namespace cn\com\maiyoule\mqttclient\test;
use cn\com\maiyoule\mqttclient\AuthorAppMQTTClient;
use PHPUnit\Framework\TestCase;
class AuthorAppMQTTClientTest extends TestCase
{
private AuthorAppMQTTClient $client;
protected function setUp(): void
{
}
protected function tearDown(): void
{
$this->client->stop();
}
public function testInit()
{
$this->client = AuthorAppMQTTClient::getInstance();
$this->client->setServer('202.200.18.22');
$this->client->setAppid('6N6QPV2FYD');
$this->client
->setClientId('6NEC8SKNK5')
->setUsername('6N6QPV2FYD')
->setPassword('123')
->registerEvent(AuthorAppMQTTClient::EVENT_CONNECT, function ($connection) {
print_r('连接成功');
});
$result = $this->client->start();
self::assertTrue($result, '启动失败');
}
}