-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add testIsMQTT5 and Use constants instead of hard coding
- Loading branch information
1 parent
a329202
commit b9d4365
Showing
3 changed files
with
76 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
/** | ||
* This file is part of Simps | ||
* | ||
* @link https://github.com/simps/mqtt | ||
* @contact Lu Fei <lufei@simps.io> | ||
* | ||
* For the full copyright and license information, | ||
* please view the LICENSE file that was distributed with this source code | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpsTest\MQTT\Unit; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Simps\MQTT\Client; | ||
use Simps\MQTT\Config\ClientConfig; | ||
use Simps\MQTT\Protocol\ProtocolInterface; | ||
|
||
/** | ||
* @internal | ||
* @coversNothing | ||
*/ | ||
class ClientConfigTest extends TestCase | ||
{ | ||
public function testIsMQTT5() | ||
{ | ||
$config = new ClientConfig(); | ||
$config->setClientId(Client::genClientID()) | ||
->setKeepAlive(10) | ||
->setDelay(3000) | ||
->setMaxAttempts(5) | ||
->setSwooleConfig(SWOOLE_MQTT_CONFIG); | ||
$this->assertEquals($config->getUserName(), ''); | ||
$this->assertEquals($config->getPassword(), ''); | ||
$this->assertFalse($config->isMQTT5()); | ||
$this->assertEquals($config->getProtocolLevel(), ProtocolInterface::MQTT_PROTOCOL_LEVEL_3_1_1); | ||
|
||
$config->setProperties(['receive_maximum' => 65535]); | ||
$this->assertTrue($config->isMQTT5()); | ||
$this->assertEquals($config->getProtocolLevel(), ProtocolInterface::MQTT_PROTOCOL_LEVEL_5_0); | ||
|
||
$config->setProtocolLevel(ProtocolInterface::MQTT_PROTOCOL_LEVEL_3_1); | ||
$this->assertTrue($config->isMQTT5()); | ||
$this->assertEquals($config->getProtocolLevel(), ProtocolInterface::MQTT_PROTOCOL_LEVEL_5_0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters