function it_does_not_update_username_when_customer_email_is_the_same(OnFlushEventArgs $onFlushEventArgs, EntityManager $entityManager, UnitOfWork $unitOfWork, CustomerInterface $customer, UserInterface $user, ClassMetadata $userMetadata) { $onFlushEventArgs->getEntityManager()->willReturn($entityManager); $entityManager->getUnitOfWork()->willReturn($unitOfWork); $unitOfWork->getScheduledEntityInsertions()->willReturn([]); $unitOfWork->getScheduledEntityUpdates()->willReturn([$customer]); $user->getUsername()->willReturn('*****@*****.**'); $customer->getUser()->willReturn($user); $customer->getEmail()->willReturn('*****@*****.**'); $user->setUsername('*****@*****.**')->shouldNotBeCalled(); $entityManager->persist($user)->shouldNotBeCalled(); $unitOfWork->recomputeSingleEntityChangeSet($userMetadata, $user)->shouldNotBeCalled(); $this->onFlush($onFlushEventArgs); }