Skip to content

Commit a765bc5

Browse files
Updated tests for latest changes.
1 parent e724777 commit a765bc5

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

tests/ATest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ protected function mockConnection()
4848
->method('write')
4949
->with(
5050
$this->callback(function ($buffer) {
51+
if ($buffer == 0x0000)
52+
return true;
53+
5154
$i = self::$writeIndex;
5255
self::$writeIndex++;
5356

tests/BoltTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,17 @@ public function testHello(): ?Bolt
3434
Bolt::$debug = true;
3535

3636
try {
37-
$conn = new \Bolt\connection\StreamSocket($GLOBALS['NEO_HOST'] ?? '127.0.0.1', $GLOBALS['NEO_PORT'] ?? 7687);
38-
$this->assertInstanceOf(\Bolt\connection\StreamSocket::class, $conn);
39-
$bolt = new Bolt($conn);
40-
$this->assertInstanceOf(Bolt::class, $bolt);
41-
$this->assertTrue($bolt->hello('Test/1.0', $GLOBALS['NEO_USER'], $GLOBALS['NEO_PASS']));
37+
if (extension_loaded('sockets')) {
38+
$conn = new \Bolt\connection\Socket($GLOBALS['NEO_HOST'] ?? '127.0.0.1', $GLOBALS['NEO_PORT'] ?? 7687);
39+
$this->assertInstanceOf(\Bolt\connection\Socket::class, $conn);
40+
$bolt = new Bolt($conn);
41+
$this->assertInstanceOf(Bolt::class, $bolt);
42+
$this->assertTrue($bolt->hello('Test/1.0', $GLOBALS['NEO_USER'], $GLOBALS['NEO_PASS']));
43+
}
4244
unset($bolt);
4345

44-
$conn = new \Bolt\connection\Socket($GLOBALS['NEO_HOST'] ?? '127.0.0.1', $GLOBALS['NEO_PORT'] ?? 7687);
45-
$this->assertInstanceOf(\Bolt\connection\Socket::class, $conn);
46+
$conn = new \Bolt\connection\StreamSocket($GLOBALS['NEO_HOST'] ?? '127.0.0.1', $GLOBALS['NEO_PORT'] ?? 7687);
47+
$this->assertInstanceOf(\Bolt\connection\StreamSocket::class, $conn);
4648
$bolt = new Bolt($conn);
4749
$this->assertInstanceOf(Bolt::class, $bolt);
4850
$this->assertTrue($bolt->hello('Test/1.0', $GLOBALS['NEO_USER'], $GLOBALS['NEO_PASS']));

tests/ErrorsTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,16 @@ public function testMessageException()
4444
}
4545

4646
$this->expectException(\Bolt\error\MessageException::class);
47-
$bolt->hello('Test/1.0', $GLOBALS['NEO_USER'], 'wrong password');
47+
$bolt->hello('Test/1.0', $GLOBALS['NEO_USER'], $GLOBALS['NEO_PASS']);
48+
$bolt->run('Wrong message');
4849
}
4950

5051
public function testPackException1()
5152
{
52-
$this->expectException(\Bolt\error\PackException::class);
5353
$packer = new \Bolt\PackStream\v1\Packer();
5454
$this->assertInstanceOf(\Bolt\PackStream\v1\Packer::class, $packer);
55-
$packer->pack(0x00, fopen('php://input', 'r'));
55+
$this->expectException(\Bolt\error\PackException::class);
56+
foreach ($packer->pack(0x00, fopen('php://input', 'r')) as $chunk) { }
5657
}
5758

5859
public function testPackException2()

tests/PackStream/v1/PackerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function test__construct(): Packer
4141
*/
4242
public function testPack(string $bin, array $args, Packer $packer)
4343
{
44-
$this->assertEquals($bin, $packer->pack(0x88, $args));
44+
$this->assertEquals($bin, implode(iterator_to_array($packer->pack(0x88, $args))));
4545
}
4646

4747
/**

tests/protocol/V1Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function test__construct()
3939
public function testInit(V1 $cls)
4040
{
4141
self::$readArray = [1, 2, 0];
42-
self::$writeBuffer = [hex2bin('003db20188546573742f312e30a386736368656d65856261736963897072696e636970616c84757365728b63726564656e7469616c738870617373776f72640000')];
42+
self::$writeBuffer = [hex2bin('003db20188546573742f312e30a386736368656d65856261736963897072696e636970616c84757365728b63726564656e7469616c738870617373776f7264')];
4343

4444
$this->assertTrue($cls->init('Test/1.0', 'basic', 'user', 'password'));
4545
}

0 commit comments

Comments
 (0)