3 namespace Tests\Wallabag\CoreBundle\Command
;
5 use Symfony\Bundle\FrameworkBundle\Console\Application
;
6 use Symfony\Component\Console\Tester\CommandTester
;
7 use Wallabag\CoreBundle\Command\ExportCommand
;
8 use Tests\Wallabag\CoreBundle\WallabagCoreTestCase
;
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 6 entrie(s) for user « admin »... Done', $tester->getDisplay());
59 $this->assertFileExists('admin-export.json');
62 public function testExportCommandWithSpecialPath()
64 $application = new Application($this->getClient()->getKernel());
65 $application->add(new ExportCommand());
67 $command = $application->find('wallabag:export');
69 $tester = new CommandTester($command);
71 'command' => $command->getName(),
72 'username' => 'admin',
73 'filepath' => 'specialexport.json'
76 $this->assertFileExists('specialexport.json');