app); $serviceProvider->register(); $user = new User(); /** @var Authenticator|MockObject $auth */ $auth = $this->createMock(Authenticator::class); $this->setExpects($auth, 'user', null, $user); $this->app->instance(Authenticator::class, $auth); /** @var UsesAuthImplementation $instance */ $instance = $this->app->make(UsesAuthImplementation::class); $this->assertEquals($user, $instance->user('self')); } }