Skip to content

Commit 594b3d8

Browse files
committed
cleanup object model
1 parent 752259a commit 594b3d8

File tree

8 files changed

+26
-14
lines changed

8 files changed

+26
-14
lines changed

src/Types/CypherList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,9 @@ public function getAsWGS843DPoint(int $key): WGS843DPoint
338338
return $this->getAsObject($key, WGS843DPoint::class);
339339
}
340340

341-
public function key(): string
341+
public function key(): int
342342
{
343-
/** @var string */
343+
/** @var int */
344344
return $this->cacheKey();
345345
}
346346

src/Types/CypherMap.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,9 @@ public function getAsWGS843DPoint(string $key): WGS843DPoint
572572

573573
public function key(): string
574574
{
575-
/** @var string */
576-
return $this->cacheKey();
575+
// we have to cast to a string, as the value is potentially an integer if the key is numeric:
576+
// https://stackoverflow.com/questions/4100488/a-numeric-string-as-array-key-in-php
577+
return (string) $this->cacheKey();
577578
}
578579

579580
/**

src/Types/CypherSequenceTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public function next(): void
366366

367367
protected function cacheKey(): string|int
368368
{
369-
return (string) $this->keyCache[$this->currentPosition % max($this->cacheLimit, 1)];
369+
return $this->keyCache[$this->currentPosition % max($this->cacheLimit, 1)];
370370
}
371371

372372
/**

testkit-backend/src/Handlers/AbstractRunner.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Laudis\Neo4j\TestkitBackend\Responses\FrontendErrorResponse;
2525
use Laudis\Neo4j\TestkitBackend\Responses\ResultResponse;
2626
use Laudis\Neo4j\Types\AbstractCypherObject;
27+
use Laudis\Neo4j\Types\CypherList;
2728
use Laudis\Neo4j\Types\CypherMap;
2829
use Psr\Log\LoggerInterface;
2930
use Symfony\Component\Uid\Uuid;
@@ -106,7 +107,7 @@ private function decodeToValue(array $param)
106107
$list[] = $this->decodeToValue($v);
107108
}
108109

109-
return new CypherMap($list);
110+
return new CypherList($list);
110111
}
111112
}
112113

testkit-backend/src/Responses/Types/CypherNode.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ final class CypherNode implements TestkitResponseInterface
2020
private CypherObject $id;
2121
private CypherObject $labels;
2222
private CypherObject $props;
23+
private CypherObject $elementId;
2324

24-
public function __construct(CypherObject $id, CypherObject $labels, CypherObject $props)
25+
public function __construct(CypherObject $id, CypherObject $labels, CypherObject $props, CypherObject $elementId)
2526
{
2627
$this->id = $id;
2728
$this->labels = $labels;
2829
$this->props = $props;
30+
$this->elementId = $elementId;
2931
}
3032

3133
public function jsonSerialize(): array
@@ -36,6 +38,7 @@ public function jsonSerialize(): array
3638
'id' => $this->id,
3739
'labels' => $this->labels,
3840
'props' => $this->props,
41+
'elementId' => $this->elementId,
3942
],
4043
];
4144
}

testkit-backend/src/Responses/Types/CypherObject.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ public static function autoDetect($value): TestkitResponseInterface
107107
$tbr = new CypherNode(
108108
new CypherObject('CypherInt', $value->getId()),
109109
new CypherObject('CypherList', new CypherList($labels)),
110-
new CypherObject('CypherMap', new CypherMap($props))
110+
new CypherObject('CypherMap', new CypherMap($props)),
111+
new CypherObject('CypherString', $value->getElementId())
111112
);
112113
break;
113114
case Relationship::class:
@@ -123,6 +124,7 @@ public static function autoDetect($value): TestkitResponseInterface
123124
new CypherObject('CypherInt', $value->getEndNodeId()),
124125
new CypherObject('CypherString', $value->getType()),
125126
new CypherObject('CypherMap', new CypherMap($props)),
127+
new CypherObject('CypherString', $value->getElementId())
126128
);
127129
break;
128130
case Path::class:
@@ -157,7 +159,8 @@ public static function autoDetect($value): TestkitResponseInterface
157159
new CypherObject('CypherNull', null),
158160
new CypherObject('CypherNull', null),
159161
new CypherObject('CypherString', $value->getType()),
160-
new CypherObject('CypherMap', new CypherMap($props))
162+
new CypherObject('CypherMap', new CypherMap($props)),
163+
new CypherObject('CypherString', $value->getElementId())
161164
);
162165
break;
163166
default:

testkit-backend/src/Responses/Types/CypherRelationship.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ final class CypherRelationship implements TestkitResponseInterface
2222
private CypherObject $endNodeId;
2323
private CypherObject $type;
2424
private CypherObject $props;
25+
private CypherObject $elementId;
2526

26-
public function __construct(CypherObject $id, CypherObject $startNodeId, CypherObject $endNodeId, CypherObject $type, CypherObject $props)
27+
public function __construct(CypherObject $id, CypherObject $startNodeId, CypherObject $endNodeId, CypherObject $type, CypherObject $props, CypherObject $elementId)
2728
{
2829
$this->id = $id;
2930
$this->startNodeId = $startNodeId;
3031
$this->endNodeId = $endNodeId;
3132
$this->type = $type;
3233
$this->props = $props;
34+
$this->elementId = $elementId;
3335
}
3436

3537
public function jsonSerialize(): array
@@ -42,6 +44,7 @@ public function jsonSerialize(): array
4244
'endNodeId' => $this->endNodeId,
4345
'type' => $this->type,
4446
'props' => $this->props,
47+
'elementId' => $this->elementId,
4548
],
4649
];
4750
}

testkit-backend/testkit.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ pip install -r requirements.txt
3434
echo "Starting tests..."
3535
# exec python3 main.py --tests UNIT_TESTS
3636
(exec python3 -m unittest tests.neo4j.test_authentication.TestAuthenticationBasic) || true
37-
echo "TestAuthenticationBasic Done"
38-
(exec python3 -m unittest tests.neo4j.test_bookmarks.TestBookmarks) || true
37+
#echo "TestAuthenticationBasic Done"
38+
python3 -m unittest tests.neo4j.test_bookmarks.TestBookmarks || true
3939
echo "TestBookmarks Done"
40-
(exec python3 -m unittest tests.neo4j.test_session_run.TestSessionRun.test_iteration_nested) || true
41-
echo "TestSessionRun Done"
40+
#python3 -m unittest tests.neo4j.test_session_run.TestSessionRun.test_recover_from_fail_on_streaming|| true
41+
#echo "TestSessionRun Done"
42+

0 commit comments

Comments
 (0)