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
23 changes: 13 additions & 10 deletions tests/Feature/ShowJobsCommandTest.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
<?php

declare(strict_types=1);

namespace Tests\Feature;

use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Redis;

use function Pest\Laravel\artisan;

beforeEach(function () {
beforeEach(function (): void {
Redis::flushall();
});

it('shows message when no jobs exist', function () {
it('shows message when no jobs exist', function (): void {
artisan('queue:inspect')
->assertSuccessful()
->expectsOutput('No matching delayed jobs found.');
});

it('filters by --queue', function () {
it('filters by --queue', function (): void {
$payload = json_encode([
'uuid' => 'uuid-queue-1',
'displayName' => 'App\\Jobs\\QueuedJob',
Expand All @@ -34,7 +37,7 @@
->expectsOutput(json_encode(['count' => 1], JSON_PRETTY_PRINT));
});

it('filters by --job (partial match)', function () {
it('filters by --job (partial match)', function (): void {
$payload = json_encode([
'uuid' => 'uuid-job-1',
'displayName' => 'App\\Jobs\\TestNotificationJob',
Expand All @@ -48,7 +51,7 @@
->expectsOutput(json_encode(['count' => 1], JSON_PRETTY_PRINT));
});

it('filters by --uuid (exact match)', function () {
it('filters by --uuid (exact match)', function (): void {
$uuid = 'exact-uuid-1234';
$payload = json_encode([
'uuid' => $uuid,
Expand All @@ -63,7 +66,7 @@
->expectsOutput(json_encode(['count' => 1], JSON_PRETTY_PRINT));
});

it('filters by --identifier (serialized in payload)', function () {
it('filters by --identifier (serialized in payload)', function (): void {
$identifier = 42;
$serialized = serialize((object) ['id' => $identifier]);

Expand All @@ -80,7 +83,7 @@
->expectsOutput(json_encode(['count' => 1], JSON_PRETTY_PRINT));
});

it('filters jobs by --from and --to date range', function () {
it('filters jobs by --from and --to date range', function (): void {
$today = now();
$releaseAt = $today->copy()->addHours(2); // falls within today

Expand All @@ -99,7 +102,7 @@
->and($json['jobs'][0]['job'])->toBe('App\\Jobs\\ScheduledJob');
});

it('respects --limit and --page', function () {
it('respects --limit and --page', function (): void {
Redis::flushall();

foreach (range(1, 5) as $i) {
Expand Down Expand Up @@ -131,7 +134,7 @@
expect($jsonPage2['jobs'][1]['job'])->toBe('App\\Jobs\\PaginatedJob4');
});

it('outputs in JSON when --json is used', function () {
it('outputs in JSON when --json is used', function (): void {
Redis::flushall();

Redis::zadd('queues:default:delayed', time() + 300, json_encode([
Expand All @@ -151,7 +154,7 @@
->and($data['jobs'][0]['job'])->toBe('App\\Jobs\\JsonJob');
});

it('shows total count when using --count', function () {
it('shows total count when using --count', function (): void {
Redis::zadd('queues:default:delayed', time() + 300, json_encode([
'uuid' => 'uuid-count',
'displayName' => 'App\\Jobs\\CountingJob',
Expand Down
2 changes: 2 additions & 0 deletions tests/Pest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use Tests\TestCase;

uses(TestCase::class)->in(__DIR__);
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Tests;

use Pdmfc\RedisQueueInspector\Providers\RedisQueueInspectorServiceProvider;
use Orchestra\Testbench\TestCase as Orchestra;
use Pdmfc\RedisQueueInspector\Providers\RedisQueueInspectorServiceProvider;

abstract class TestCase extends Orchestra
{
Expand Down