Skip to content

Commit 19310e7

Browse files
committed
Fix version incompatibilities in QueryException
1 parent f6e4b6a commit 19310e7

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

tests/Unit/Mutex/MutexRelayTest.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Contracts\Cache\LockTimeoutException;
99
use Illuminate\Database\QueryException;
1010
use Illuminate\Filesystem\Filesystem;
11+
use Illuminate\Foundation\Application;
1112
use Netsells\LaravelMutexMigrations\Mutex\DatabaseCacheTableNotFoundException;
1213
use Netsells\LaravelMutexMigrations\Mutex\MutexRelay;
1314
use Netsells\LaravelMutexMigrations\Tests\Unit\Mutex\Fixtures\TestPDOException;
@@ -41,11 +42,7 @@ public function testAcquireLockHandlesMissingCacheTable(): void
4142

4243
$store->expects($this->once())
4344
->method('lock')
44-
->willThrowException(new QueryException(
45-
'select * from ' . MutexRelay::DEFAULT_LOCK_TABLE,
46-
[],
47-
new TestPDOException('Base table or view not found', '42S02')
48-
));
45+
->willThrowException($this->getQueryException());
4946

5047
$this->expectException(DatabaseCacheTableNotFoundException::class);
5148

@@ -110,4 +107,19 @@ public function testReleaseLockUnblocksOtherRelays(): void
110107

111108
$this->assertTrue($relay2->acquireLock());
112109
}
110+
111+
private function getQueryException(): QueryException
112+
{
113+
$arguments = [
114+
'select * from ' . MutexRelay::DEFAULT_LOCK_TABLE,
115+
[],
116+
new TestPDOException('Base table or view not found', '42S02')
117+
];
118+
119+
if (version_compare(Application::VERSION, '10.0.0', '>=')) {
120+
array_unshift($arguments, 'test-connection');
121+
}
122+
123+
return new QueryException(...$arguments);
124+
}
113125
}

0 commit comments

Comments
 (0)