From d143fa243df6112c9df7c6e7e408b66da40c8fce Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 2 Jun 2017 16:53:03 +0200 Subject: Add show user command Signed-off-by: Thomas Citharel --- .../CoreBundle/Command/ShowUserCommandTest.php | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php (limited to 'tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php') diff --git a/tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php b/tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php new file mode 100644 index 00000000..642327c3 --- /dev/null +++ b/tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php @@ -0,0 +1,95 @@ +getClient()->getKernel()); + $application->add(new ShowUserCommand()); + + $command = $application->find('wallabag:user:show'); + + $tester = new CommandTester($command); + $tester->execute([ + 'command' => $command->getName(), + ]); + } + + public function testRunShowUserCommandWithBadUsername() + { + $application = new Application($this->getClient()->getKernel()); + $application->add(new ShowUserCommand()); + + $command = $application->find('wallabag:user:show'); + + $tester = new CommandTester($command); + $tester->execute([ + 'command' => $command->getName(), + 'username' => 'unknown', + ]); + + $this->assertContains('User "unknown" not found', $tester->getDisplay()); + } + + public function testRunShowUserCommandForUser() + { + $application = new Application($this->getClient()->getKernel()); + $application->add(new ShowUserCommand()); + + $command = $application->find('wallabag:user:show'); + + $tester = new CommandTester($command); + $tester->execute([ + 'command' => $command->getName(), + 'username' => 'admin', + ]); + + $this->assertContains('Username : admin', $tester->getDisplay()); + $this->assertContains('Email : bigboss@wallabag.org', $tester->getDisplay()); + $this->assertContains('Display name : Big boss', $tester->getDisplay()); + $this->assertContains('2FA activated: false', $tester->getDisplay()); + } + + public function testShowUser() + { + $client = $this->getClient(); + $em = $client->getContainer()->get('doctrine.orm.entity_manager'); + + $this->logInAs('admin'); + + /** @var User $user */ + $user = $em->getRepository('WallabagUserBundle:User')->findOneById($this->getLoggedInUserId()); + + $user->setName('Bug boss'); + $em->persist($user); + + $em->flush(); + + $application = new Application($this->getClient()->getKernel()); + $application->add(new ShowUserCommand()); + + $command = $application->find('wallabag:user:show'); + + $tester = new CommandTester($command); + $tester->execute([ + 'command' => $command->getName(), + 'username' => 'admin', + ]); + + $this->assertContains('Display name : Bug boss', $tester->getDisplay()); + } +} -- cgit v1.2.3 From 0d8ecb82a32fcb7e87d99316b00c827c8aa71eee Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sun, 4 Jun 2017 17:57:40 +0200 Subject: Fix review Signed-off-by: Thomas Citharel --- tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php') diff --git a/tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php b/tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php index 642327c3..3b928d1e 100644 --- a/tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php @@ -61,7 +61,7 @@ class ShowUserCommandTest extends WallabagCoreTestCase $this->assertContains('Username : admin', $tester->getDisplay()); $this->assertContains('Email : bigboss@wallabag.org', $tester->getDisplay()); $this->assertContains('Display name : Big boss', $tester->getDisplay()); - $this->assertContains('2FA activated: false', $tester->getDisplay()); + $this->assertContains('2FA activated: no', $tester->getDisplay()); } public function testShowUser() -- cgit v1.2.3