diff options
Diffstat (limited to 'tests/Wallabag')
-rw-r--r-- | tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php b/tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php new file mode 100644 index 00000000..9939d43c --- /dev/null +++ b/tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php | |||
@@ -0,0 +1,59 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Tests\Wallabag\CoreBundle\Command; | ||
4 | |||
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 | |||
10 | class CleanDuplicatesCommandTest extends WallabagCoreTestCase | ||
11 | { | ||
12 | public function testRunTagAllCommandForAll() | ||
13 | { | ||
14 | $application = new Application($this->getClient()->getKernel()); | ||
15 | $application->add(new CleanDuplicatesCommand()); | ||
16 | |||
17 | $command = $application->find('wallabag:clean-duplicates'); | ||
18 | |||
19 | $tester = new CommandTester($command); | ||
20 | $tester->execute([ | ||
21 | 'command' => $command->getName(), | ||
22 | ]); | ||
23 | |||
24 | $this->assertContains('Cleaning through 3 user accounts', $tester->getDisplay()); | ||
25 | $this->assertContains('Finished cleaning. 0 duplicates found in total', $tester->getDisplay()); | ||
26 | } | ||
27 | |||
28 | public function testRunTagAllCommandWithBadUsername() | ||
29 | { | ||
30 | $application = new Application($this->getClient()->getKernel()); | ||
31 | $application->add(new CleanDuplicatesCommand()); | ||
32 | |||
33 | $command = $application->find('wallabag:clean-duplicates'); | ||
34 | |||
35 | $tester = new CommandTester($command); | ||
36 | $tester->execute([ | ||
37 | 'command' => $command->getName(), | ||
38 | 'username' => 'unknown', | ||
39 | ]); | ||
40 | |||
41 | $this->assertContains('User "unknown" not found', $tester->getDisplay()); | ||
42 | } | ||
43 | |||
44 | public function testRunTagAllCommandForUser() | ||
45 | { | ||
46 | $application = new Application($this->getClient()->getKernel()); | ||
47 | $application->add(new CleanDuplicatesCommand()); | ||
48 | |||
49 | $command = $application->find('wallabag:clean-duplicates'); | ||
50 | |||
51 | $tester = new CommandTester($command); | ||
52 | $tester->execute([ | ||
53 | 'command' => $command->getName(), | ||
54 | 'username' => 'admin', | ||
55 | ]); | ||
56 | |||
57 | $this->assertContains('Cleaned 0 duplicates for user admin', $tester->getDisplay()); | ||
58 | } | ||
59 | } | ||