diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 07d41b7..ac9fbbe 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,13 +13,7 @@ jobs: tests: runs-on: ubuntu-22.04 - strategy: - fail-fast: true - matrix: - php: [8.3, 8.4] - doppar: [2] - - name: PHP ${{ matrix.php }} - Doppar ${{ matrix.doppar }} + name: PHP 8.5 steps: - name: Checkout code @@ -28,7 +22,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php }} + php-version: '8.5' extensions: dom, curl, libxml, mbstring, zip ini-values: error_reporting=E_ALL tools: composer:v2 diff --git a/composer.json b/composer.json index 8fbc7d2..88c9102 100644 --- a/composer.json +++ b/composer.json @@ -15,8 +15,8 @@ ], "require-dev": { "mockery/mockery": "^1.6", - "phpunit/phpunit": "^12.1.5", - "doppar/framework": "3.*" + "phpunit/phpunit": "^13.3", + "doppar/framework": "4.*" }, "autoload": { "psr-4": { @@ -28,19 +28,13 @@ "Doppar\\Queue\\Tests\\": "tests/" } }, - "extra": { - "doppar": { - "providers": [ - "Doppar\\Queue\\QueueServiceProvider" - ] - } - }, "config": { "sort-packages": true }, "minimum-stability": "dev", "require": { - "opis/closure": "^4.4" + "php": "^8.5", + "opis/closure": "^4.5" }, "prefer-stable": true } \ No newline at end of file diff --git a/src/Commands/MakeJobCommand.php b/src/Commands/MakeJobCommand.php index aa3c054..30bfe5b 100644 --- a/src/Commands/MakeJobCommand.php +++ b/src/Commands/MakeJobCommand.php @@ -37,7 +37,7 @@ public function handle(): int $namespace = 'App\\Jobs' . (count($parts) > 0 ? '\\' . implode('\\', $parts) : ''); $fileName = count($parts) > 0 ? implode('/', $parts) . '/' . $className : $className; - $filePath = $this->generatedFilePath('app/Jobs', $fileName); + $filePath = $this->generatedFilePath('src/Jobs', $fileName); // Check if Job already exists if (file_exists($filePath)) { diff --git a/src/InteractsWithModelSerialization.php b/src/InteractsWithModelSerialization.php index ebadf8d..1ca9483 100644 --- a/src/InteractsWithModelSerialization.php +++ b/src/InteractsWithModelSerialization.php @@ -33,7 +33,6 @@ public function __serialize(): array $properties = $reflection->getProperties(); foreach ($properties as $property) { - $property->setAccessible(true); if (!$property->isInitialized($this)) { continue; @@ -79,7 +78,6 @@ public function __unserialize(array $values): void } $property = $reflection->getProperty($name); - $property->setAccessible(true); // Restore serialized models if (is_array($value) && isset($value['__serialized_model__'])) { @@ -128,7 +126,6 @@ protected function getModelConnection(Model $model): ?string try { $reflection = new \ReflectionClass($model); $property = $reflection->getProperty('connection'); - $property->setAccessible(true); return $property->getValue($model); } catch (\ReflectionException $e) { return null; @@ -172,7 +169,6 @@ protected function getCollectionModelClass(Collection $collection): ?string try { $reflection = new \ReflectionClass($collection); $property = $reflection->getProperty('modelClass'); - $property->setAccessible(true); return $property->getValue($collection); } catch (\ReflectionException $e) { // If we can't get the modelClass, try to infer from first item @@ -373,7 +369,6 @@ public function __wakeup(): void $reflection = new \ReflectionClass($this); foreach ($reflection->getProperties() as $property) { - $property->setAccessible(true); if ($property->isInitialized($this)) { $values[$property->getName()] = $property->getValue($this); } diff --git a/src/QueueServiceProvider.php b/src/QueueLauncher.php similarity index 81% rename from src/QueueServiceProvider.php rename to src/QueueLauncher.php index adc79fe..aa5c182 100644 --- a/src/QueueServiceProvider.php +++ b/src/QueueLauncher.php @@ -3,8 +3,8 @@ namespace Doppar\Queue; use Doppar\Queue\Commands\MakeJobCommand; -use Phaseolies\Providers\GhostableProvider; -use Phaseolies\Providers\ServiceProvider; +use Phaseolies\Launchers\GhostableLauncher; +use Phaseolies\Launchers\ServiceLauncher; use Doppar\Queue\QueueManager; use Doppar\Queue\Commands\QueueRunCommand; use Doppar\Queue\Commands\QueueRetryCommand; @@ -12,7 +12,7 @@ use Doppar\Queue\Commands\QueueFailedCommand; use Doppar\Queue\Commands\QueueMonitorCommand; -class QueueServiceProvider extends ServiceProvider implements GhostableProvider +class QueueLauncher extends ServiceLauncher implements GhostableLauncher { /** * Register any application services. @@ -29,12 +29,12 @@ public function register(): void * * @return void */ - public function boot(): void + public function launch(): void { $this->loadMigrations(__DIR__ . '/database/migrations'); $this->publishes([ - __DIR__ . '/database/migrations' => database_path('migrations'), + __DIR__ . '/database/migrations' => schema_path('migrations'), ], 'migrations'); $this->commands([ diff --git a/tests/Unit/MakeJobCommandTest.php b/tests/Unit/MakeJobCommandTest.php index c55b2f1..7353157 100644 --- a/tests/Unit/MakeJobCommandTest.php +++ b/tests/Unit/MakeJobCommandTest.php @@ -86,7 +86,7 @@ protected function relativePath(string $path, ?string $basePath = null): string }; $result = $command->handle(); - $file = $this->tempRoot . '/app/Jobs/Reports/GenerateDailyJob.php'; + $file = $this->tempRoot . '/src/Jobs/Reports/GenerateDailyJob.php'; $contents = (string) file_get_contents($file); $this->assertSame(0, $result); @@ -95,7 +95,7 @@ protected function relativePath(string $path, ?string $basePath = null): string $this->assertStringContainsString('class GenerateDailyJob extends Job', $contents); $this->assertContains('Job created successfully', $command->capturedSuccesses); $this->assertContains( - '📦 File: app/Jobs/Reports/GenerateDailyJob.php', + '📦 File: src/Jobs/Reports/GenerateDailyJob.php', $command->capturedLines ); } diff --git a/tests/Unit/ModelSerializationTest.php b/tests/Unit/ModelSerializationTest.php index 25b23e0..7eabb0a 100644 --- a/tests/Unit/ModelSerializationTest.php +++ b/tests/Unit/ModelSerializationTest.php @@ -171,9 +171,7 @@ private function setStaticProperty(string $className, string $propertyName, $val try { $reflection = new \ReflectionClass($className); $property = $reflection->getProperty($propertyName); - $property->setAccessible(true); $property->setValue(null, $value); - $property->setAccessible(false); } catch (\ReflectionException $e) { $this->fail("Failed to set static property {$propertyName}: " . $e->getMessage()); } @@ -239,7 +237,6 @@ public function testUnserializeSingleModel(): void // Access the user property using reflection (it's protected) $reflection = new \ReflectionClass($unserializedJob); $property = $reflection->getProperty('user'); - $property->setAccessible(true); $restoredUser = $property->getValue($unserializedJob); // Verify user is a fresh instance from database @@ -278,7 +275,6 @@ public function testModelDataFreshnessAfterSerialization(): void // Get the user from the job $reflection = new \ReflectionClass($unserializedJob); $property = $reflection->getProperty('user'); - $property->setAccessible(true); $restoredUser = $property->getValue($unserializedJob); // Verify we got the updated data, not stale data @@ -312,7 +308,6 @@ public function testDeletedModelReturnsNull(): void // Get user from job $reflection = new \ReflectionClass($unserializedJob); $property = $reflection->getProperty('user'); - $property->setAccessible(true); $restoredUser = $property->getValue($unserializedJob); // User should be null @@ -807,7 +802,6 @@ public function testModelUpdateBetweenDispatchAndExecution(): void // Get the restored user $reflection = new \ReflectionClass($unserializedJob); $property = $reflection->getProperty('user'); - $property->setAccessible(true); $restoredUser = $property->getValue($unserializedJob); // Should have the LATEST data @@ -840,7 +834,6 @@ public function testModelWithDifferentConnections(): void // Set a specific connection (in real app) $reflection = new \ReflectionClass($user); $property = $reflection->getProperty('connection'); - $property->setAccessible(true); $property->setValue($user, 'sqlite'); $job = new TestSendEmailToUserJob($user); @@ -1176,7 +1169,6 @@ public function testSerializationDeserializationCycle(): void // Get the user from job $reflection = new \ReflectionClass($unserializedJob); $property = $reflection->getProperty('user'); - $property->setAccessible(true); $restoredUser = $property->getValue($unserializedJob); // Verify we got fresh data diff --git a/tests/Unit/QueueSystemTest.php b/tests/Unit/QueueSystemTest.php index 225c43a..e3cfa13 100644 --- a/tests/Unit/QueueSystemTest.php +++ b/tests/Unit/QueueSystemTest.php @@ -127,9 +127,7 @@ private function setStaticProperty(string $className, string $propertyName, $val try { $reflection = new \ReflectionClass($className); $property = $reflection->getProperty($propertyName); - $property->setAccessible(true); $property->setValue(null, $value); - $property->setAccessible(false); } catch (\ReflectionException $e) { $this->fail("Failed to set static property {$propertyName}: " . $e->getMessage()); } @@ -570,7 +568,6 @@ public function testWorkerMemoryCheck(): void // This should return true since we're using more than 1MB $reflection = new \ReflectionClass($this->worker); $method = $reflection->getMethod('memoryExceeded'); - $method->setAccessible(true); $exceeded = $method->invoke($this->worker); $this->assertTrue($exceeded);