Skip to content

Commit

Permalink
changed default requested protocol versions to avoid breaking changes…
Browse files Browse the repository at this point in the history
…. updated readme. (#114)
  • Loading branch information
stefanak-michal authored Mar 15, 2023
1 parent 87e8e48 commit 06b5eef
Show file tree
Hide file tree
Showing 11 changed files with 184 additions and 130 deletions.
158 changes: 106 additions & 52 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Bolt.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class Bolt

public function __construct(private IConnection $connection)
{
$this->setProtocolVersions(5.1, 5, 4.4);
$this->setProtocolVersions(5, 4.4);
}

/**
Expand Down
30 changes: 15 additions & 15 deletions tests/BoltTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Bolt\Bolt;
use Exception;
use Bolt\protocol\{AProtocol, Response, V1, V2, V3, V4, V4_1, V4_2, V4_3, V4_4, V5, V5_1};
use Bolt\protocol\{AProtocol, Response, V4_4, V5, V5_1};

/**
* Class BoltTest
Expand All @@ -26,8 +26,8 @@ public function testSockets(): void
$bolt = new Bolt($conn);
$this->assertInstanceOf(Bolt::class, $bolt);

/** @var AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol */
$protocol = $bolt->build();
/** @var AProtocol|V4_4|V5|V5_1 $protocol */
$protocol = $bolt->setProtocolVersions(5.1, 5, 4.4)->build();
$this->assertInstanceOf(AProtocol::class, $protocol);

$this->sayHello($protocol, $GLOBALS['NEO_USER'], $GLOBALS['NEO_PASS']);
Expand All @@ -46,25 +46,25 @@ public function testAura(): void
$bolt = new Bolt($conn);
$this->assertInstanceOf(Bolt::class, $bolt);

/** @var AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|v5_1 $protocol */
$protocol = $bolt->build();
/** @var AProtocol|V4_4|V5|v5_1 $protocol */
$protocol = $bolt->setProtocolVersions(5.1, 5, 4.4)->build();
$this->assertInstanceOf(AProtocol::class, $protocol);

$this->sayHello($protocol, 'movies', 'movies');

$protocol->goodbye();
}

