3 namespace Tests\Wallabag\CoreBundle\Command
;
5 use Symfony\Bundle\FrameworkBundle\Console\Application
;
6 use Symfony\Component\Console\Tester\CommandTester
;
7 use Tests\Wallabag\CoreBundle\WallabagCoreTestCase
;
8 use Wallabag\CoreBundle\Command\ExportCommand
;
10 class ExportCommandTest
extends WallabagCoreTestCase
13 * @expectedException \Symfony\Component\Console\Exception\RuntimeException
14 * @expectedExceptionMessage Not enough arguments (missing: "username")
16 public function testExportCommandWithoutUsername()
18 $application = new Application($this->getClient()->getKernel());
19 $application->add(new ExportCommand());
21 $command = $application->find('wallabag:export');
23 $tester = new CommandTester($command);
25 'command' => $command->getName(),
29 public function testExportCommandWithBadUsername()
31 $application = new Application($this->getClient()->getKernel());
32 $application->add(new ExportCommand());
34 $command = $application->find('wallabag:export');
36 $tester = new CommandTester($command);
38 'command' => $command->getName(),
39 'username' => 'unknown',
42 $this->assertContains('User "unknown" not found', $tester->getDisplay());
45 public function testExportCommand()
47 $application = new Application($this->getClient()->getKernel());
48 $application->add(new ExportCommand());
50 $command = $application->find('wallabag:export');
52 $tester = new CommandTester($command);
54 'command' => $command->getName(),
55 'username' => 'admin',
58 $this->assertContains('Exporting 5 entrie(s) for user admin...', $tester->getDisplay());
59 $this->assertContains('Done', $tester->getDisplay());
60 $this->assertFileExists('admin-export.json');
63 public function testExportCommandWithSpecialPath()
65 $application = new Application($this->getClient()->getKernel());
66 $application->add(new ExportCommand());
68 $command = $application->find('wallabag:export');
70 $tester = new CommandTester($command);
72 'command' => $command->getName(),
73 'username' => 'admin',
74 'filepath' => 'specialexport.json',
77 $this->assertFileExists('specialexport.json');