Skip to content

Commit 5c9a27b

Browse files
added tests for 4.2 and 4.3. Fixed test for timeout exception. added test script into composer.
1 parent 36db30b commit 5c9a27b

File tree

9 files changed

+82
-10
lines changed

9 files changed

+82
-10
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.idea/
22
.vscode/
3-
phpunit*.phar
43
/index.php
54
cert/
5+
/vendor/
6+
*.lock
7+
*.cache

composer.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"ext-mbstring": "*"
1414
},
1515
"require-dev": {
16-
"phpunit/phpunit": ">=7.5.0"
16+
"phpunit/phpunit": ">=7.5.0",
1717
},
1818
"support": {
1919
"issues": "https://github.com/neo4j-php/Bolt/issues",
@@ -42,7 +42,14 @@
4242
"Bolt\\tests\\": "tests/"
4343
}
4444
},
45-
"suggests": {
45+
"suggest": {
4646
"laudis/neo4j-php-client": "Neo4j-PHP-Client is the most advanced PHP Client for Neo4j"
47+
},
48+
"scripts": {
49+
"test": [
50+
"@putenv XDEBUG_MODE=debug",
51+
"Composer\\Config::disableProcessTimeout",
52+
"phpunit"
53+
]
4754
}
4855
}

src/autoload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
return;
1010
array_shift($parts);
1111

12-
if ($parts[0] == 'tests')
12+
if (reset($parts) == 'tests')
1313
array_unshift($parts,'..');
1414

1515
//compose standart namespaced path to file

tests/ErrorsTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ class ErrorsTest extends ATest
2222
{
2323
public function testConnectException()
2424
{
25-
$this->expectException(\Bolt\error\ConnectException::class);
26-
ini_set('default_socket_timeout', 1000);
27-
$conn = new \Bolt\connection\StreamSocket('1.1.1.1', 7687, 1);
25+
$conn = new \Bolt\connection\StreamSocket('127.0.0.1', 7800, 1);
2826
$this->assertInstanceOf(\Bolt\connection\StreamSocket::class, $conn);
27+
$this->expectException(\Bolt\error\ConnectException::class);
2928
$conn->connect();
3029
}
3130

tests/protocol/V1Test.php

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

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

4747
/**

tests/protocol/V3Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testHello(V3 $cls)
3838
self::$readArray = [1, 2, 0];
3939
self::$writeBuffer = [hex2bin('0048b101a48a757365725f6167656e7488546573742f312e3086736368656d65856261736963897072696e636970616c84757365728b63726564656e7469616c738870617373776f72640000')];
4040

41-
$this->assertTrue($cls->hello('Test/1.0', 'basic', 'user', 'password'));
41+
$this->assertIsArray($cls->hello('Test/1.0', 'basic', 'user', 'password'));
4242
}
4343

4444
/**

tests/protocol/V4_1Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testHello(V4_1 $cls)
3838
self::$readArray = [1, 2, 0];
3939
self::$writeBuffer = [hex2bin('0051b101a58a757365725f6167656e7488546573742f312e3086736368656d65856261736963897072696e636970616c84757365728b63726564656e7469616c738870617373776f726487726f7574696e67a00000')];
4040

41-
$this->assertTrue($cls->hello('Test/1.0', 'basic', 'user', 'password', []));
41+
$this->assertIsArray($cls->hello('Test/1.0', 'basic', 'user', 'password', []));
4242
}
4343

4444
/**

tests/protocol/V4_2Test.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Bolt\tests\protocol;
4+
5+
use Bolt\protocol\V4_2;
6+
7+
/**
8+
* Class V4_2Test
9+
*
10+
* @author Michal Stefanak
11+
* @link https://github.com/stefanak-michal/Bolt
12+
*
13+
* @covers \Bolt\protocol\AProtocol
14+
* @covers \Bolt\protocol\V4_2
15+
*
16+
* @package Bolt\tests\protocol
17+
* @requires PHP >= 7.1
18+
* @requires mbstring
19+
*/
20+
class V4_2Test extends \Bolt\tests\ATest
21+
{
22+
/**
23+
* @return V4_2
24+
*/
25+
public function test__construct()
26+
{
27+
$cls = new V4_2(new \Bolt\PackStream\v1\Packer, new \Bolt\PackStream\v1\Unpacker, $this->mockConnection());
28+
$this->assertInstanceOf(V4_2::class, $cls);
29+
return $cls;
30+
}
31+
32+
}

tests/protocol/V4_3Test.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Bolt\tests\protocol;
4+
5+
use Bolt\protocol\V4_3;
6+
7+
/**
8+
* Class V4_3Test
9+
*
10+
* @author Michal Stefanak
11+
* @link https://github.com/stefanak-michal/Bolt
12+
*
13+
* @covers \Bolt\protocol\AProtocol
14+
* @covers \Bolt\protocol\V4_3
15+
*
16+
* @package Bolt\tests\protocol
17+
* @requires PHP >= 7.1
18+
* @requires mbstring
19+
*/
20+
class V4_3Test extends \Bolt\tests\ATest
21+
{
22+
/**
23+
* @return V4_3
24+
*/
25+
public function test__construct()
26+
{
27+
$cls = new V4_3(new \Bolt\PackStream\v1\Packer, new \Bolt\PackStream\v1\Unpacker, $this->mockConnection());
28+
$this->assertInstanceOf(V4_3::class, $cls);
29+
return $cls;
30+
}
31+
32+
}

0 commit comments

Comments
 (0)