diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-01-21 16:36:17 +0100 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-01-21 16:36:17 +0100 |
commit | 27ea492cf72657a7ba2deb3d45302923ddd289b8 (patch) | |
tree | 6984ea3dbf2709a8eb71f882b5161724bea5543a | |
parent | 7a0e6970b447b270c09e16fc7ee4098f736a7a12 (diff) | |
download | wallabag-27ea492cf72657a7ba2deb3d45302923ddd289b8.tar.gz wallabag-27ea492cf72657a7ba2deb3d45302923ddd289b8.tar.zst wallabag-27ea492cf72657a7ba2deb3d45302923ddd289b8.zip |
Add tests on TagAllCommand
Some simple tests
-rw-r--r-- | src/Wallabag/CoreBundle/Command/TagAllCommand.php | 2 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Command/TagAllCommandTest.php | 60 |
2 files changed, 61 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Command/TagAllCommand.php b/src/Wallabag/CoreBundle/Command/TagAllCommand.php index 2cf3f808..db1a9ab7 100644 --- a/src/Wallabag/CoreBundle/Command/TagAllCommand.php +++ b/src/Wallabag/CoreBundle/Command/TagAllCommand.php | |||
@@ -28,7 +28,7 @@ class TagAllCommand extends ContainerAwareCommand | |||
28 | try { | 28 | try { |
29 | $user = $this->getUser($input->getArgument('username')); | 29 | $user = $this->getUser($input->getArgument('username')); |
30 | } catch (NoResultException $e) { | 30 | } catch (NoResultException $e) { |
31 | $output->writeln(sprintf('<error>User %s not found.</error>', $input->getArgument('username'))); | 31 | $output->writeln(sprintf('<error>User "%s" not found.</error>', $input->getArgument('username'))); |
32 | 32 | ||
33 | return 1; | 33 | return 1; |
34 | } | 34 | } |
diff --git a/src/Wallabag/CoreBundle/Tests/Command/TagAllCommandTest.php b/src/Wallabag/CoreBundle/Tests/Command/TagAllCommandTest.php new file mode 100644 index 00000000..653c1a93 --- /dev/null +++ b/src/Wallabag/CoreBundle/Tests/Command/TagAllCommandTest.php | |||
@@ -0,0 +1,60 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Tests\Command; | ||
4 | |||
5 | use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
6 | use Symfony\Component\Console\Tester\CommandTester; | ||
7 | use Wallabag\CoreBundle\Command\TagAllCommand; | ||
8 | use Wallabag\CoreBundle\Tests\WallabagCoreTestCase; | ||
9 | |||
10 | class TagAllCommandTest extends WallabagCoreTestCase | ||
11 | { | ||
12 | /** | ||
13 | * @expectedException Symfony\Component\Console\Exception\RuntimeException | ||
14 | * @expectedExceptionMessage Not enough arguments (missing: "username") | ||
15 | */ | ||
16 | public function testRunTagAllCommandWithoutUsername() | ||
17 | { | ||
18 | $application = new Application($this->getClient()->getKernel()); | ||
19 | $application->add(new TagAllCommand()); | ||
20 | |||
21 | $command = $application->find('wallabag:tag:all'); | ||
22 | |||
23 | $tester = new CommandTester($command); | ||
24 | $tester->execute(array( | ||
25 | 'command' => $command->getName(), | ||
26 | )); | ||
27 | } | ||
28 | |||
29 | public function testRunTagAllCommandWithBadUsername() | ||
30 | { | ||
31 | $application = new Application($this->getClient()->getKernel()); | ||
32 | $application->add(new TagAllCommand()); | ||
33 | |||
34 | $command = $application->find('wallabag:tag:all'); | ||
35 | |||
36 | $tester = new CommandTester($command); | ||
37 | $tester->execute(array( | ||
38 | 'command' => $command->getName(), | ||
39 | 'username' => 'unknown', | ||
40 | )); | ||
41 | |||
42 | $this->assertContains('User "unknown" not found', $tester->getDisplay()); | ||
43 | } | ||
44 | |||
45 | public function testRunTagAllCommand() | ||
46 | { | ||
47 | $application = new Application($this->getClient()->getKernel()); | ||
48 | $application->add(new TagAllCommand()); | ||
49 | |||
50 | $command = $application->find('wallabag:tag:all'); | ||
51 | |||
52 | $tester = new CommandTester($command); | ||
53 | $tester->execute(array( | ||
54 | 'command' => $command->getName(), | ||
55 | 'username' => 'admin', | ||
56 | )); | ||
57 | |||
58 | $this->assertContains('Tagging entries for user « admin »... Done', $tester->getDisplay()); | ||
59 | } | ||
60 | } | ||