Skip to content

Commit

Permalink
Expect zero as default Keep Alive
Browse files Browse the repository at this point in the history
  • Loading branch information
jjok committed Jul 11, 2017
1 parent cdcb0df commit 848303a
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions tests/unit/packet/ConnectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testGetHeaderTestVariableHeaderWithoutConnectFlags()
chr(4) . // byte 7
chr(0) . // byte 8
chr(0) . // byte 9
chr(10) // byte 10
chr(0) // byte 10
),
MessageHelper::getReadableByRawString(substr($packet->get(), 2, 10))
);
Expand All @@ -59,7 +59,7 @@ public function testGetHeaderTestVariableHeaderWithConnectFlagsCleanSession()
chr(4) . // byte 7
chr(2) . // byte 8
chr(0) . // byte 9
chr(10) // byte 10
chr(0) // byte 10
),
MessageHelper::getReadableByRawString(substr($packet->get(), 2, 10))
);
Expand All @@ -79,7 +79,7 @@ public function testGetHeaderTestVariableHeaderWithConnectFlagWillFlag()
chr(4) . // byte 7
chr(4) . // byte 8
chr(0) . // byte 9
chr(10) // byte 10
chr(0) // byte 10
),
MessageHelper::getReadableByRawString(substr($packet->get(), 2, 10))
);
Expand All @@ -99,7 +99,7 @@ public function testGetHeaderTestVariableHeaderWithConnectFlagWillRetain()
chr(4) . // byte 7
chr(32) . // byte 8
chr(0) . // byte 9
chr(10) // byte 10
chr(0) // byte 10
),
MessageHelper::getReadableByRawString(substr($packet->get(), 2, 10))
);
Expand All @@ -119,7 +119,7 @@ public function testGetHeaderTestVariableHeaderWithConnectFlagUsername()
chr(4) . // byte 7
chr(128) . // byte 8
chr(0) . // byte 9
chr(10) // byte 10
chr(0) // byte 10
),
MessageHelper::getReadableByRawString(substr($packet->get(), 2, 10))
);
Expand All @@ -139,7 +139,7 @@ public function testGetHeaderTestVariableHeaderWithConnectFlagPassword()
chr(4) . // byte 7
chr(64) . // byte 8
chr(0) . // byte 9
chr(10) // byte 10
chr(0) // byte 10
),
MessageHelper::getReadableByRawString(substr($packet->get(), 2, 10))
);
Expand All @@ -159,7 +159,7 @@ public function testGetHeaderTestVariableHeaderWithConnectFlagWillWillQos()
chr(4) . // byte 7
chr(8) . // byte 8
chr(0) . // byte 9
chr(10) // byte 10
chr(0) // byte 10
),
MessageHelper::getReadableByRawString(substr($packet->get(), 2, 10))
);
Expand All @@ -179,7 +179,28 @@ public function testGetHeaderTestVariableHeaderWithConnectFlagUserNamePasswordCl
chr(4) . // byte 7
chr(194) . // byte 8
chr(0) . // byte 9
chr(10) // byte 10
chr(0) // byte 10
),
MessageHelper::getReadableByRawString(substr($packet->get(), 2, 10))
);
}

public function testBytesNineAndTenOfVariableHeaderAreKeepAlive()
{
$version = new \oliverlorenz\reactphpmqtt\protocol\Version4();
$packet = new \oliverlorenz\reactphpmqtt\packet\Connect(
$version, null, null, null, true, null, null, null, null, 999
);

$this->assertEquals(
MessageHelper::getReadableByRawString(
chr(0) . // byte 1
chr(4) . // byte 2
'MQTT' . // byte 3,4,5,6
chr(4) . // byte 7
chr(2) . // byte 8
chr(3) . // byte 9
chr(231) // byte 10
),
MessageHelper::getReadableByRawString(substr($packet->get(), 2, 10))
);
Expand Down

0 comments on commit 848303a

Please sign in to comment.