Skip to content

feat: implement queue assertion helpers - #287

Open
AZabolotnikov wants to merge 47 commits into
masterfrom
Implement-queue-assertion-helpers
Open

feat: implement queue assertion helpers#287
AZabolotnikov wants to merge 47 commits into
masterfrom
Implement-queue-assertion-helpers

Conversation

@AZabolotnikov

Copy link
Copy Markdown
Contributor

refs: #285

@AZabolotnikov AZabolotnikov self-assigned this May 20, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 44f823f427

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Traits/TestingTrait.php Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b5c32a3cda

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Traits/TestingTrait.php Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5a5a79068f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Traits/TestingTrait.php Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 55bf96b282

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Traits/TestingTrait.php

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4a59481d07

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Traits/TestingTrait.php Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements centralized queue-related assertion helpers in TestingTrait (per issue #285) and adds coverage + fixtures to validate queued job state across supported Laravel major versions.

Changes:

  • Added assertQueueEqualsFixture() and assertQueueEmpty() to src/Traits/TestingTrait.php, including helper methods to normalize pushed job representations.
  • Expanded TestingTraitTest with queue assertion test cases covering dispatch and Queue::push(...) variants.
  • Added versioned queue fixtures (v11/v12/v13) and supporting mock job classes/trait for test reuse.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Traits/TestingTrait.php Adds queue assertion helpers and reflection-based job attribute extraction.
tests/TestingTraitTest.php Adds tests for queue assertions and Laravel-major-version fixture selection.
tests/support/Traits/TestingTraitTestTrait.php Adds a helper to select versioned queue fixtures.
tests/support/Mock/Jobs/BaseTestJob.php Adds a base queued job used by the new tests.
tests/support/Mock/Jobs/TestJob.php Adds a test job with payload fields and explicit queue.
tests/support/Mock/Jobs/AnotherTestJob.php Adds a second test job to validate multiple job types in the queue.
tests/fixtures/TestingTraitTest/queue_states/v11/*.json Adds Laravel v11 expected queue-state fixtures.
tests/fixtures/TestingTraitTest/queue_states/v12/*.json Adds Laravel v12 expected queue-state fixtures.
tests/fixtures/TestingTraitTest/queue_states/v13/*.json Adds Laravel v13 expected queue-state fixtures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Traits/TestingTrait.php Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 444ce8f990

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Traits/TestingTrait.php Outdated
foreach (Queue::pushedJobs() as $namespace => $jobs) {
$actualData[$namespace] = Arr::map($jobs, function ($job) {
$job = $this->getJobObject($job);
$job->delay = (string) $job->delay;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve null delays when normalizing queued jobs

When a queued job has no delay, which is the default for Queue::push(...) and several tests added in this commit, this cast changes $job->delay from null to '' before snapshotting. The committed fixtures decode that field as null, so assertQueueEqualsFixture() fails for no-delay jobs even though the queue state matches; only stringify non-null date delays.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb347e7ff5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5ed9bbf6bb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

});
}

$actualData = json_decode(json_encode($actualData), true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve nested object state in queue snapshots

When a queued job has an attribute that is itself a DTO/value object with private or protected properties, getObjectAttributes() returns that nested object but this JSON round-trip serializes only public/JsonSerializable state. For example, two different payload objects with only private fields both become {}, so assertQueueEqualsFixture() can keep passing while the actual queued payload state changes; recursively normalize nested objects or fail loudly before encoding.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9477cd8ef1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread tests/TestingTraitTest.php Outdated

TestJob::dispatch('some payload', ['another payload'])->delay(now()->addMinute());

$this->assertQueueEqualsFixture($this->getFixturePathForVersion('assert_queue_equals'));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Define the fixture-version helper before using it

In this test (and the four queue tests below it), $this->getFixturePathForVersion() is called, but this method is not defined anywhere in the repo (rg "function getFixturePathForVersion|getFixturePathForVersion" only finds these call sites). PHPUnit will throw Error: Call to undefined method RonasIT\Support\Tests\TestingTraitTest::getFixturePathForVersion() as soon as these new tests run, so the added queue coverage cannot pass until the helper is added or an existing fixture helper is used.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c8111d238

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

{
$actualData = [];

foreach (Queue::pushedJobs() as $namespace => $jobs) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve cross-class dispatch order in snapshots

When jobs of different classes are dispatched to the same queue, iterating Queue::pushedJobs() snapshots class-keyed buckets instead of the chronological queue sequence, so sequences such as A, B, A and A, A, B normalize to the same fixture as long as each class bucket is unchanged. Since the real queue processes jobs in push order, tests using this helper can miss regressions that reorder different job classes; include a flat sequence/index in the captured data rather than only class-keyed buckets.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4dd36dc8c7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

{
$actualData = [];

foreach (Queue::pushedJobs() as $namespace => $jobs) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include raw pushes in queue snapshots

When code under test calls Queue::pushRaw() alongside normal queued jobs, Laravel's fake records those payloads separately from pushedJobs(). Because this snapshot is built only from pushedJobs(), an unexpected raw payload is invisible and assertQueueEqualsFixture() can still pass against a fixture that matches only the object jobs; include raw pushes in the captured data or fail when any are present.

Useful? React with 👍 / 👎.

$actualData[$namespace] = Arr::map($jobs, function ($job) {
$job = $this->getJobObject($job);

return $this->getObjectAttributes($job);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve captured state for queued closures

When a test queues a closure job such as Queue::push(function () use ($id) {}), this path passes the Closure into getObjectAttributes(), but closures expose no reflected properties, so every closure snapshots as an empty object. A fixture containing one closure will therefore keep passing even if the captured variables or queued work change; snapshot closure static variables with ReflectionFunction or reject closure jobs explicitly.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 40aeee929c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


TestJob::dispatch('some payload', ['another payload'])->delay(now()->addMinute());

$this->assertQueueEqualsVersioningFixture('assert_queue_equals');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Pass version boundaries to queue fixture assertions

Fresh evidence beyond the earlier versioning concern is that the commit now adds laravel_before_v11/laravel_before_v12 queue fixture directories, but this call and the three below still omit the $versions argument, so getVersioningFixtureName() receives [] and always compares against the root fixture. When the suite runs on a supported older framework version such as Laravel 11 (composer.json allows laravel/framework >=11.0), those versioned fixtures are never selected and the queue tests compare against snapshots containing newer queue properties instead of the Laravel 11 shape.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3b53ae17f6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

"queue": "some_queue",
"messageGroup": null,
"deduplicator": null,
"debounceOwner": "",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Version debounce fixtures by minor release

Fresh evidence beyond the earlier major-version concern is that the new [12, 13] selection still treats every Laravel 13 install as using this root fixture. debounceOwner was added with Laravel's debounced queue jobs in the 13.6 line, while composer.json allows any laravel/framework >=11.0; on supported Laravel 13.0–13.5 installs the reflected job does not have this property, so these queue fixture tests compare against an extra key and fail unless the fixture selection accounts for the minor boundary or avoids this framework-internal field.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants