From 772ee905fcf826911e2710c2ecef81d6d1d7706a Mon Sep 17 00:00:00 2001 From: Ghlen Nagels Date: Wed, 9 Oct 2024 14:49:23 +0530 Subject: [PATCH] fix http tests --- src/Http/HttpHelper.php | 2 +- .../SummarizedResultFormatterTest.php | 4 ++++ .../Integration/TransactionIntegrationTest.php | 18 ++++++++++++++---- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Http/HttpHelper.php b/src/Http/HttpHelper.php index 3212dba5..822e6880 100644 --- a/src/Http/HttpHelper.php +++ b/src/Http/HttpHelper.php @@ -49,7 +49,7 @@ final class HttpHelper */ public static function interpretResponse(ResponseInterface $response): stdClass { - if ($response->getStatusCode() >= 400) { + if ($response->getStatusCode() >= 500) { throw new RuntimeException('HTTP Error: '.$response->getReasonPhrase()); } diff --git a/tests/Integration/SummarizedResultFormatterTest.php b/tests/Integration/SummarizedResultFormatterTest.php index 60bfaf2c..b42d291b 100644 --- a/tests/Integration/SummarizedResultFormatterTest.php +++ b/tests/Integration/SummarizedResultFormatterTest.php @@ -104,6 +104,10 @@ public function testAvailableAfter(): void public function testDateTime(): void { + if (str_starts_with($_ENV['CONNECTION'] ?? '', 'http')) { + $this->markTestSkipped('http does not support datetime conversion'); + } + $dt = new DateTimeImmutable(); $ls = $this->getSession()->run('RETURN $x AS x', ['x' => $dt])->first()->get('x'); diff --git a/tests/Integration/TransactionIntegrationTest.php b/tests/Integration/TransactionIntegrationTest.php index 4d5f0a59..e575129b 100644 --- a/tests/Integration/TransactionIntegrationTest.php +++ b/tests/Integration/TransactionIntegrationTest.php @@ -226,10 +226,15 @@ public function testCommitInvalid(): void $exception = null; try { $tsx->commit(); - } catch (ClientException $e) { + } catch (ClientException|Neo4jException $e) { $exception = $e; } - self::assertTrue($exception instanceof ClientException); + + if (str_starts_with($_ENV['CONNECTION'] ?? '', 'http')) { + self::assertTrue($exception instanceof Neo4jException); + } else { + self::assertTrue($exception instanceof ClientException); + } self::assertTrue($tsx->isFinished()); self::assertFalse($tsx->isRolledBack()); @@ -259,10 +264,15 @@ public function testRollbackInvalid(): void $exception = null; try { $tsx->rollback(); - } catch (ClientException $e) { + } catch (ClientException|Neo4jException $e) { $exception = $e; } - self::assertTrue($exception instanceof ClientException); + + if (str_starts_with($_ENV['CONNECTION'] ?? '', 'http')) { + self::assertTrue($exception instanceof Neo4jException); + } else { + self::assertTrue($exception instanceof ClientException); + } self::assertTrue($tsx->isFinished()); self::assertTrue($tsx->isRolledBack());