Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@
'phpdoc_separation' => false,
'phpdoc_summary' => false,
'single_quote' => true,
'increment_style' => [],
'increment_style' => [
'style' => 'post',
],
'standardize_increment' => false,
'standardize_not_equals' => true,
'multiline_comment_opening_closing' => true,
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"ext-mbstring": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0",
"phpunit/phpunit": "^8.5",
"deminy/counit": "^0.3",
"friendsofphp/php-cs-fixer": "3.7.0",
"swoole/ide-helper": ">=4.4.20",
"simps/mqtt-cli": "*",
"phpstan/phpstan": "^2.0"
Expand All @@ -50,7 +50,7 @@
"scripts": {
"cs-check": "/usr/bin/env php ./vendor/bin/php-cs-fixer fix --dry-run",
"cs-fix": "/usr/bin/env php ./vendor/bin/php-cs-fixer fix",
"test": "./tests/co-phpunit --colors=always",
"test": "./vendor/bin/counit --colors=always",
"analyse": "phpstan analyse --memory-limit 4096M -c phpstan.neon"
},
"extra": {
Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@
<ini name="display_errors" value="On" />
<ini name="display_startup_errors" value="On" />
</php>
<extensions>
<extension class="Deminy\Counit\CounitExtension"/>
</extensions>
</phpunit>
2 changes: 1 addition & 1 deletion src/Tools/UnPackTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected static function getRemainingLength(string $data, ?int &$headBytes): in
$digit = ord($data[$headBytes]);
$value += ($digit & 127) * $multiplier;
$multiplier *= 128;
++$headBytes;
$headBytes++;
} while (($digit & 128) != 0);

return $value;
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/ClientConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
namespace SimpsTest\MQTT\Unit;

use PHPUnit\Framework\TestCase;
use Deminy\Counit\TestCase;
use Simps\MQTT\Client;
use Simps\MQTT\Config\ClientConfig;
use Simps\MQTT\Protocol\ProtocolInterface;
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
namespace SimpsTest\MQTT\Unit;

use PHPUnit\Framework\TestCase;
use Deminy\Counit\TestCase;
use Simps\MQTT\Client as MQTTClient;
use Simps\MQTT\Exception\ConnectException;
use Simps\MQTT\Exception\ProtocolException;
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
namespace SimpsTest\MQTT\Unit;

use PHPUnit\Framework\TestCase;
use Deminy\Counit\TestCase;
use Simps\MQTT\Message;
use Simps\MQTT\Protocol\ProtocolInterface;
use Simps\MQTT\Protocol\Types;
Expand All @@ -31,7 +31,7 @@
->setQos(ProtocolInterface::MQTT_QOS_1)
->setDup(ProtocolInterface::MQTT_DUP_0)
->setRetain(ProtocolInterface::MQTT_RETAIN_0)
->setMessage('this is content')

Check failure on line 34 in tests/Unit/MessageTest.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "this is content" 3 times.

