How to properly call this middleware closure function in phpunit test so that $user will be set?
Auth::user is mocked and will receive the proper user object, but the function is not called when creating the controller instance.
Here is my code:
use App\Http\Controllers\Controller;
class CustomController extends Controller
{
private $user;
public function __construct()
{
$this->middleware(function ($request, $next) {
$this->user = Auth::user();
return $next($request);
});
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire