Skip to content

Commit 76cdf8a

Browse files
PratikshaPratiksha
authored andcommitted
winp
1 parent c241a5b commit 76cdf8a

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

src/Configuration.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public function __construct(
2626
public readonly Bookmarks $bookmarks = new Bookmarks([]),
2727
public readonly AccessMode $accessMode = AccessMode::WRITE,
2828
) {
29-
// Validate that baseUri is not empty
3029
if (empty($this->baseUri)) {
3130
throw new InvalidArgumentException("Address (baseUri) must be provided.");
3231
}

src/Neo4jQueryAPI.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ public function __construct(
2323
private Neo4jRequestFactory $requestFactory,
2424
?Configuration $config = null
2525
) {
26-
$this->config = $config ?? new Configuration(getenv("NEO4J_ADDRESS")); // Default configuration if not provided
26+
$this->config = $config ?? new Configuration(baseUri: 'http://myaddress'); // Default configuration if not provided
2727
}
2828

2929
/**
3030
* @api
3131
*/
32-
public static function login(string $address, ?AuthenticateInterface $auth = null, ?Configuration $config = null): self
32+
public static function login(string $address = null, ?AuthenticateInterface $auth = null, ?Configuration $config = null): self
3333
{
3434
$client = new Client();
3535
$config = $config ?? new Configuration(baseUri: $address);

tests/Integration/Neo4jQueryAPITest.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,23 @@ public function testLoginWithEmptyAddress()
3636

3737
Neo4jQueryAPI::login('http://myaddress', Authentication::fromEnvironment(), $config);
3838
}
39-
/**
40-
* Test to ensure that an exception is thrown when baseUri is empty.
41-
*/
39+
public function testLoginWithNullConfiguration()
40+
{
41+
$config = null;
42+
43+
$api = Neo4jQueryAPI::login('http://myaddress', Authentication::fromEnvironment(), $config);
44+
45+
$this->assertInstanceOf(Neo4jQueryAPI::class, $api);$this->assertEquals('http://myaddress', $api->getConfig()->baseUri);
46+
}
47+
public function testConfigOnly()
48+
{
49+
$config = new COnfiguration(baseUri: 'http://valid.address');
50+
51+
$api = Neo4jQueryAPI::login(auth: Authentication::fromEnvironment(), config: $config);
52+
53+
$this->assertInstanceOf(Neo4jQueryAPI::class, $api);
54+
$this->assertEquals('http://valid.address', $api->getConfig()->baseUri);
55+
}
4256

4357

4458
}

0 commit comments

Comments
 (0)