aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Wallabag/CoreBundle/Command/ExportCommand.php4
-rw-r--r--tests/Wallabag/CoreBundle/Command/ExportCommandTest.php17
2 files changed, 19 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Command/ExportCommand.php b/src/Wallabag/CoreBundle/Command/ExportCommand.php
index 9c3c3fef..0cf5de48 100644
--- a/src/Wallabag/CoreBundle/Command/ExportCommand.php
+++ b/src/Wallabag/CoreBundle/Command/ExportCommand.php
@@ -23,7 +23,7 @@ class ExportCommand extends ContainerAwareCommand
23 'User from which to export entries' 23 'User from which to export entries'
24 ) 24 )
25 ->addArgument( 25 ->addArgument(
26 'filename', 26 'filepath',
27 InputArgument::OPTIONAL, 27 InputArgument::OPTIONAL,
28 'Path of the exported file' 28 'Path of the exported file'
29 ) 29 )
@@ -46,7 +46,7 @@ class ExportCommand extends ContainerAwareCommand
46 46
47 $output->write(sprintf('Exporting %d entrie(s) for user « <comment>%s</comment> »... ', count($entries), $user->getUserName())); 47 $output->write(sprintf('Exporting %d entrie(s) for user « <comment>%s</comment> »... ', count($entries), $user->getUserName()));
48 48
49 $filePath = $input->getArgument('filename'); 49 $filePath = $input->getArgument('filepath');
50 if (!$filePath) { 50 if (!$filePath) {
51 $filePath = $this->getContainer()->getParameter('kernel.root_dir') . '/../' . sprintf('%s-export', $user->getUsername()); 51 $filePath = $this->getContainer()->getParameter('kernel.root_dir') . '/../' . sprintf('%s-export', $user->getUsername());
52 } 52 }
diff --git a/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php b/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php
index 41491838..4c66e051 100644
--- a/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php
+++ b/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php
@@ -57,4 +57,21 @@ class ExportCommandTest extends WallabagCoreTestCase
57 57
58 $this->assertContains('Exporting 6 entrie(s) for user « admin »... Done', $tester->getDisplay()); 58 $this->assertContains('Exporting 6 entrie(s) for user « admin »... Done', $tester->getDisplay());
59 } 59 }
60
61 public function testExportCommandWithSpecialPath()
62 {
63 $application = new Application($this->getClient()->getKernel());
64 $application->add(new ExportCommand());
65
66 $command = $application->find('wallabag:export');
67
68 $tester = new CommandTester($command);
69 $tester->execute([
70 'command' => $command->getName(),
71 'username' => 'admin',
72 'filepath' => 'specialexport.json'
73 ]);
74
75 $this->assertFileExists('specialexport.json');
76 }
60} 77}