3 namespace Tests\Wallabag\CoreBundle\Command
;
5 use Symfony\Bundle\FrameworkBundle\Console\Application
;
6 use Symfony\Component\Console\Tester\CommandTester
;
7 use Wallabag\CoreBundle\Command\CleanDuplicatesCommand
;
8 use Tests\Wallabag\CoreBundle\WallabagCoreTestCase
;
9 use Wallabag\CoreBundle\Command\ShowUserCommand
;
10 use Wallabag\CoreBundle\Entity\Entry
;
11 use Wallabag\UserBundle\Entity\User
;
13 class ShowUserCommandTest
extends WallabagCoreTestCase
16 * @expectedException \Symfony\Component\Console\Exception\RuntimeException
17 * @expectedExceptionMessage Not enough arguments
19 public function testRunShowUserCommandWithoutUsername()
21 $application = new Application($this->getClient()->getKernel());
22 $application->add(new ShowUserCommand());
24 $command = $application->find('wallabag:user:show');
26 $tester = new CommandTester($command);
28 'command' => $command->getName(),
32 public function testRunShowUserCommandWithBadUsername()
34 $application = new Application($this->getClient()->getKernel());
35 $application->add(new ShowUserCommand());
37 $command = $application->find('wallabag:user:show');
39 $tester = new CommandTester($command);
41 'command' => $command->getName(),
42 'username' => 'unknown',
45 $this->assertContains('User "unknown" not found', $tester->getDisplay());
48 public function testRunShowUserCommandForUser()
50 $application = new Application($this->getClient()->getKernel());
51 $application->add(new ShowUserCommand());
53 $command = $application->find('wallabag:user:show');
55 $tester = new CommandTester($command);
57 'command' => $command->getName(),
58 'username' => 'admin',
61 $this->assertContains('Username : admin', $tester->getDisplay());
62 $this->assertContains('Email : bigboss@wallabag.org', $tester->getDisplay());
63 $this->assertContains('Display name : Big boss', $tester->getDisplay());
64 $this->assertContains('2FA activated: no', $tester->getDisplay());
67 public function testShowUser()
69 $client = $this->getClient();
70 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
72 $this->logInAs('admin');
74 /** @var User $user */
75 $user = $em->getRepository('WallabagUserBundle:User')->findOneById($this->getLoggedInUserId());
77 $user->setName('Bug boss');
82 $application = new Application($this->getClient()->getKernel());
83 $application->add(new ShowUserCommand());
85 $command = $application->find('wallabag:user:show');
87 $tester = new CommandTester($command);
89 'command' => $command->getName(),
90 'username' => 'admin',
93 $this->assertContains('Display name : Bug boss', $tester->getDisplay());