Author: Antoine Hérault (antoine.herault@gmail.com)
Inheritance: extends Symfony\Bundle\FrameworkBundle\Command\Command
 public function testUserDeactivation()
 {
     $kernel = $this->createKernel();
     $command = new DeactivateUserCommand();
     $application = new Application($kernel);
     $application->setAutoExit(false);
     $tester = new ApplicationTester($application);
     $username = '******';
     $password = '******';
     $email = '*****@*****.**';
     $userManager = $this->getService('fos_user.user_manager');
     $user = $userManager->createUser();
     $user->setUsername($username);
     $user->setEmail($email);
     $user->setPlainPassword($password);
     $user->setEnabled(true);
     $userManager->updateUser($user);
     $this->assertTrue($user->isEnabled());
     $tester->run(array('command' => $command->getFullName(), 'username' => $username), array('interactive' => false, 'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE));
     $this->getService('doctrine.orm.default_entity_manager')->clear();
     $userManager = $this->getService('fos_user.user_manager');
     $user = $userManager->findUserByUsername($username);
     $this->assertTrue($user instanceof User);
     $this->assertFalse($user->isEnabled());
     $userManager->deleteUser($user);
 }
 private function createCommandTester(ContainerInterface $container, Application $application = null)
 {
     if (null === $application) {
         $application = new Application();
     }
     $application->setAutoExit(false);
     $command = new DeactivateUserCommand();
     $command->setContainer($container);
     $application->add($command);
     return new CommandTester($application->find('fos:user:deactivate'));
 }
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     /** @var UserDiscriminatorInterface $discriminator */
     $discriminator = $this->getContainer()->get('rollerworks_multi_user.user_discriminator');
     $discriminator->setCurrentUser($input->getOption('user-system'));
     parent::interact($input, $output);
 }