public function testUpdateOnlineUsers()
 {
     $provider = $this->getMock(OnlineUserIdWriteProviderInterface::class);
     $provider->expects($this->once())->method('addUserId');
     $user = $this->getMockWithoutInvokingTheOriginalConstructor(User::class);
     $entityManager = $this->getMock(EntityManagerInterface::class);
     $entityManager->expects($this->once())->method('persist')->with($user);
     $user->expects($this->once())->method('updateLastAction');
     $user->expects($this->once())->method('getId')->willReturn('1');
     $entityManager->expects($this->once())->method('flush');
     $token = $this->getMockWithoutInvokingTheOriginalConstructor(PreAuthenticatedToken::class);
     $token->expects($this->once())->method('getUser')->willReturn($user);
     $listener = new OnlineUsersUpdateListener($provider, $entityManager);
     $event = new OnFirewallAuthenticationEvent();
     $event->setToken($token);
     $listener->onFirewallLogin($event);
 }
 public function testUpdateOnlineUsers()
 {
     $provider = $this->getMock(OnlineUserIdDataProviderInterface::class);
     $provider->expects($this->once())->method('addUserId');
     $now = time();
     $request = Request::create('/');
     $request->server->set('REQUEST_TIME', $now);
     $requestStack = $this->getMock(RequestStack::class, ['getMasterRequest']);
     $requestStack->expects($this->once())->method('getMasterRequest')->willReturn($request);
     $user = User::create('Ma27', '123456', 'Ma27@sententiaregum.dev');
     $entityManager = $this->getMock(EntityManagerInterface::class);
     $entityManager->expects($this->once())->method('persist')->with($user);
     $entityManager->expects($this->once())->method('flush')->with($user);
     $token = $this->getMockWithoutInvokingTheOriginalConstructor(PreAuthenticatedToken::class);
     $token->expects($this->once())->method('getUser')->willReturn($user);
     $listener = new OnlineUsersUpdateListener($provider, $requestStack, $entityManager);
     $event = new OnFirewallAuthenticationEvent();
     $event->setToken($token);
     $listener->onFirewallLogin($event);
     $this->assertSame($now, $user->getLastAction()->getTimestamp());
 }