Skip to content

Commit 283d369

Browse files
committed
test code
1 parent f5a1062 commit 283d369

File tree

3 files changed

+58
-6
lines changed

3 files changed

+58
-6
lines changed

.phpunit.result.cache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":1,"defects":{"Neo4j\\QueryAPI\\Tests\\Integration\\Neo4jQueryAPIIntegrationTest::testRunSuccessWithParameters#testWithPropertyExistenceCheck":7,"Neo4j\\QueryAPI\\Tests\\Integration\\Neo4jQueryAPIIntegrationTest::testRunSuccessWithParameters#testWithNumericFilters":8,"Neo4j\\QueryAPI\\Tests\\Integration\\Neo4jQueryAPIIntegrationTest::testRunSuccessWithParameters#testWithNestedRelationships":7,"Neo4j\\QueryAPI\\Tests\\Integration\\Neo4jQueryAPIIntegrationTest::testRunSuccessWithParameters#testWithMultipleConditions":7},"times":{"Neo4j\\QueryAPI\\Tests\\Integration\\Neo4jQueryAPIIntegrationTest::testRunSuccessWithParameters#0":0.393,"Neo4j\\QueryAPI\\Tests\\Integration\\Neo4jQueryAPIIntegrationTest::testRunSuccessWithParameters#testWithExactNames":0.356,"Neo4j\\QueryAPI\\Tests\\Integration\\Neo4jQueryAPIIntegrationTest::testRunSuccessWithParameters#testWithNoMatchingNames":0.327,"Neo4j\\QueryAPI\\Tests\\Integration\\Neo4jQueryAPIIntegrationTest::testRunSuccessWithParameters#testWithSingleName":0.4,"Neo4j\\QueryAPI\\Tests\\Integration\\Neo4jQueryAPIIntegrationTest::testRunSuccessWithParameters#testWithNonExistentLabel":0.355,"Neo4j\\QueryAPI\\Tests\\Integration\\Neo4jQueryAPIIntegrationTest::testRunSuccessWithParameters#testWithPropertyExistenceCheck":0.417,"Neo4j\\QueryAPI\\Tests\\Integration\\Neo4jQueryAPIIntegrationTest::testRunSuccessWithParameters#testWithNumericFilters":0.378,"Neo4j\\QueryAPI\\Tests\\Integration\\Neo4jQueryAPIIntegrationTest::testRunSuccessWithParameters#testWithSortingResults":0.371,"Neo4j\\QueryAPI\\Tests\\Integration\\Neo4jQueryAPIIntegrationTest::testRunSuccessWithParameters#testWithNestedRelationships":0.415,"Neo4j\\QueryAPI\\Tests\\Integration\\Neo4jQueryAPIIntegrationTest::testRunSuccessWithParameters#testWithMultipleConditions":0.396,"Neo4j\\QueryAPI\\Tests\\Integration\\Neo4jQueryAPIIntegrationTest::testRunSuccessWithParameters#testWithInvalidQuery":0.357,"Neo4j\\QueryAPI\\Tests\\Unit\\Neo4jQueryAPIUnitTest::testCorrectClientSetup":0.012,"Neo4j\\QueryAPI\\Tests\\Unit\\Neo4jQueryAPIUnitTest::testRunSuccess":0.007}}

tests/Integration/Neo4jQueryAPIIntegrationTest.php

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@
99

1010
class Neo4jQueryAPIIntegrationTest extends TestCase
1111
{
12-
1312
/**
1413
* @throws GuzzleException
1514
*/
1615
public static function setUpBeforeClass(): void
1716
{
1817
$api = Neo4jQueryAPI::login(
19-
'https://bb79fe35.databases.neo4j.io',
20-
'neo4j',
21-
'OXDRMgdWFKMcBRCBrIwXnKkwLgDlmFxipnywT6t_AK0'
18+
getenv('NEO4J_ADDRESS'),
19+
getenv('NEO4J_USERNAME'),
20+
getenv('NEO4J_PASSWORD')
2221
);
2322

2423
// Clear the database
@@ -94,7 +93,8 @@ public function testRunSuccessWithParameters(
9493
public static function queryProvider(): array
9594
{
9695
return [
97-
[
96+
// Basic test with exact names
97+
'testWithExactNames' => [
9898
'https://bb79fe35.databases.neo4j.io',
9999
'neo4j',
100100
'OXDRMgdWFKMcBRCBrIwXnKkwLgDlmFxipnywT6t_AK0',
@@ -107,6 +107,57 @@ public static function queryProvider(): array
107107
],
108108
],
109109
],
110+
111+
// Test with no matching names
112+
'testWithNoMatchingNames' => [
113+
'https://bb79fe35.databases.neo4j.io',
114+
'neo4j',
115+
'OXDRMgdWFKMcBRCBrIwXnKkwLgDlmFxipnywT6t_AK0',
116+
'MATCH (n:Person) WHERE n.name IN $names RETURN n.name',
117+
['names' => ['charlie', 'david']],
118+
[
119+
'data' => [],
120+
],
121+
],
122+
123+
// Test with a single name
124+
'testWithSingleName' => [
125+
'https://bb79fe35.databases.neo4j.io',
126+
'neo4j',
127+
'OXDRMgdWFKMcBRCBrIwXnKkwLgDlmFxipnywT6t_AK0',
128+
'MATCH (n:Person) WHERE n.name = $name RETURN n.name',
129+
['name' => 'bob1'],
130+
[
131+
'data' => [
132+
['row' => ['n.name' => 'bob1']],
133+
],
134+
],
135+
],
136+
137+
// Test for non-existent label
138+
'testWithNonExistentLabel' => [
139+
'https://bb79fe35.databases.neo4j.io',
140+
'neo4j',
141+
'OXDRMgdWFKMcBRCBrIwXnKkwLgDlmFxipnywT6t_AK0',
142+
'MATCH (n:NonExistentLabel) RETURN n',
143+
[],
144+
[
145+
'data' => [],
146+
],
147+
],
148+
149+
150+
// Test with an invalid query that should return an error
151+
'testWithInvalidQuery' => [
152+
'https://bb79fe35.databases.neo4j.io',
153+
'neo4j',
154+
'OXDRMgdWFKMcBRCBrIwXnKkwLgDlmFxipnywT6t_AK0',
155+
'MATCH (n:Person) WHERE n.nonexistentProperty = $value RETURN n.name',
156+
['value' => 'someValue'],
157+
[
158+
'data' => [],
159+
],
160+
],
110161
];
111162
}
112163
}

tests/Unit/Neo4jQueryAPIUnitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function testRunSuccess(): void
6060

6161
$result = $neo4jQueryAPI->run($cypherQuery, []);
6262

63-
// print_r($result);
63+
print_r($result);
6464

6565
$this->assertEquals(['hello' => 'world'], $result);
6666
}

0 commit comments

Comments
 (0)