Skip to content

Commit 495864c

Browse files
Merge pull request #53 from neo4j-php/phpunit_update
Phpunit update
2 parents d3fdcc9 + 28f2792 commit 495864c

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
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
/**

0 commit comments

Comments
 (0)