Skip to content

Commit b8e7662

Browse files
committed
setup tests and bugfix for configuration parameter passing
1 parent fb7a468 commit b8e7662

File tree

6 files changed

+81
-172
lines changed

6 files changed

+81
-172
lines changed

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ x-definitions:
2626
build:
2727
context: .
2828
dockerfile: Dockerfile
29-
image: neo4j-php-client:latest
29+
# image: neo4j-php-client:latest
3030
volumes:
3131
- .:/opt/project
3232
x-common-cluster:

psalm-baseline.xml

Lines changed: 1 addition & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -1,171 +1,2 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="5.15.0@5c774aca4746caf3d239d9c8cadb9f882ca29352">
3-
<file src="src/Authentication/Authenticate.php">
4-
<PossiblyUndefinedIntArrayOffset>
5-
<code>$pass</code>
6-
</PossiblyUndefinedIntArrayOffset>
7-
</file>
8-
<file src="src/Bolt/SslConfigurationFactory.php">
9-
<LessSpecificReturnStatement>
10-
<code><![CDATA[[$sslConfig, $this->enableSsl($uri->getHost(), $sslConfig, $config)]]]></code>
11-
<code>[$sslConfig, []]</code>
12-
</LessSpecificReturnStatement>
13-
<MoreSpecificReturnType>
14-
<code><![CDATA[array{0: 's'|'ssc'|'', 1: array{verify_peer?: bool, peer_name?: string, SNI_enabled?: bool, allow_self_signed?: bool}}]]></code>
15-
</MoreSpecificReturnType>
16-
</file>
17-
<file src="src/Common/SysVSemaphore.php">
18-
<InvalidArgument>
19-
<code><![CDATA[$this->semaphore]]></code>
20-
<code><![CDATA[$this->semaphore]]></code>
21-
<code>sem_get(hexdec($key), $max)</code>
22-
</InvalidArgument>
23-
</file>
24-
<file src="src/Databags/DatabaseInfo.php">
25-
<MissingTemplateParam>
26-
<code>DatabaseInfo</code>
27-
</MissingTemplateParam>
28-
</file>
29-
<file src="src/Databags/Plan.php">
30-
<MissingTemplateParam>
31-
<code>Plan</code>
32-
</MissingTemplateParam>
33-
</file>
34-
<file src="src/Databags/ProfiledPlan.php">
35-
<MissingTemplateParam>
36-
<code>ProfiledPlan</code>
37-
</MissingTemplateParam>
38-
</file>
39-
<file src="src/Databags/ResultSummary.php">
40-
<MissingTemplateParam>
41-
<code>ResultSummary</code>
42-
</MissingTemplateParam>
43-
</file>
44-
<file src="src/Databags/ServerInfo.php">
45-
<MissingTemplateParam>
46-
<code>ServerInfo</code>
47-
</MissingTemplateParam>
48-
</file>
49-
<file src="src/Databags/Statement.php">
50-
<MissingTemplateParam>
51-
<code>Statement</code>
52-
</MissingTemplateParam>
53-
</file>
54-
<file src="src/Databags/SummaryCounters.php">
55-
<MissingTemplateParam>
56-
<code>SummaryCounters</code>
57-
</MissingTemplateParam>
58-
</file>
59-
<file src="src/Formatter/BasicFormatter.php">
60-
<ImplementedParamTypeMismatch>
61-
<code>$meta</code>
62-
</ImplementedParamTypeMismatch>
63-
</file>
64-
<file src="src/Formatter/Specialised/JoltHttpOGMTranslator.php">
65-
<PossiblyUndefinedArrayOffset>
66-
<code>$coordinates</code>
67-
</PossiblyUndefinedArrayOffset>
68-
</file>
69-
<file src="src/Formatter/Specialised/LegacyHttpOGMTranslator.php">
70-
<ArgumentTypeCoercion>
71-
<code>$value</code>
72-
<code>$value</code>
73-
</ArgumentTypeCoercion>
74-
<InvalidReturnStatement>
75-
<code><![CDATA[$this->translateCypherList($value, $meta)]]></code>
76-
<code>[new CypherList($tbr), $meta]</code>
77-
</InvalidReturnStatement>
78-
<InvalidReturnType>
79-
<code>array{0: OGMTypes, 1: HttpMetaInfo}</code>
80-
</InvalidReturnType>
81-
<PossiblyUndefinedIntArrayOffset>
82-
<code>$milliseconds</code>
83-
<code>$milliseconds</code>
84-
<code>$secondsFraction</code>
85-
<code>$time</code>
86-
<code>$time</code>
87-
<code>$timezone</code>
88-
<code>$tzMinutes</code>
89-
</PossiblyUndefinedIntArrayOffset>
90-
</file>
91-
<file src="src/Formatter/SummarizedResultFormatter.php">
92-
<InvalidArgument>
93-
<code>$response</code>
94-
</InvalidArgument>
95-
<InvalidArrayOffset>
96-
<code><![CDATA[$response['db']]]></code>
97-
</InvalidArrayOffset>
98-
</file>
99-
<file src="src/Types/Abstract3DPoint.php">
100-
<ImplementedReturnTypeMismatch>
101-
<code>array{x: float, y: float, z: float, srid: int, crs: Crs}</code>
102-
</ImplementedReturnTypeMismatch>
103-
</file>
104-
<file src="src/Types/AbstractCypherSequence.php">
105-
<InvalidPropertyAssignmentValue>
106-
<code><![CDATA[$this->keyCache]]></code>
107-
<code><![CDATA[$this->keyCache]]></code>
108-
</InvalidPropertyAssignmentValue>
109-
</file>
110-
<file src="src/Types/AbstractPoint.php">
111-
<MissingTemplateParam>
112-
<code>AbstractPoint</code>
113-
</MissingTemplateParam>
114-
</file>
115-
<file src="src/Types/ArrayList.php">
116-
<ImplementedReturnTypeMismatch>
117-
<code><![CDATA[static<TValue|NewValue>]]></code>
118-
</ImplementedReturnTypeMismatch>
119-
</file>
120-
<file src="src/Types/Map.php">
121-
<ImplementedReturnTypeMismatch>
122-
<code><![CDATA[static<TValue|NewValue>]]></code>
123-
</ImplementedReturnTypeMismatch>
124-
</file>
125-
<file src="tests/Unit/CypherListTest.php">
126-
<NoValue>
127-
<code>$item</code>
128-
</NoValue>
129-
<UnevaluatedCode>
130-
<code>++$counter;</code>
131-
<code>self::assertEquals(0, $counter);</code>
132-
<code><![CDATA[self::assertEquals(['A', 'B', 'C'][$key], $item);]]></code>
133-
</UnevaluatedCode>
134-
<UnusedVariable>
135-
<code>$counter</code>
136-
<code>$key</code>
137-
</UnusedVariable>
138-
</file>
139-
<file src="tests/Unit/CypherMapTest.php">
140-
<MissingTemplateParam>
141-
<code>IteratorAggregate</code>
142-
</MissingTemplateParam>
143-
<NoValue>
144-
<code>$item</code>
145-
</NoValue>
146-
<UnevaluatedCode>
147-
<code>++$counter;</code>
148-
<code>self::assertEquals(0, $counter);</code>
149-
<code><![CDATA[self::assertEquals(['A' => 'x'][$key], $item);]]></code>
150-
</UnevaluatedCode>
151-
<UnusedVariable>
152-
<code>$counter</code>
153-
<code>$key</code>
154-
</UnusedVariable>
155-
</file>
156-
<file src="tests/Unit/DNSAddressResolverTest.php">
157-
<InvalidOperand>
158-
<code><![CDATA[$this->resolver->getAddresses('8.8.8.8')]]></code>
159-
<code><![CDATA[$this->resolver->getAddresses('bogus')]]></code>
160-
<code><![CDATA[$this->resolver->getAddresses('test.ghlen.com')]]></code>
161-
</InvalidOperand>
162-
<NoValue>
163-
<code>$records</code>
164-
</NoValue>
165-
</file>
166-
<file src="tests/Unit/ParameterHelperTest.php">
167-
<MissingTemplateParam>
168-
<code>Iterator</code>
169-
</MissingTemplateParam>
170-
</file>
171-
</files>
2+
<files psalm-version="5.15.0@5c774aca4746caf3d239d9c8cadb9f882ca29352"/>

