14
14
namespace Laudis \Neo4j \Tests \Unit ;
15
15
16
16
use BadMethodCallException ;
17
+ use Buzz \Exception \NetworkException ;
17
18
use InvalidArgumentException ;
18
19
use Laudis \Neo4j \ClientBuilder ;
20
+ use Laudis \Neo4j \Exception \Neo4jException ;
21
+ use Laudis \Neo4j \Network \Bolt \BoltInjections ;
22
+ use Laudis \Neo4j \Network \Http \HttpInjections ;
19
23
use PHPUnit \Framework \TestCase ;
20
24
21
25
final class ClientBuilderTest extends TestCase
@@ -41,7 +45,7 @@ public function testBadDefault(): void
41
45
public function testBadHttpUrl (): void
42
46
{
43
47
$ this ->expectException (InvalidArgumentException::class);
44
- $ this ->expectExceptionMessage ('The provided url must have a parsed host, user and pass value ' );
48
+ $ this ->expectExceptionMessage ('The provided url must have a parsed host, user, pass and scheme value ' );
45
49
46
50
ClientBuilder::create ()
47
51
->addHttpConnection ('temp ' , 'neoj:test ' );
@@ -50,9 +54,107 @@ public function testBadHttpUrl(): void
50
54
public function testBadBoltUrl (): void
51
55
{
52
56
$ this ->expectException (InvalidArgumentException::class);
53
- $ this ->expectExceptionMessage ('The provided url must have a parsed host, user and pass value ' );
57
+ $ this ->expectExceptionMessage ('The provided url must have a parsed host, user, pass and scheme value ' );
54
58
55
59
ClientBuilder::create ()
56
60
->addBoltConnection ('temp ' , 'neoj:test ' );
57
61
}
62
+
63
+ public function testBoltSetupNoScheme (): void
64
+ {
65
+ $ this ->expectException (InvalidArgumentException::class);
66
+ $ client = ClientBuilder::create ()->addBoltConnection ('bolt ' , 'neo4j:test@neo4j-42:7687 ' )->build ();
67
+ $ client ->openTransaction ();
68
+ }
69
+
70
+ public function testBoltSetupWithScheme (): void
71
+ {
72
+ $ client = ClientBuilder::create ()->addBoltConnection ('bolt ' , 'bolt://neo4j:test@neo4j-42:7687 ' )->build ();
73
+ $ client ->openTransaction ();
74
+ self ::assertTrue (true );
75
+ }
76
+
77
+ public function testBoltSetupWithoutPort (): void
78
+ {
79
+ $ client = ClientBuilder::create ()->addBoltConnection ('bolt ' , 'bolt://neo4j:test@neo4j-42 ' )->build ();
80
+ $ client ->openTransaction ();
81
+ self ::assertTrue (true );
82
+ }
83
+
84
+ public function testBoltSetupWithoutUserAndPass (): void
85
+ {
86
+ $ this ->expectException (InvalidArgumentException::class);
87
+ $ client = ClientBuilder::create ()->addBoltConnection ('bolt ' , 'bolt://@neo4j-42 ' )->build ();
88
+ $ client ->openTransaction ();
89
+ }
90
+
91
+ public function testBoltEmpty (): void
92
+ {
93
+ $ this ->expectException (InvalidArgumentException::class);
94
+ $ client = ClientBuilder::create ()->addBoltConnection ('bolt ' , '' )->build ();
95
+ $ client ->openTransaction ();
96
+ }
97
+
98
+ public function testBoltSetupWrongScheme (): void
99
+ {
100
+ $ client = ClientBuilder::create ()->addBoltConnection ('bolt ' , 'neo4j://neo4j:test@neo4j-42:7687 ' )->build ();
101
+ $ client ->openTransaction ();
102
+ self ::assertTrue (true );
103
+ }
104
+
105
+ public function testHttpSetupNoScheme (): void
106
+ {
107
+ $ this ->expectException (InvalidArgumentException::class);
108
+ $ client = ClientBuilder::create ()->addHttpConnection ('http ' , 'test:neo4j@neo4j-42:7474 ' )->build ();
109
+ $ client ->openTransaction ();
110
+ }
111
+
112
+ public function testHttpSetupWithScheme (): void
113
+ {
114
+ $ client = ClientBuilder::create ()->addHttpConnection ('http ' , 'http://neo4j:test@neo4j-42:7474 ' )->build ();
115
+ $ client ->openTransaction ();
116
+ self ::assertTrue (true );
117
+ }
118
+
119
+ public function testHttpSetupWrongScheme (): void
120
+ {
121
+ $ client = ClientBuilder::create ()->addHttpConnection ('http ' , 'neo4j://neo4j:test@neo4j-42:7474 ' )->build ();
122
+ $ this ->expectException (NetworkException::class);
123
+ $ client ->openTransaction ();
124
+ }
125
+
126
+ public function testHttpSetupWithoutPort (): void
127
+ {
128
+ $ client = ClientBuilder::create ()->addHttpConnection ('http ' , 'http://neo4j:test@neo4j-42 ' )->build ();
129
+ $ client ->openTransaction ();
130
+ self ::assertTrue (true );
131
+ }
132
+
133
+ public function testHttpSetupWithoutUserAndPass (): void
134
+ {
135
+ $ this ->expectException (InvalidArgumentException::class);
136
+ $ client = ClientBuilder::create ()->addHttpConnection ('http ' , 'http://@neo4j-42 ' )->build ();
137
+ $ client ->openTransaction ();
138
+ }
139
+
140
+ public function testHttpEmpty (): void
141
+ {
142
+ $ this ->expectException (InvalidArgumentException::class);
143
+ $ client = ClientBuilder::create ()->addHttpConnection ('http ' , '' )->build ();
144
+ $ client ->openTransaction ();
145
+ }
146
+
147
+ public function testHttpWithDatabase (): void
148
+ {
149
+ $ client = ClientBuilder::create ()->addHttpConnection ('http ' , 'http://neo4j:test@neo4j-42 ' , HttpInjections::create ()->withDatabase ('abc ' ))->build ();
150
+ $ this ->expectException (Neo4jException::class);
151
+ $ client ->openTransaction ();
152
+ }
153
+
154
+ public function testBoltWithDatabase (): void
155
+ {
156
+ $ client = ClientBuilder::create ()->addBoltConnection ('bolt ' , 'bolt://neo4j:test@neo4j-42 ' , BoltInjections::create ()->withDatabase ('abc ' ))->build ();
157
+ $ this ->expectException (Neo4jException::class);
158
+ $ client ->openTransaction ();
159
+ }
58
160
}
0 commit comments