Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempts() method does not exist on FakeJob #51929

Closed
JamesFreeman opened this issue Jun 27, 2024 · 1 comment
Closed

attempts() method does not exist on FakeJob #51929

JamesFreeman opened this issue Jun 27, 2024 · 1 comment

Comments

@JamesFreeman
Copy link
Contributor

Laravel Version

11.12.0

PHP Version

8.2.20

Database Driver & Version

N/A

Description

I need to be able to test a job that will be put back onto the queue with different delays based on how many times it has not been completed - after x times, we will just run the job. I thought the best course of action would be to use the new withFakeQueueInteractions helper - but i'm getting the following error:

Error:

Error: Call to undefined method Illuminate\Queue\Jobs\FakeJob::attempts()
/Users/xxx/Sites/xxx/vendor/laravel/framework/src/Illuminate/Queue/InteractsWithQueue.php:32

Steps To Reproduce

Job Code:

public function handle(): void
{
    if ($this->payment->paymentRequest->tokenize_payment && is_null($this->payment->token_id) && $this->attempts() <= 3) {
        $this->release($this->delays[$this->attempts()]);

        return;
    }

    $this->send();
}

Test Code:

public function test_that_it_will_release_job_back_onto_queue_if_is_token_payment_and_its_not_there()
{
    Bus::fake();

    $payment = $this->createPaymentWithPostback();

    $payment->update(['token_id' => null]);
    $payment->paymentRequest->update(['tokenize_payment' => true]);

    $job = (new PaymentVerified($payment))->withFakeQueueInteractions();

    $job->handle();

    $this->assertWebhookNotCreated();
    $job->assertReleased(1);
}
@driesvints
Copy link
Member

Hi there,

Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.

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

No branches or pull requests

2 participants