Skip to content

feat: add assertQueueEqualsFixture to TestingTrait - #279

Closed
neellii wants to merge 14 commits into
masterfrom
add-assert-queue
Closed

feat: add assertQueueEqualsFixture to TestingTrait#279
neellii wants to merge 14 commits into
masterfrom
add-assert-queue

Conversation

@neellii

@neellii neellii commented Apr 17, 2026

Copy link
Copy Markdown

@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: 2292624c72

ℹ️ 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
$properties = (new ReflectionClass($object))->getProperties();

foreach ($properties as $property) {
$value = $property->getValue($object);

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 Handle uninitialized typed props before reading job attributes

getObjectAttributes() reads every reflected property with getValue(), but this throws an Error for typed properties that were declared but never initialized (for example, queued jobs with public string $foo; and no constructor assignment). In that case, assertQueueEqualsFixture() fails before assertion output is produced, so queue-state fixtures cannot be used for valid job classes. Check ReflectionProperty::isInitialized($object) (or provide a fallback value) before calling getValue().

Useful? React with 👍 / 👎.

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: 8c67464057

ℹ️ 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
$actualData = [];

foreach (Queue::pushedJobs() as $namespace => $jobs) {
$actualData[$namespace] = Arr::map($jobs, fn ($job) => $this->getObjectAttributes($job['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 Support string jobs in queue fixture assertions

assertQueueEqualsFixture() unconditionally passes $job['job'] into getObjectAttributes(object $object), but Laravel queue fakes can store pushed jobs as class strings (e.g., Queue::push('SomeJob', $data)) rather than instantiated objects. In that valid input path, this helper throws a TypeError before any fixture comparison runs, so tests that assert queue state for string-based jobs fail hard instead of producing assertion output.

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: 71b15dd3c3

ℹ️ 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".

$result[$property->getName()] = $value;
}

return json_decode(json_encode($result), 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 Handle JSON encoding failures in reflected job attributes

getObjectAttributes() converts reflected properties via json_encode/json_decode, but json_encode returns false for valid PHP values like invalid UTF-8 strings or resources inside job properties; in that case this expression returns null, violating the declared array return type and throwing a TypeError before fixture assertion runs. This makes queue fixture assertions crash for jobs carrying non-JSON-safe payloads instead of producing a comparison result.

Useful? React with 👍 / 👎.

@pirs1337

Copy link
Copy Markdown
Contributor

@neellii, please, fix tests

@pirs1337 pirs1337 assigned neellii and unassigned pirs1337 Apr 26, 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: 714ac87d5e

ℹ️ 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
$actualData = [];

foreach (Queue::pushedJobs() as $namespace => $jobs) {
$actualData[$namespace] = Arr::map($jobs, fn ($job) => $this->getObjectAttributes($job['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 pushed queue payload metadata

assertQueueEqualsFixture() currently reduces each pushed entry to getObjectAttributes($job['job']), which drops the queue and data fields that QueueFake::push() stores alongside the job. In tests that dispatch the same job class to different queues (e.g. pushOn) or with different payload data, this helper will serialize both entries identically and can pass even when queue routing/payload behavior regresses. Include these fields in the compared fixture structure so queue-state assertions remain accurate.

Useful? React with 👍 / 👎.

@neellii neellii assigned pirs1337 and unassigned neellii May 22, 2026
@DenTray DenTray assigned vitgrams and unassigned pirs1337 Jun 8, 2026
@DenTray
DenTray requested a review from vitgrams June 8, 2026 00:57
@vitgrams

vitgrams commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

@neellii @DenTray There are a few conflicts in my PR regarding notification assertions. We need to resolve them to avoid code duplication and ensure a clean distribution of methods across traits.

refs: #270

@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: fd6d2705b1

ℹ️ 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 queue pushes in the fixture state

When a test uses Queue::pushRaw(), Laravel's QueueFake stores that payload separately in rawPushes() while pushedJobs() remains unchanged. Because this assertion builds fixtures only from Queue::pushedJobs(), a test can pass against an empty or incomplete queue fixture even though raw payloads were enqueued, so regressions in code paths that produce raw queue jobs are silently missed.

Useful? React with 👍 / 👎.

@DenTray

DenTray commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

@neellii @DenTray There are a few conflicts in my PR regarding notification assertions. We need to resolve them to avoid code duplication and ensure a clean distribution of methods across traits.

refs: #270

@neellii @vitgrams we have a separate task for it #285 let's proceed work as part of this task

@DenTray DenTray closed this Jun 16, 2026
@DenTray
DenTray deleted the add-assert-queue branch June 16, 2026 02:14
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.

4 participants