From: Thomas Citharel Date: Sun, 22 Jan 2017 12:19:46 +0000 (+0100) Subject: add filepath test X-Git-Tag: 2.2.0~3^2~4^2~1 X-Git-Url: https://git.immae.eu/?p=github%2Fwallabag%2Fwallabag.git;a=commitdiff_plain;h=a607b7a9c0870bcdfb4b4e7920d20b5ed39f14fe add filepath test Signed-off-by: Thomas Citharel --- 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 'User from which to export entries' ) ->addArgument( - 'filename', + 'filepath', InputArgument::OPTIONAL, 'Path of the exported file' ) @@ -46,7 +46,7 @@ class ExportCommand extends ContainerAwareCommand $output->write(sprintf('Exporting %d entrie(s) for user « %s »... ', count($entries), $user->getUserName())); - $filePath = $input->getArgument('filename'); + $filePath = $input->getArgument('filepath'); if (!$filePath) { $filePath = $this->getContainer()->getParameter('kernel.root_dir') . '/../' . sprintf('%s-export', $user->getUsername()); } 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 $this->assertContains('Exporting 6 entrie(s) for user « admin »... Done', $tester->getDisplay()); } + + public function testExportCommandWithSpecialPath() + { + $application = new Application($this->getClient()->getKernel()); + $application->add(new ExportCommand()); + + $command = $application->find('wallabag:export'); + + $tester = new CommandTester($command); + $tester->execute([ + 'command' => $command->getName(), + 'username' => 'admin', + 'filepath' => 'specialexport.json' + ]); + + $this->assertFileExists('specialexport.json'); + } }