Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/integration-test-aura.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
run: |
echo "PHP_VERSION=8.1.31" > .env
echo "CONNECTION=\"${{ secrets.AURA_PRO }}\"" >> .env
echo "CI=true" >> .env

- name: Cache PHP deps
id: cache-php-deps
Expand All @@ -51,4 +52,4 @@ jobs:
run: docker compose run --rm client composer install

- name: Run tests
run: docker compose run --rm client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration
run: docker compose run --rm client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration --teamcity
3 changes: 2 additions & 1 deletion .github/workflows/integration-test-cluster-neo4j-4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
run: |
echo "PHP_VERSION=${{ matrix.php }}" > .env
echo "CONNECTION=neo4j://neo4j:testtest@server1" >> .env
echo "CI=true" >> .env

- name: Cache PHP deps
id: cache-php-deps
Expand All @@ -78,4 +79,4 @@ jobs:
server4

docker compose -f docker-compose-neo4j-4.yml run --rm client \
./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration
./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration --teamcity
3 changes: 2 additions & 1 deletion .github/workflows/integration-test-cluster-neo4j-5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
run: |
echo "PHP_VERSION=${{ matrix.php }}" > .env
echo "CONNECTION=neo4j://neo4j:testtest@server1" >> .env
echo "CI=true" >> .env

- name: Cache PHP deps
id: cache-php-deps
Expand All @@ -79,4 +80,4 @@ jobs:

# install PHP deps and run PHPUnit inside the client container
docker compose run --rm client \
./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration
./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration --teamcity
13 changes: 9 additions & 4 deletions .github/workflows/integration-test-single-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
- name: Populate .env
run: |
echo "PHP_VERSION=${{ matrix.php }}" > .env
echo "CI=true" >> .env

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand Down Expand Up @@ -72,17 +73,19 @@ jobs:

echo "PHP_VERSION=${{ matrix.php }}" > .env
echo "CONNECTION=bolt://neo4j:testtest@neo4j" >> .env
echo "CI=true" >> .env

docker compose -f docker-compose-neo4j-4.yml up -d --build --remove-orphans --wait neo4j

docker compose -f docker-compose-neo4j-4.yml run --rm \
client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration
client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration --teamcity

echo "PHP_VERSION=${{ matrix.php }}" > .env
echo "CONNECTION=neo4j://neo4j:testtest@neo4j" >> .env
echo "CI=true" >> .env

docker compose -f docker-compose-neo4j-4.yml run --rm \
client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration
client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration --teamcity

tests-v5:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -132,16 +135,18 @@ jobs:
run: |
echo "PHP_VERSION=${{ matrix.php }}" > .env
echo "CONNECTION=bolt://neo4j:testtest@neo4j" >> .env
echo "CI=true" >> .env

docker compose up -d --build --remove-orphans --wait neo4j

docker compose run --rm \
client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration
client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration --teamcity

echo "PHP_VERSION=${{ matrix.php }}" > .env
echo "CONNECTION=neo4j://neo4j:testtest@neo4j" >> .env
echo "CI=true" >> .env

docker compose run --rm \
client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration
client ./vendor/bin/phpunit -c phpunit.xml.dist --testsuite Integration --teamcity

docker compose down --remove-orphans --volumes
96 changes: 66 additions & 30 deletions src/Databags/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,60 +13,96 @@

namespace Laudis\Neo4j\Databags;

/**
* Representation for notifications found when executing a query. A notification can be visualized in a client pinpointing problems or other information about the query.
*
* @psalm-immutable
*/
use InvalidArgumentException;

final class Notification
{
public function __construct(
private readonly string $code,
private readonly string $description,
private readonly ?InputPosition $inputPosition,
private readonly string $severity,
private readonly string $title,
private string $severity,
private string $description,
private string $code,
private Position $position,
private string $title,
private string $category,
) {
}

/**
* Returns a notification code for the discovered issue.
* @throws InvalidArgumentException
*
* @return array{classification: string, category: string, title: string}
*/
public function getCode(): string
private function splitCode(): array
{
return $this->code;
$parts = explode('.', $this->code, 4);
if (count($parts) < 4) {
throw new InvalidArgumentException('Invalid message exception code');
}

return [
'classification' => $parts[1],
'category' => $parts[2],
'title' => $parts[3],
];
}

/**
* Returns a longer description of the notification.
*/
public function getDescription(): string
public function getCodeClassification(): string
{
return $this->description;
return $this->splitCode()['classification'];
}

/**
* The position in the query where this notification points to.
* Not all notifications have a unique position to point to and in that case the position would be set to null.
*/
public function getInputPosition(): ?InputPosition
public function getCodeCategory(): string
{
return $this->inputPosition;
return $this->splitCode()['category'];
}

public function getCodeTitle(): string
{
return $this->splitCode()['title'];
}

/**
* The severity level of the notification.
*/
public function getSeverity(): string
{
return $this->severity;
}

/**
* Returns a short summary of the notification.
*/
public function getDescription(): string
{
return $this->description;
}

public function getCode(): string
{
return $this->code;
}

public function getPosition(): Position
{
return $this->position;
}

public function getTitle(): string
{
return $this->title;
}

public function getCategory(): string
{
return $this->category;
}

/**
* @psalm-external-mutation-free
*/
public function toArray(): array
{
return [
'severity' => $this->severity,
'description' => $this->description,
'code' => $this->code,
'position' => $this->position->toArray(),
'title' => $this->title,
'category' => $this->category,
];
}
}
41 changes: 15 additions & 26 deletions src/Databags/Plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,60 +13,49 @@

