Lumen Testing mocking Authenticate.php

20 Views Asked by At

In my Luman app I am trying to mock the Authenticate class and it is working correctly, the only problem I have is, I dont know how to pass a variable into my mocking.

This is my code:

$someVariable = "test";
 
$this->app->instance(Authenticate::class, new class  {
        public function handle($request, $next, ...$guards)
        {
            // Here I need the $someVariable variable defined outside this scope.
            return $next($request);
        }
    });

Thanks for your help.

0

There are 0 best solutions below