From a6dd03951876d522e778b897fd58d6f3433ecde4 Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Tue, 21 Feb 2023 19:46:12 -0300 Subject: [PATCH] Show "error" on failed statements --- src/Database.php | 2 +- tests/Debug/DatabaseCollectorTest.php | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Database.php b/src/Database.php index cff5961..b18b4d6 100644 --- a/src/Database.php +++ b/src/Database.php @@ -792,7 +792,7 @@ protected function finalizeAddToDebug( ) : void { $end = \microtime(true); $rows = $this->mysqli->affected_rows; - $rows = $rows < 0 ? $rows . ' (failed)' : $rows; + $rows = $rows < 0 ? 'error' : $rows; $this->debugCollector->addData([ 'start' => $start, 'end' => $end, diff --git a/tests/Debug/DatabaseCollectorTest.php b/tests/Debug/DatabaseCollectorTest.php index d9cb8ea..d618778 100644 --- a/tests/Debug/DatabaseCollectorTest.php +++ b/tests/Debug/DatabaseCollectorTest.php @@ -130,6 +130,12 @@ public function testFinalizeAddToDebug() : void $data = $this->collector->getData(); $data = $data[\array_key_last($data)]; self::assertSame('Foo Bar', $data['statement']); - self::assertSame('-1 (failed)', $data['rows']); + self::assertSame('error', $data['rows']); + $contents = $this->collector->getContents(); + self::assertStringContainsString('error', $contents); + self::assertStringContainsString( + \htmlentities($data['description']), + $contents + ); } }