Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
14 changes: 4 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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
}
2 changes: 1 addition & 1 deletion src/Commands/MakeJobCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
5 changes: 0 additions & 5 deletions src/InteractsWithModelSerialization.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public function __serialize(): array
$properties = $reflection->getProperties();

foreach ($properties as $property) {
$property->setAccessible(true);

if (!$property->isInitialized($this)) {
continue;
Expand Down Expand Up @@ -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__'])) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down
10 changes: 5 additions & 5 deletions src/QueueServiceProvider.php → src/QueueLauncher.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
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;
use Doppar\Queue\Commands\QueueFlushCommand;
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.
Expand All @@ -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([
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/MakeJobCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(
'<fg=yellow>📦 File:</> <fg=white>app/Jobs/Reports/GenerateDailyJob.php</>',
'<fg=yellow>📦 File:</> <fg=white>src/Jobs/Reports/GenerateDailyJob.php</>',
$command->capturedLines
);
}
Expand Down
8 changes: 0 additions & 8 deletions tests/Unit/ModelSerializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions tests/Unit/QueueSystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -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);
Expand Down
Loading