src/Client.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,21 @@ public function __construct(
5555
private TransactionConfiguration $defaultTransactionConfiguration
5656
) {}
5757

58+
public function getDriverSetups(): DriverSetupManager
59+
{
60+
return $this->driverSetups;
61+
}
62+
63+
public function getDefaultSessionConfiguration(): SessionConfiguration
64+
{
65+
return $this->defaultSessionConfiguration;
66+
}
67+
68+
public function getDefaultTransactionConfiguration(): TransactionConfiguration
69+
{
70+
return $this->defaultTransactionConfiguration;
71+
}
72+
5873
public function run(string $statement, iterable $parameters = [], ?string $alias = null)
5974
{
6075
return $this->runStatement(Statement::create($statement, $parameters), $alias);

src/ClientBuilder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ public function build(): ClientInterface
163163
public function withDefaultDriverConfiguration(DriverConfiguration $config): self
164164
{
165165
$tbr = clone $this;
166-
$tbr->defaultDriverConfig = $config;
166+
167+
$tbr->driverSetups = $tbr->driverSetups->withDriverConfiguration($config);
167168

168169
return $tbr;
169170
}

src/Common/DriverSetupManager.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@ public function __construct(
5757
private DriverConfiguration $configuration
5858
) {}
5959

60+
public function getDriverConfiguration(): DriverConfiguration
61+
{
62+
return $this->configuration;
63+
}
64+
65+
public function withDriverConfiguration(DriverConfiguration $config): self
66+
{
67+
$tbr = clone $this;
68+
69+
$tbr->configuration = $config;
70+
71+
return $tbr;
72+
}
73+
6074
/**
6175
* @psalm-mutation-free
6276
*/
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the Neo4j PHP Client and Driver package.
7+
*
8+
* (c) Nagels <https://nagels.tech>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Integration;
15+
16+
use Laudis\Neo4j\Client;
17+
use Laudis\Neo4j\ClientBuilder;
18+
use Laudis\Neo4j\Databags\DriverConfiguration;
19+
use Laudis\Neo4j\Databags\SessionConfiguration;
20+
use Laudis\Neo4j\Databags\SslConfiguration;
21+
use Laudis\Neo4j\Databags\TransactionConfiguration;
22+
use Laudis\Neo4j\Enum\SslMode;
23+
use PHPUnit\Framework\TestCase;
24+
25+
class ClientBuilderTest extends TestCase
26+
{
27+
public function testGetClient(): void
28+
{
29+
$sslConfig = SslConfiguration::default()->withVerifyPeer(false)->withMode(SslMode::FROM_URL());
30+
$driverconfig = DriverConfiguration::default()
31+
->withSslConfiguration($sslConfig)
32+
->withMaxPoolSize(4096)
33+
->withAcquireConnectionTimeout(2.5);
34+
$sessionConfig = SessionConfiguration::default()->withDatabase('neo4j');
35+
$transactionConfig = TransactionConfiguration::default()->withTimeout(120.0);
36+
$client = ClientBuilder::create()
37+
->withDefaultDriverConfiguration($driverconfig)
38+
->withDefaultSessionConfiguration($sessionConfig)
39+
->withDefaultTransactionConfiguration($transactionConfig)
40+
->build();
41+
42+
self::assertInstanceOf(Client::class, $client);
43+
self::assertEquals($driverconfig, $client->getDriverSetups()->getDriverConfiguration());
44+
self::assertEquals($sslConfig, $client->getDriverSetups()->getDriverConfiguration()->getSslConfiguration());
45+
self::assertEquals($sessionConfig, $client->getDefaultSessionConfiguration());
46+
self::assertEquals($transactionConfig, $client->getDefaultTransactionConfiguration());
47+
}
48+
}

0 commit comments

Comments
 (0)