3 namespace Tests\Wallabag\ImportBundle\Command
;
5 use Symfony\Bundle\FrameworkBundle\Console\Application
;
6 use Symfony\Component\Console\Tester\CommandTester
;
7 use Tests\Wallabag\CoreBundle\WallabagCoreTestCase
;
8 use Wallabag\ImportBundle\Command\ImportCommand
;
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(),
43 'username' => 'admin',
49 * @expectedException \Doctrine\ORM\NoResultException
51 public function testRunImportCommandWithWrongUsername()
53 $application = new Application($this->getClient()->getKernel());
54 $application->add(new ImportCommand());
56 $command = $application->find('wallabag:import');
58 $tester = new CommandTester($command);
60 'command' => $command->getName(),
61 'username' => 'random',
66 public function testRunImportCommand()
68 $application = new Application($this->getClient()->getKernel());
69 $application->add(new ImportCommand());
71 $command = $application->find('wallabag:import');
73 $tester = new CommandTester($command);
75 'command' => $command->getName(),
76 'username' => 'admin',
77 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.project_dir') . '/tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json',
81 $this->assertContains('imported', $tester->getDisplay());
82 $this->assertContains('already saved', $tester->getDisplay());
85 public function testRunImportCommandWithUserId()
87 $application = new Application($this->getClient()->getKernel());
88 $application->add(new ImportCommand());
90 $command = $application->find('wallabag:import');
92 $tester = new CommandTester($command);
94 'command' => $command->getName(),
96 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.project_dir') . '/tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json',
97 '--useUserId' => true,
101 $this->assertContains('imported', $tester->getDisplay());
102 $this->assertContains('already saved', $tester->getDisplay());