40 lines
941 B
PHP
40 lines
941 B
PHP
<?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, '启动失败');
|
|
}
|
|
}
|