|
8 | 8 | use Illuminate\Contracts\Cache\LockTimeoutException; |
9 | 9 | use Illuminate\Database\QueryException; |
10 | 10 | use Illuminate\Filesystem\Filesystem; |
| 11 | +use Illuminate\Foundation\Application; |
11 | 12 | use Netsells\LaravelMutexMigrations\Mutex\DatabaseCacheTableNotFoundException; |
12 | 13 | use Netsells\LaravelMutexMigrations\Mutex\MutexRelay; |
13 | 14 | use Netsells\LaravelMutexMigrations\Tests\Unit\Mutex\Fixtures\TestPDOException; |
@@ -41,11 +42,7 @@ public function testAcquireLockHandlesMissingCacheTable(): void |
41 | 42 |
|
42 | 43 | $store->expects($this->once()) |
43 | 44 | ->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()); |
49 | 46 |
|
50 | 47 | $this->expectException(DatabaseCacheTableNotFoundException::class); |
51 | 48 |
|
@@ -110,4 +107,19 @@ public function testReleaseLockUnblocksOtherRelays(): void |
110 | 107 |
|
111 | 108 | $this->assertTrue($relay2->acquireLock()); |
112 | 109 | } |
| 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 | + } |
113 | 125 | } |
0 commit comments