From 64d5f4436fc8682fa7fa4e3bc604f307535bb317 Mon Sep 17 00:00:00 2001 From: tpetry Date: Fri, 13 Sep 2024 12:55:28 +0200 Subject: [PATCH] fix: query exception had different parameters in old versions --- tests/MysqlExplainTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/MysqlExplainTest.php b/tests/MysqlExplainTest.php index 0100419..494d697 100644 --- a/tests/MysqlExplainTest.php +++ b/tests/MysqlExplainTest.php @@ -6,6 +6,7 @@ use Illuminate\Database\ConnectionInterface; use Illuminate\Database\QueryException; +use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\DB; use Mockery\MockInterface; use RuntimeException; @@ -45,7 +46,10 @@ public function testSubmitQueryCollectsMetricsAndSubmitsThem(): void ->andReturn('mysql'); $mock->shouldReceive('queryScalar') ->withArgs([$connection, 'SELECT * FROM seq_1_to_1']) - ->andThrow(new QueryException("SQLSTATE[42S02]: Base table or view not found: 1146 Table 'seq_1_to_1' doesn't exist.", 'SELECT * FROM seq_1_to_1', [], new RuntimeException)); + ->andThrow(match (true) { + version_compare(App::version(), '10.0.0', '>=') => new QueryException('mysql', 'SELECT * FROM seq_1_to_1', [], new RuntimeException), + default => new QueryException('SELECT * FROM seq_1_to_1', [], new RuntimeException) + }); $mock->shouldReceive('queryScalar') ->withArgs([$connection, 'SELECT VERSION()']) ->andReturn('...version...');