lorisleiva / laravel-actions

⚡️ Laravel components that take care of one specific task
https://laravelactions.com
MIT License
2.52k stars 124 forks source link

assertPushed() does not seem to work with actions implementing the ShouldBeUnique interface #120

Closed FrancisMawn closed 3 years ago

FrancisMawn commented 3 years ago

Hi there,

I could not make my test assert that my action was pushed. I followed the documentation and I think I wrote everything fine, but for some reasons, when my action implements the ShouldBeUnique interface, my test would never assert that my job got pushed.

After a lot of troubleshooting, I ended up removing the ShouldBeUnique interface the test passed from there. I did define a getJobUniqueId() method and a $jobUniqueFor property on my action class. Maybe I am missing something?

On that note, I think the documentation is misleading. From the doc:

public function getJobUniqueId(Team $team)
{
    return $this->team->id;
}

Here the getJobUniqueId() method receives an instance of $team but the actual implementation references a property on the class. Should it rather be:

return $team->id;

I say that because when I tried to reference the actual class property (like documented here), it would throw a "Typed property must not be accessed before initialization" exception.

lorisleiva commented 3 years ago

Hi there 👋

Sorry for the late reply and thank you for raising this issue because it was indeed a bug (both on the code and on the documentation).

I've fixed both of them and I should create a release later today. Once the released is tagged you should be able to use assertPushed on actions that use the ShouldBeUnique interface. 🙂

lorisleiva commented 3 years ago

Released as v2.1.4. 🚀