See more on https://sonarcloud.io/project/issues?id=simps_mqtt&issues=AaBPIlcV69uhNReJ4ji9&open=AaBPIlcV69uhNReJ4ji9&pullRequest=130
->setMessageId(1)
->setProperties(['message_expiry_interval' => 100]);
$this->assertEquals(
Expand All @@ -43,7 +43,7 @@
$this->assertEquals(
$message->toArray(),
$message->getContents(true),
'The results of getContents and toArray should be the same'

Check failure on line 46 in tests/Unit/MessageTest.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "The results of getContents and toArray should be the same" 3 times.

See more on https://sonarcloud.io/project/issues?id=simps_mqtt&issues=AaBPIlcV69uhNReJ4ji8&open=AaBPIlcV69uhNReJ4ji8&pullRequest=130
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/ToolsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
namespace SimpsTest\MQTT\Unit;

use PHPUnit\Framework\TestCase;
use Deminy\Counit\TestCase;
use Simps\MQTT\Exception\InvalidArgumentException;
use Simps\MQTT\Protocol\ProtocolInterface;
use Simps\MQTT\Tools\Debug;
Expand All @@ -28,7 +28,7 @@
{
$connect_31 = '104400064d51497364700306000a001353696d70735f36313362316164323236626334001973696d70732d6d7174742f757365723030312f64656c6574650006627965627965';
$connect_311 = '104200044d5154540406000a001353696d70735f36313362313830323035636633001973696d70732d6d7174742f757365723030312f64656c6574650006627965627965';
$connect_50 = '106200044d515454050e000a0b110000003c21ffff22ffff001353696d70735f3631336231613330313962663213180000003c020000003c030004746573740101001973696d70732d6d7174742f757365723030312f64656c6574650006627965627965';

Check failure on line 31 in tests/Unit/ToolsTest.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "106200044d515454050e000a0b110000003c21ffff22ffff001353696d70735f3631336231613330313962663213180000003c020000003c030004746573740101001973696d70732d6d7174742f757365723030312f64656c6574650006627965627965" 6 times.

See more on https://sonarcloud.io/project/issues?id=simps_mqtt&issues=AaBPIlaO69uhNReJ4ji7&open=AaBPIlaO69uhNReJ4ji7&pullRequest=130
$this->assertSame(ProtocolInterface::MQTT_PROTOCOL_LEVEL_3_1, UnPackTool::getLevel(hex2bin($connect_31)));
$this->assertSame(ProtocolInterface::MQTT_PROTOCOL_LEVEL_3_1_1, UnPackTool::getLevel(hex2bin($connect_311)));
$this->assertSame(ProtocolInterface::MQTT_PROTOCOL_LEVEL_5_0, UnPackTool::getLevel(hex2bin($connect_50)));
Expand Down
4 changes: 3 additions & 1 deletion tests/V3/PacketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
namespace SimpsTest\MQTT\V3;

use PHPUnit\Framework\TestCase;
use Deminy\Counit\TestCase;
use Simps\MQTT\Client;
use Simps\MQTT\Exception\ProtocolException;
use Simps\MQTT\Hex\ReasonCode;
Expand All @@ -30,6 +30,7 @@ class PacketTest extends TestCase

public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::$topic = 'testtopic/simps-' . rand(100, 999);
self::$client = new Client(SIMPS_MQTT_REMOTE_HOST, SIMPS_MQTT_PORT, getTestConnectConfig());
}
Expand All @@ -38,6 +39,7 @@ public static function tearDownAfterClass(): void
{
self::$topic = '';
self::$client = null;
parent::tearDownAfterClass();
}

public function testConnect()
Expand Down
4 changes: 3 additions & 1 deletion tests/V3/WebSocketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
namespace SimpsTest\MQTT\V3;

use PHPUnit\Framework\TestCase;
use Deminy\Counit\TestCase;
use Simps\MQTT\Exception\ProtocolException;
use Simps\MQTT\Hex\ReasonCode;
use Simps\MQTT\Protocol\Types;
Expand All @@ -30,6 +30,7 @@ class WebSocketTest extends TestCase

public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::$topic = 'testtopic/simps-' . rand(100, 999);
self::$client = new WebSocketClient(SIMPS_MQTT_REMOTE_HOST, SIMPS_MQTT_OVER_WEBSOCKET_PORT, getTestConnectConfig());
}
Expand All @@ -38,6 +39,7 @@ public static function tearDownAfterClass(): void
{
self::$topic = '';
self::$client = null;
parent::tearDownAfterClass();
}

public function testConnect()
Expand Down
4 changes: 3 additions & 1 deletion tests/V5/PacketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
namespace SimpsTest\MQTT\V5;

use PHPUnit\Framework\TestCase;
use Deminy\Counit\TestCase;
use Simps\MQTT\Client;
use Simps\MQTT\Exception\ProtocolException;
use Simps\MQTT\Hex\ReasonCode;
Expand All @@ -31,6 +31,7 @@ class PacketTest extends TestCase

public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::$topic = 'testtopic/simps-' . rand(100, 999);
self::$client = new Client(SIMPS_MQTT_REMOTE_HOST, SIMPS_MQTT_PORT, getTestMQTT5ConnectConfig());
}
Expand All @@ -39,6 +40,7 @@ public static function tearDownAfterClass(): void
{
self::$topic = '';
self::$client = null;
parent::tearDownAfterClass();
}

public function testConnect()
Expand Down
4 changes: 3 additions & 1 deletion tests/V5/WebSocketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
namespace SimpsTest\MQTT\V5;

use PHPUnit\Framework\TestCase;
use Deminy\Counit\TestCase;
use Simps\MQTT\Exception\ProtocolException;
use Simps\MQTT\Hex\ReasonCode;
use Simps\MQTT\Protocol\Types;
Expand All @@ -31,6 +31,7 @@ class WebSocketTest extends TestCase

public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::$topic = 'testtopic/simps-' . rand(100, 999);
self::$client = new WebSocketClient(SIMPS_MQTT_REMOTE_HOST, SIMPS_MQTT_OVER_WEBSOCKET_PORT, getTestMQTT5ConnectConfig());
}
Expand All @@ -39,6 +40,7 @@ public static function tearDownAfterClass(): void
{
self::$topic = '';
self::$client = null;
parent::tearDownAfterClass();
}

public function testConnect()
Expand Down
64 changes: 0 additions & 64 deletions tests/co-phpunit

This file was deleted.