When writing tests in Laravel, use the app()
helper to resolve the class. Laravel will automatically inject the dependencies.
// In the phpunit
$orderInvoice = app(CreateBasketInvoiceAction::class)($basket);
// Action
public function __construct(CreateOrderAction $createOrderAction)
{
$this->createOrderAction = $createOrderAction;
}