From 8303b037fb4e64b542f6f755828b999fdf6eebb0 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sun, 22 Jan 2017 12:51:14 +0100 Subject: add cli export Signed-off-by: Thomas Citharel --- .../CoreBundle/Command/ExportCommandTest.php | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/Wallabag/CoreBundle/Command/ExportCommandTest.php (limited to 'tests/Wallabag/CoreBundle/Command') diff --git a/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php b/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php new file mode 100644 index 00000000..41491838 --- /dev/null +++ b/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php @@ -0,0 +1,60 @@ +getClient()->getKernel()); + $application->add(new ExportCommand()); + + $command = $application->find('wallabag:export'); + + $tester = new CommandTester($command); + $tester->execute([ + 'command' => $command->getName(), + ]); + } + + public function testExportCommandWithBadUsername() + { + $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' => 'unknown', + ]); + + $this->assertContains('User "unknown" not found', $tester->getDisplay()); + } + + public function testExportCommand() + { + $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', + ]); + + $this->assertContains('Exporting 6 entrie(s) for user « admin »... Done', $tester->getDisplay()); + } +} -- cgit v1.2.3 From a607b7a9c0870bcdfb4b4e7920d20b5ed39f14fe Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sun, 22 Jan 2017 13:19:46 +0100 Subject: add filepath test Signed-off-by: Thomas Citharel --- tests/Wallabag/CoreBundle/Command/ExportCommandTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/Wallabag/CoreBundle/Command') 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'); + } } -- cgit v1.2.3 From 3b0380f049d408f0721e28218170c562153a56e5 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 24 Jan 2017 20:42:02 +0100 Subject: Fix phpcs and tests --- tests/Wallabag/CoreBundle/Command/ExportCommandTest.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/Wallabag/CoreBundle/Command') diff --git a/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php b/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php index 4c66e051..6798c5d7 100644 --- a/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php @@ -56,6 +56,7 @@ class ExportCommandTest extends WallabagCoreTestCase ]); $this->assertContains('Exporting 6 entrie(s) for user « admin »... Done', $tester->getDisplay()); + $this->assertFileExists('admin-export.json'); } public function testExportCommandWithSpecialPath() -- cgit v1.2.3