3 namespace Tests\Wallabag\CoreBundle\Command
;
5 use Symfony\Bundle\FrameworkBundle\Console\Application
;
6 use Symfony\Component\Console\Tester\CommandTester
;
7 use Tests\Wallabag\CoreBundle\WallabagCoreTestCase
;
8 use Wallabag\CoreBundle\Command\ShowUserCommand
;
9 use Wallabag\UserBundle\Entity\User
;
11 class ShowUserCommandTest
extends WallabagCoreTestCase
14 * @expectedException \Symfony\Component\Console\Exception\RuntimeException
15 * @expectedExceptionMessage Not enough arguments
17 public function testRunShowUserCommandWithoutUsername()
19 $application = new Application($this->getClient()->getKernel());
20 $application->add(new ShowUserCommand());
22 $command = $application->find('wallabag:user:show');
24 $tester = new CommandTester($command);
26 'command' => $command->getName(),
30 public function testRunShowUserCommandWithBadUsername()
32 $application = new Application($this->getClient()->getKernel());
33 $application->add(new ShowUserCommand());
35 $command = $application->find('wallabag:user:show');
37 $tester = new CommandTester($command);
39 'command' => $command->getName(),
40 'username' => 'unknown',
43 $this->assertContains('User "unknown" not found', $tester->getDisplay());
46 public function testRunShowUserCommandForUser()
48 $application = new Application($this->getClient()->getKernel());
49 $application->add(new ShowUserCommand());
51 $command = $application->find('wallabag:user:show');
53 $tester = new CommandTester($command);
55 'command' => $command->getName(),
56 'username' => 'admin',
59 $this->assertContains('Username: admin', $tester->getDisplay());
60 $this->assertContains('Email: bigboss@wallabag.org', $tester->getDisplay());
61 $this->assertContains('Display name: Big boss', $tester->getDisplay());
62 $this->assertContains('2FA (email) activated', $tester->getDisplay());
63 $this->assertContains('2FA (OTP) activated', $tester->getDisplay());
66 public function testShowUser()
68 $client = $this->getClient();
69 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
71 $this->logInAs('admin');
73 /** @var User $user */
74 $user = $em->getRepository('WallabagUserBundle:User')->findOneById($this->getLoggedInUserId());
76 $user->setName('Bug boss');
81 $application = new Application($this->getClient()->getKernel());
82 $application->add(new ShowUserCommand());
84 $command = $application->find('wallabag:user:show');
86 $tester = new CommandTester($command);
88 'command' => $command->getName(),
89 'username' => 'admin',
92 $this->assertContains('Display name: Bug boss', $tester->getDisplay());