aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php
diff options
context:
space:
mode:
authorJeremy Benoist <j0k3r@users.noreply.github.com>2017-01-27 09:34:32 +0100
committerGitHub <noreply@github.com>2017-01-27 09:34:32 +0100
commit6fb06904ecde15b1b07d0a2af945338b416cf0e2 (patch)
treee76f3e8142399316ec5660fab8c646b2c34b8336 /tests/Wallabag/CoreBundle/Command/ExportCommandTest.php
parent05fa529bcfde01be5d320cb532900d72cf4b0830 (diff)
parent78295b99dd1721c613f1ce52e2debbe6f6db7753 (diff)
downloadwallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.tar.gz
wallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.tar.zst
wallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.zip
Merge pull request #2416 from wallabag/2.2
wallabag 2.2.0
Diffstat (limited to 'tests/Wallabag/CoreBundle/Command/ExportCommandTest.php')
-rw-r--r--tests/Wallabag/CoreBundle/Command/ExportCommandTest.php78
1 files changed, 78 insertions, 0 deletions
diff --git a/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php b/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php
new file mode 100644
index 00000000..6798c5d7
--- /dev/null
+++ b/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php
@@ -0,0 +1,78 @@
1<?php
2
3namespace Tests\Wallabag\CoreBundle\Command;
4
5use Symfony\Bundle\FrameworkBundle\Console\Application;
6use Symfony\Component\Console\Tester\CommandTester;
7use Wallabag\CoreBundle\Command\ExportCommand;
8use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
9
10class ExportCommandTest extends WallabagCoreTestCase
11{
12 /**
13 * @expectedException Symfony\Component\Console\Exception\RuntimeException
14 * @expectedExceptionMessage Not enough arguments (missing: "username")
15 */
16 public function testExportCommandWithoutUsername()
17 {
18 $application = new Application($this->getClient()->getKernel());
19 $application->add(new ExportCommand());
20
21 $command = $application->find('wallabag:export');
22
23 $tester = new CommandTester($command);
24 $tester->execute([
25 'command' => $command->getName(),
26 ]);
27 }
28
29 public function testExportCommandWithBadUsername()
30 {
31 $application = new Application($this->getClient()->getKernel());
32 $application->add(new ExportCommand());
33
34 $command = $application->find('wallabag:export');
35
36 $tester = new CommandTester($command);
37 $tester->execute([
38 'command' => $command->getName(),
39 'username' => 'unknown',
40 ]);
41
42 $this->assertContains('User "unknown" not found', $tester->getDisplay());
43 }
44
45 public function testExportCommand()
46 {
47 $application = new Application($this->getClient()->getKernel());
48 $application->add(new ExportCommand());
49
50 $command = $application->find('wallabag:export');
51
52 $tester = new CommandTester($command);
53 $tester->execute([
54 'command' => $command->getName(),
55 'username' => 'admin',
56 ]);
57
58 $this->assertContains('Exporting 6 entrie(s) for user « admin »... Done', $tester->getDisplay());
59 $this->assertFileExists('admin-export.json');
60 }
61
62 public function testExportCommandWithSpecialPath()
63 {
64 $application = new Application($this->getClient()->getKernel());
65 $application->add(new ExportCommand());
66
67 $command = $application->find('wallabag:export');
68
69 $tester = new CommandTester($command);
70 $tester->execute([
71 'command' => $command->getName(),
72 'username' => 'admin',
73 'filepath' => 'specialexport.json'
74 ]);
75
76 $this->assertFileExists('specialexport.json');
77 }
78}