diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index c01b882..2b9d4cc 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -12,7 +12,7 @@ jobs: fail-fast: false matrix: php: ['8.1'] - laravel: ['^9.1'] + laravel: ['^9.1', '^10.0'] steps: - name: Checkout the repo diff --git a/composer.json b/composer.json index d529cc7..6ea45c2 100644 --- a/composer.json +++ b/composer.json @@ -21,10 +21,10 @@ ], "require": { "php": "^8.1", - "laravel/framework": "^9.3" + "laravel/framework": "^9.3 || ^10.0" }, "require-dev": { - "orchestra/testbench": "^7.7", + "orchestra/testbench": "^7.7 || ^8.0", "spatie/fork": "^1.1" }, "autoload": { diff --git a/tests/Integration/AbstractIntegrationTest.php b/tests/Integration/AbstractIntegrationTestCase.php similarity index 83% rename from tests/Integration/AbstractIntegrationTest.php rename to tests/Integration/AbstractIntegrationTestCase.php index 94c7fdc..ad2f97b 100644 --- a/tests/Integration/AbstractIntegrationTest.php +++ b/tests/Integration/AbstractIntegrationTestCase.php @@ -5,7 +5,7 @@ use Netsells\LaravelMutexMigrations\ServiceProvider; use Orchestra\Testbench\TestCase; -abstract class AbstractIntegrationTest extends TestCase +abstract class AbstractIntegrationTestCase extends TestCase { protected function getPackageProviders($app): array { diff --git a/tests/Integration/CommandConcurrencyTest.php b/tests/Integration/CommandConcurrencyTest.php index eca933e..29c3bb1 100644 --- a/tests/Integration/CommandConcurrencyTest.php +++ b/tests/Integration/CommandConcurrencyTest.php @@ -6,7 +6,7 @@ use Illuminate\Contracts\Console\Kernel; use Spatie\Fork\Fork; -class CommandConcurrencyTest extends AbstractIntegrationTest +class CommandConcurrencyTest extends AbstractIntegrationTestCase { public function testCommandCanBeCalledConcurrently(): void { diff --git a/tests/Unit/Mutex/MutexRelayTest.php b/tests/Unit/Mutex/MutexRelayTest.php index c21ce53..fc70597 100644 --- a/tests/Unit/Mutex/MutexRelayTest.php +++ b/tests/Unit/Mutex/MutexRelayTest.php @@ -8,6 +8,7 @@ use Illuminate\Contracts\Cache\LockTimeoutException; use Illuminate\Database\QueryException; use Illuminate\Filesystem\Filesystem; +use Illuminate\Foundation\Application; use Netsells\LaravelMutexMigrations\Mutex\DatabaseCacheTableNotFoundException; use Netsells\LaravelMutexMigrations\Mutex\MutexRelay; use Netsells\LaravelMutexMigrations\Tests\Unit\Mutex\Fixtures\TestPDOException; @@ -41,11 +42,7 @@ public function testAcquireLockHandlesMissingCacheTable(): void $store->expects($this->once()) ->method('lock') - ->willThrowException(new QueryException( - 'select * from ' . MutexRelay::DEFAULT_LOCK_TABLE, - [], - new TestPDOException('Base table or view not found', '42S02') - )); + ->willThrowException($this->getQueryException()); $this->expectException(DatabaseCacheTableNotFoundException::class); @@ -110,4 +107,19 @@ public function testReleaseLockUnblocksOtherRelays(): void $this->assertTrue($relay2->acquireLock()); } + + private function getQueryException(): QueryException + { + $arguments = [ + 'select * from ' . MutexRelay::DEFAULT_LOCK_TABLE, + [], + new TestPDOException('Base table or view not found', '42S02') + ]; + + if (version_compare(Application::VERSION, '10.0.0', '>=')) { + array_unshift($arguments, 'test-connection'); + } + + return new QueryException(...$arguments); + } }