namespace Laudis\Neo4j\Databags;

use Laudis\Neo4j\Types\AbstractCypherObject;
use Laudis\Neo4j\Types\CypherList;
use Laudis\Neo4j\Types\CypherMap;

/**
* This describes the plan that the database planner produced and used (or will use) to execute your query.
*
* @see https://neo4j.com/docs/cypher-manual/current/execution-plans/
*
* @psalm-immutable
*
* @extends AbstractCypherObject<string, mixed>
*/
final class Plan extends AbstractCypherObject
final class Plan
{
/**
* @param CypherMap<mixed> $arguments
* @param CypherList<Plan> $list
* @param CypherList<string> $identifiers
* @param list<Plan> $children
* @param list<string> $identifiers
*/
public function __construct(
private readonly CypherMap $arguments,
private readonly CypherList $list,
private readonly CypherList $identifiers,
private readonly PlanArguments $args,
private readonly array $children,
private readonly array $identifiers,
private readonly string $operator,
) {
}

/**
* Returns the arguments for the operator.
*
* @return CypherMap<mixed>
*/
public function getArguments(): CypherMap
public function getArgs(): PlanArguments
{
return $this->arguments;
return $this->args;
}

/**
* Returns the sub-plans.
*
* @return CypherList<Plan>
* @return list<Plan>
*/
public function getList(): CypherList
public function getChildren(): array
{
return $this->list;
return $this->children;
}

/**
* Identifiers used by this part of the plan.
*
* @return CypherList<string>
* @return list<string>
*/
public function getIdentifiers(): CypherList
public function getIdentifiers(): array
{
return $this->identifiers;
}
Expand All @@ -82,8 +71,8 @@ public function getOperator(): string
public function toArray(): array
{
return [
'arguments' => $this->arguments,
'list' => $this->list,
'arguments' => $this->args,
'list' => $this->children,
'identifiers' => $this->identifiers,
'operator' => $this->operator,
];
Expand Down
70 changes: 70 additions & 0 deletions src/Databags/PlanArguments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Neo4j PHP Client and Driver package.
*
* (c) Nagels <https://nagels.tech>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Laudis\Neo4j\Databags;

final class PlanArguments
{
public function __construct(
public readonly ?int $globalMemory = null,
public readonly ?string $plannerImpl = null,
public readonly ?int $memory = null,
public readonly ?string $stringRepresentation = null,
public readonly ?string $runtime = null,
public readonly ?int $time = null,
public readonly ?int $pageCacheMisses = null,
public readonly ?int $pageCacheHits = null,
public readonly ?string $runtimeImpl = null,
public readonly ?string $version = null,
public readonly ?int $dbHits = null,
public readonly ?int $batchSize = null,
public readonly ?string $details = null,
public readonly ?string $plannerVersion = null,
public readonly ?string $pipelineInfo = null,
public readonly string|float|null $runtimeVersion = null,
public readonly ?int $id = null,
public readonly ?float $estimatedRows = null,
public readonly ?string $planner = null,
public readonly ?int $rows = null,
) {
}

/**
* @psalm-external-mutation-free
*/
public function toArray(): array
{
return [
'globalMemory' => $this->globalMemory,
'plannerImpl' => $this->plannerImpl,
'memory' => $this->memory,
'stringRepresentation' => $this->stringRepresentation,
'runtime' => $this->runtime,
'time' => $this->time,
'pageCacheMisses' => $this->pageCacheMisses,
'pageCacheHits' => $this->pageCacheHits,
'runtimeImpl' => $this->runtimeImpl,
'version' => $this->version,
'dbHits' => $this->dbHits,
'batchSize' => $this->batchSize,
'details' => $this->details,
'plannerVersion' => $this->plannerVersion,
'pipelineInfo' => $this->pipelineInfo,
'runtimeVersion' => $this->runtimeVersion,
'id' => $this->id,
'estimatedRows' => $this->estimatedRows,
'planner' => $this->planner,
'rows' => $this->rows,
];
}
}
Loading
Loading