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
;
10 class ImportCommandTest
extends WallabagCoreTestCase
13 * @expectedException Symfony\Component\Console\Exception\RuntimeException
14 * @expectedExceptionMessage Not enough arguments
16 public function testRunImportCommandWithoutArguments()
18 $application = new Application($this->getClient()->getKernel());
19 $application->add(new ImportCommand());
21 $command = $application->find('wallabag:import');
23 $tester = new CommandTester($command);
25 'command' => $command->getName(),
30 * @expectedException Symfony\Component\Config\Definition\Exception\Exception
31 * @expectedExceptionMessage not found
33 public function testRunImportCommandWithoutFilepath()
35 $application = new Application($this->getClient()->getKernel());
36 $application->add(new ImportCommand());
38 $command = $application->find('wallabag:import');
40 $tester = new CommandTester($command);
42 'command' => $command->getName(),
49 * @expectedException Symfony\Component\Config\Definition\Exception\Exception
50 * @expectedExceptionMessage User with id
52 public function testRunImportCommandWithoutUserId()
54 $application = new Application($this->getClient()->getKernel());
55 $application->add(new ImportCommand());
57 $command = $application->find('wallabag:import');
59 $tester = new CommandTester($command);
61 'command' => $command->getName(),
67 public function testRunImportCommand()
69 $application = new Application($this->getClient()->getKernel());
70 $application->add(new ImportCommand());
72 $command = $application->find('wallabag:import');
74 $tester = new CommandTester($command);
76 'command' => $command->getName(),
78 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.root_dir').'/../tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json',
82 $this->assertContains('imported', $tester->getDisplay());
83 $this->assertContains('already saved', $tester->getDisplay());