]>
Commit | Line | Data |
---|---|---|
27ea492c JB |
1 | <?php |
2 | ||
23634d5d | 3 | namespace Tests\Wallabag\CoreBundle\Command; |
27ea492c JB |
4 | |
5 | use Symfony\Bundle\FrameworkBundle\Console\Application; | |
6 | use Symfony\Component\Console\Tester\CommandTester; | |
23634d5d | 7 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; |
f808b016 | 8 | use Wallabag\CoreBundle\Command\TagAllCommand; |
27ea492c JB |
9 | |
10 | class TagAllCommandTest extends WallabagCoreTestCase | |
11 | { | |
12 | /** | |
bad7df8c | 13 | * @expectedException \Symfony\Component\Console\Exception\RuntimeException |
27ea492c JB |
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); | |
4094ea47 | 24 | $tester->execute([ |
27ea492c | 25 | 'command' => $command->getName(), |
4094ea47 | 26 | ]); |
27ea492c JB |
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); | |
4094ea47 | 37 | $tester->execute([ |
27ea492c JB |
38 | 'command' => $command->getName(), |
39 | 'username' => 'unknown', | |
4094ea47 | 40 | ]); |
27ea492c JB |
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); | |
4094ea47 | 53 | $tester->execute([ |
27ea492c JB |
54 | 'command' => $command->getName(), |
55 | 'username' => 'admin', | |
4094ea47 | 56 | ]); |
27ea492c | 57 | |
e1b33efb NH |
58 | $this->assertContains('Tagging entries for user admin...', $tester->getDisplay()); |
59 | $this->assertContains('Done', $tester->getDisplay()); | |
27ea492c JB |
60 | } |
61 | } |