3 namespace Tests\Wallabag\ImportBundle\Command
;
5 use Symfony\Bundle\FrameworkBundle\Console\Application
;
6 use Symfony\Component\Console\Tester\CommandTester
;
7 use Wallabag\ImportBundle\Command\ImportCommand
;
8 use Tests\Wallabag\CoreBundle\WallabagCoreTestCase
;
9 use M6Web\Component\RedisMock\RedisMockFactory
;
11 class ImportCommandTest
extends WallabagCoreTestCase
14 * @expectedException Symfony\Component\Console\Exception\RuntimeException
15 * @expectedExceptionMessage Not enough arguments
17 public function testRunImportCommandWithoutArguments()
19 $application = new Application($this->getClient()->getKernel());
20 $application->add(new ImportCommand());
22 $command = $application->find('wallabag:import');
24 $tester = new CommandTester($command);
26 'command' => $command->getName(),
31 * @expectedException Symfony\Component\Config\Definition\Exception\Exception
32 * @expectedExceptionMessage not found
34 public function testRunImportCommandWithoutFilepath()
36 $application = new Application($this->getClient()->getKernel());
37 $application->add(new ImportCommand());
39 $command = $application->find('wallabag:import');
41 $tester = new CommandTester($command);
43 'command' => $command->getName(),
50 * @expectedException Symfony\Component\Config\Definition\Exception\Exception
51 * @expectedExceptionMessage User with id
53 public function testRunImportCommandWithoutUserId()
55 $application = new Application($this->getClient()->getKernel());
56 $application->add(new ImportCommand());
58 $command = $application->find('wallabag:import');
60 $tester = new CommandTester($command);
62 'command' => $command->getName(),
68 public function testRunImportCommand()
70 $application = new Application($this->getClient()->getKernel());
71 $application->add(new ImportCommand());
73 $command = $application->find('wallabag:import');
75 $tester = new CommandTester($command);
77 'command' => $command->getName(),
79 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.root_dir').'/../tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json',
83 $this->assertContains('imported', $tester->getDisplay());
84 $this->assertContains('already saved', $tester->getDisplay());