dillingham / nova-assertions

Laravel Nova assertions for your tests
MIT License
79 stars 16 forks source link

Action __construct #17

Closed nenads closed 3 years ago

nenads commented 3 years ago

Hi,

any suggestion

class Delete extends DestructiveAction
{

    protected $modelId;

    public function __construct($modelId)
    {
        $this->modelId = $modelId;       
    }

How to use it with

$response->assertActionsInclude(Delete::class)

It will create error: Unresolvable dependency resolving [Parameter #0 [ $modelId ]] in class App\Nova\Actions\Delete

while

$response->assertActionsInclude(new Delete(1))

Creates: Illegal offset type in isset or empty

any suggestion how to assert Nova Actions that have constructor

dillingham commented 3 years ago

$response->assertActions(function($actions) {
    return $actions[0]->modelId == 1;
});

Maybe use the callback approach for that

Although the assertions are really to show the action exists on the page. Not that it was selected. Good luck