public function testHello(): AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1
public function testHello(): AProtocol|V4_4|V5|V5_1
{
$conn = new \Bolt\connection\StreamSocket($GLOBALS['NEO_HOST'] ?? '127.0.0.1', $GLOBALS['NEO_PORT'] ?? 7687);
$this->assertInstanceOf(\Bolt\connection\StreamSocket::class, $conn);

$bolt = new Bolt($conn);
$this->assertInstanceOf(Bolt::class, $bolt);

/** @var AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol */
$protocol = $bolt->build();
/** @var AProtocol|V4_4|V5|V5_1 $protocol */
$protocol = $bolt->setProtocolVersions(5.1, 5, 4.4)->build();
$this->assertInstanceOf(AProtocol::class, $protocol);

$this->sayHello($protocol, $GLOBALS['NEO_USER'], $GLOBALS['NEO_PASS']);
Expand All @@ -75,7 +75,7 @@ public function testHello(): AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1
/**
* @depends testHello
*/
public function testPull(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol): void
public function testPull(AProtocol|V4_4|V5|V5_1 $protocol): void
{
$protocol
->run('RETURN 1 AS num, 2 AS cnt', [], ['mode' => 'r'])
Expand All @@ -92,7 +92,7 @@ public function testPull(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $prot
/**
* @depends testHello
*/
public function testDiscard(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol): void
public function testDiscard(AProtocol|V4_4|V5|V5_1 $protocol): void
{
$gen = $protocol
->run('MATCH (a:Test) RETURN *', [], ['mode' => 'r'])
Expand All @@ -108,7 +108,7 @@ public function testDiscard(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $p
* @depends testHello
* @throws Exception
*/
public function testTransaction(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol): void
public function testTransaction(AProtocol|V4_4|V5|V5_1 $protocol): void
{
if (version_compare($protocol->getVersion(), 3, '<')) {
$this->markTestSkipped('Old Neo4j version does not support transactions');
Expand Down Expand Up @@ -145,7 +145,7 @@ public function testTransaction(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_
/**
* @depends testHello
*/
public function testRoute(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol): void
public function testRoute(AProtocol|V4_4|V5|V5_1 $protocol): void
{
if (version_compare($protocol->getVersion(), 4.3, '>=')) {
$response = $protocol
Expand All @@ -162,7 +162,7 @@ public function testRoute(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $pro
/**
* @depends testHello
*/
public function testReset(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol): void
public function testReset(AProtocol|V4_4|V5|V5_1 $protocol): void
{
$response = $protocol
->reset()
Expand All @@ -175,7 +175,7 @@ public function testReset(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $pro
* @depends testHello
* @throws Exception
*/
public function testChunking(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol): void
public function testChunking(AProtocol|V4_4|V5|V5_1 $protocol): void
{
$gen = $protocol
->begin()
Expand Down Expand Up @@ -205,7 +205,7 @@ public function testChunking(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $
/**
* @depends testHello
*/
public function testServerStateMismatchCallback(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol): void
public function testServerStateMismatchCallback(AProtocol|V4_4|V5|V5_1 $protocol): void
{
$protocol->serverState->set(\Bolt\protocol\ServerState::FAILED);
$protocol->serverState->expectedServerStateMismatchCallback = function (string $current, array $expected) {
Expand Down
6 changes: 3 additions & 3 deletions tests/PerformanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Bolt\Bolt;
use Bolt\connection\Socket;
use Bolt\protocol\{AProtocol, Response, V1, V2, V3, V4, V4_1, V4_2, V4_3, V4_4, V5, V5_1};
use Bolt\protocol\{AProtocol, Response, V4_4, V5, V5_1};
use Bolt\tests\packstream\v1\generators\RandomDataGenerator;

/**
Expand All @@ -20,8 +20,8 @@ public function test50KRecords(): void
$amount = 50000;

$conn = new Socket($GLOBALS['NEO_HOST'] ?? 'localhost', $GLOBALS['NEO_PORT'] ?? 7687, 60);
/** @var AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol */
$protocol = (new Bolt($conn))->build();
/** @var AProtocol|V4_4|V5|V5_1 $protocol */
$protocol = (new Bolt($conn))->setProtocolVersions(5.1, 5, 4.4)->build();

$this->sayHello($protocol, $GLOBALS['NEO_USER'], $GLOBALS['NEO_PASS']);

Expand Down
22 changes: 11 additions & 11 deletions tests/connection/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Bolt\tests\connection;

use Bolt\Bolt;
use Bolt\protocol\{AProtocol, Response, V1, V2, V3, V4, V4_1, V4_2, V4_3, V4_4, V5, V5_1};
use Bolt\protocol\{AProtocol, Response, V4_4, V5, V5_1};
use Bolt\tests\ATest;
use Bolt\connection\{
IConnection,
Expand Down Expand Up @@ -35,8 +35,8 @@ public function testMillisecondTimeout(string $alias): void
{
$conn = $this->getConnection($alias);
$conn->setTimeout(1.5);
/** @var AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol */
$protocol = (new Bolt($conn))->build();
/** @var AProtocol|V4_4|V5|V5_1 $protocol */
$protocol = (new Bolt($conn))->setProtocolVersions(5.1, 5, 4.4)->build();
$this->sayHello($protocol, $GLOBALS['NEO_USER'], $GLOBALS['NEO_PASS']);
$this->expectException(ConnectionTimeoutException::class);
$protocol
Expand All @@ -50,8 +50,8 @@ public function testMillisecondTimeout(string $alias): void
public function testLongNoTimeout(string $alias): void
{
$conn = $this->getConnection($alias);
/** @var AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol */
$protocol = (new Bolt($conn))->build();
/** @var AProtocol|V4_4|V5|V5_1 $protocol */
$protocol = (new Bolt($conn))->setProtocolVersions(5.1, 5, 4.4)->build();
$this->sayHello($protocol, $GLOBALS['NEO_USER'], $GLOBALS['NEO_PASS']);
$conn->setTimeout(200);
$protocol
Expand All @@ -66,8 +66,8 @@ public function testSecondsTimeout(string $alias): void
{
$conn = $this->getConnection($alias);
$conn->setTimeout(1);
/** @var AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol */
$protocol = (new Bolt($conn))->build();
/** @var AProtocol|V4_4|V5|V5_1 $protocol */
$protocol = (new Bolt($conn))->setProtocolVersions(5.1, 5, 4.4)->build();
$this->sayHello($protocol, $GLOBALS['NEO_USER'], $GLOBALS['NEO_PASS']);
$this->expectException(ConnectionTimeoutException::class);
$protocol
Expand All @@ -81,8 +81,8 @@ public function testSecondsTimeout(string $alias): void
public function testTimeoutRecoverAndReset(string $alias): void
{
$conn = $this->getConnection($alias);
/** @var AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol */
$protocol = (new Bolt($conn))->build();
/** @var AProtocol|V4_4|V5|V5_1 $protocol */
$protocol = (new Bolt($conn))->setProtocolVersions(5.1, 5, 4.4)->build();
$this->sayHello($protocol, $GLOBALS['NEO_USER'], $GLOBALS['NEO_PASS']);

$conn->setTimeout(1.5);
Expand All @@ -106,8 +106,8 @@ public function testTimeoutRecoverAndReset(string $alias): void
->getResponse();

$this->assertEquals(Response::SIGNATURE_FAILURE, $response->getSignature());
/** @var AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol */
$protocol = (new Bolt($conn))->build();
/** @var AProtocol|V4_4|V5|V5_1 $protocol */
$protocol = (new Bolt($conn))->setProtocolVersions(5.1, 5, 4.4)->build();
$this->sayHello($protocol, $GLOBALS['NEO_USER'], $GLOBALS['NEO_PASS']);

$conn->setTimeout(1.5);
Expand Down
10 changes: 5 additions & 5 deletions tests/packstream/v1/BytesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Bolt\Bolt;
use Bolt\packstream\Bytes;
use Bolt\protocol\{AProtocol, V1, V2, V3, V4, V4_1, V4_2, V4_3, V4_4, V5, V5_1};
use Bolt\protocol\{AProtocol, V4_4, V5, V5_1};
use Bolt\tests\ATest;

/**
Expand All @@ -13,16 +13,16 @@
*/
class BytesTest extends ATest
{
public function testInit(): AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1
public function testInit(): AProtocol|V4_4|V5|v5_1
{
$conn = new \Bolt\connection\StreamSocket($GLOBALS['NEO_HOST'] ?? '127.0.0.1', $GLOBALS['NEO_PORT'] ?? 7687);
$this->assertInstanceOf(\Bolt\connection\StreamSocket::class, $conn);

$bolt = new Bolt($conn);
$this->assertInstanceOf(Bolt::class, $bolt);

/** @var AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol */
$protocol = $bolt->build();
/** @var AProtocol|V4_4|V5|v5_1 $protocol */
$protocol = $bolt->setProtocolVersions(5.1, 5, 4.4)->build();
$this->assertInstanceOf(AProtocol::class, $protocol);

$this->sayHello($protocol, $GLOBALS['NEO_USER'], $GLOBALS['NEO_PASS']);
Expand All @@ -34,7 +34,7 @@ public function testInit(): AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1
* @depends testInit
* @dataProvider providerBytes
*/
public function testBytes(Bytes $arr, AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol)
public function testBytes(Bytes $arr, AProtocol|V4_4|V5|v5_1 $protocol)
{
$res = iterator_to_array(
$protocol
Expand Down
26 changes: 13 additions & 13 deletions tests/packstream/v1/PackerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Bolt\tests\packstream\v1;

use Bolt\Bolt;
use Bolt\protocol\{AProtocol, V1, V2, V3, V4, V4_1, V4_2, V4_3, V4_4, V5, V5_1};
use Bolt\protocol\{AProtocol, V4_4, V5, V5_1};
use Bolt\tests\ATest;

/**
Expand All @@ -15,16 +15,16 @@
*/
class PackerTest extends ATest
{
public function testInit(): AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1
public function testInit(): AProtocol|V4_4|V5|v5_1
{
$conn = new \Bolt\connection\StreamSocket($GLOBALS['NEO_HOST'] ?? '127.0.0.1', $GLOBALS['NEO_PORT'] ?? 7687);
$this->assertInstanceOf(\Bolt\connection\StreamSocket::class, $conn);

$bolt = new Bolt($conn);
$this->assertInstanceOf(Bolt::class, $bolt);

/** @var AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol */
$protocol = $bolt->build();
/** @var AProtocol|V4_4|V5|v5_1 $protocol */
$protocol = $bolt->setProtocolVersions(5.1, 5, 4.4)->build();
$this->assertInstanceOf(AProtocol::class, $protocol);

$this->sayHello($protocol, $GLOBALS['NEO_USER'], $GLOBALS['NEO_PASS']);
Expand All @@ -35,7 +35,7 @@ public function testInit(): AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1
/**
* @depends testInit
*/
public function testNull(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol): void
public function testNull(AProtocol|V4_4|V5|v5_1 $protocol): void
{
$res = iterator_to_array(
$protocol
Expand All @@ -50,7 +50,7 @@ public function testNull(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $prot
/**
* @depends testInit
*/
public function testBoolean(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol): void
public function testBoolean(AProtocol|V4_4|V5|v5_1 $protocol): void
{
$res = iterator_to_array(
$protocol
Expand All @@ -75,7 +75,7 @@ public function testBoolean(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $p
* @depends testInit
* @dataProvider providerInteger
*/
public function testInteger(int $i, AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol): void
public function testInteger(int $i, AProtocol|V4_4|V5|v5_1 $protocol): void
{
$res = iterator_to_array(
$protocol
Expand All @@ -98,7 +98,7 @@ public function providerInteger(): \Generator
/**
* @depends testInit
*/
public function testFloat(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol): void
public function testFloat(AProtocol|V4_4|V5|v5_1 $protocol): void
{
for ($i = 0; $i < 10; $i++) {
$num = mt_rand(-mt_getrandmax(), mt_getrandmax()) / mt_getrandmax();
Expand All @@ -116,7 +116,7 @@ public function testFloat(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $pro
/**
* @depends testInit
*/
public function testString(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol): void
public function testString(AProtocol|V4_4|V5|v5_1 $protocol): void
{
$randomString = function (int $length) {
$str = '';
Expand All @@ -141,7 +141,7 @@ public function testString(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $pr
/**
* @depends testInit
*/
public function testList(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol): void
public function testList(AProtocol|V4_4|V5|v5_1 $protocol): void
{
foreach ([0, 10, 200, 60000, 200000] as $size) {
$arr = $this->randomArray($size);
Expand All @@ -168,7 +168,7 @@ private function randomArray(int $size): array
/**
* @depends testInit
*/
public function testDictionary(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol): void
public function testDictionary(AProtocol|V4_4|V5|v5_1 $protocol): void
{
foreach ([0, 10, 200, 60000, 200000] as $size) {
$arr = $this->randomArray($size);
Expand All @@ -186,7 +186,7 @@ public function testDictionary(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1
/**
* @depends testInit
*/
public function testListGenerator(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol): void
public function testListGenerator(AProtocol|V4_4|V5|v5_1 $protocol): void
{
$data = [
'first',
Expand All @@ -208,7 +208,7 @@ public function testListGenerator(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V
/**
* @depends testInit
*/
public function testDictionaryGenerator(AProtocol|V1|V2|V3|V4|V4_1|V4_2|V4_3|V4_4|V5|V5_1 $protocol): void
public function testDictionaryGenerator(AProtocol|V4_4|V5|v5_1 $protocol): void
{
$data = [
'a' => 'first',
Expand Down
Loading

0 comments on commit 06b5eef

Please sign in to comment.