diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2017-10-23 11:09:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-23 11:09:17 +0200 |
commit | 1953a872932a63792293b4aec087880265ba89f7 (patch) | |
tree | fd16599e737fcdaf193c933ef3ec4a4ee248b117 /tests/Wallabag/ImportBundle/Command | |
parent | d83d25dadec2c38460a32d96f5d2903426fec9d3 (diff) | |
parent | 702f2d67d60ca963492b90dad74cb5f8dcc84e51 (diff) | |
download | wallabag-1953a872932a63792293b4aec087880265ba89f7.tar.gz wallabag-1953a872932a63792293b4aec087880265ba89f7.tar.zst wallabag-1953a872932a63792293b4aec087880265ba89f7.zip |
Merge pull request #3011 from wallabag/2.3
wallabag 2.3.0
Diffstat (limited to 'tests/Wallabag/ImportBundle/Command')
-rw-r--r-- | tests/Wallabag/ImportBundle/Command/ImportCommandTest.php | 36 | ||||
-rw-r--r-- | tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php | 8 |
2 files changed, 30 insertions, 14 deletions
diff --git a/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php b/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php index 7be1eb18..30aee4d8 100644 --- a/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php +++ b/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php | |||
@@ -4,13 +4,13 @@ namespace Tests\Wallabag\ImportBundle\Command; | |||
4 | 4 | ||
5 | use Symfony\Bundle\FrameworkBundle\Console\Application; | 5 | use Symfony\Bundle\FrameworkBundle\Console\Application; |
6 | use Symfony\Component\Console\Tester\CommandTester; | 6 | use Symfony\Component\Console\Tester\CommandTester; |
7 | use Wallabag\ImportBundle\Command\ImportCommand; | ||
8 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | 7 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; |
8 | use Wallabag\ImportBundle\Command\ImportCommand; | ||
9 | 9 | ||
10 | class ImportCommandTest extends WallabagCoreTestCase | 10 | class ImportCommandTest extends WallabagCoreTestCase |
11 | { | 11 | { |
12 | /** | 12 | /** |
13 | * @expectedException Symfony\Component\Console\Exception\RuntimeException | 13 | * @expectedException \Symfony\Component\Console\Exception\RuntimeException |
14 | * @expectedExceptionMessage Not enough arguments | 14 | * @expectedExceptionMessage Not enough arguments |
15 | */ | 15 | */ |
16 | public function testRunImportCommandWithoutArguments() | 16 | public function testRunImportCommandWithoutArguments() |
@@ -27,7 +27,7 @@ class ImportCommandTest extends WallabagCoreTestCase | |||
27 | } | 27 | } |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * @expectedException Symfony\Component\Config\Definition\Exception\Exception | 30 | * @expectedException \Symfony\Component\Config\Definition\Exception\Exception |
31 | * @expectedExceptionMessage not found | 31 | * @expectedExceptionMessage not found |
32 | */ | 32 | */ |
33 | public function testRunImportCommandWithoutFilepath() | 33 | public function testRunImportCommandWithoutFilepath() |
@@ -40,16 +40,15 @@ class ImportCommandTest extends WallabagCoreTestCase | |||
40 | $tester = new CommandTester($command); | 40 | $tester = new CommandTester($command); |
41 | $tester->execute([ | 41 | $tester->execute([ |
42 | 'command' => $command->getName(), | 42 | 'command' => $command->getName(), |
43 | 'userId' => 1, | 43 | 'username' => 'admin', |
44 | 'filepath' => 1, | 44 | 'filepath' => 1, |
45 | ]); | 45 | ]); |
46 | } | 46 | } |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * @expectedException Symfony\Component\Config\Definition\Exception\Exception | 49 | * @expectedException \Doctrine\ORM\NoResultException |
50 | * @expectedExceptionMessage User with id | ||
51 | */ | 50 | */ |
52 | public function testRunImportCommandWithoutUserId() | 51 | public function testRunImportCommandWithWrongUsername() |
53 | { | 52 | { |
54 | $application = new Application($this->getClient()->getKernel()); | 53 | $application = new Application($this->getClient()->getKernel()); |
55 | $application->add(new ImportCommand()); | 54 | $application->add(new ImportCommand()); |
@@ -59,7 +58,7 @@ class ImportCommandTest extends WallabagCoreTestCase | |||
59 | $tester = new CommandTester($command); | 58 | $tester = new CommandTester($command); |
60 | $tester->execute([ | 59 | $tester->execute([ |
61 | 'command' => $command->getName(), | 60 | 'command' => $command->getName(), |
62 | 'userId' => 0, | 61 | 'username' => 'random', |
63 | 'filepath' => './', | 62 | 'filepath' => './', |
64 | ]); | 63 | ]); |
65 | } | 64 | } |
@@ -74,12 +73,29 @@ class ImportCommandTest extends WallabagCoreTestCase | |||
74 | $tester = new CommandTester($command); | 73 | $tester = new CommandTester($command); |
75 | $tester->execute([ | 74 | $tester->execute([ |
76 | 'command' => $command->getName(), | 75 | 'command' => $command->getName(), |
77 | 'userId' => 1, | 76 | 'username' => 'admin', |
78 | 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.root_dir').'/../tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json', | 77 | 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.project_dir') . '/tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json', |
79 | '--importer' => 'v2', | 78 | '--importer' => 'v2', |
80 | ]); | 79 | ]); |
81 | 80 | ||
82 | $this->assertContains('imported', $tester->getDisplay()); | 81 | $this->assertContains('imported', $tester->getDisplay()); |
83 | $this->assertContains('already saved', $tester->getDisplay()); | 82 | $this->assertContains('already saved', $tester->getDisplay()); |
84 | } | 83 | } |
84 | |||
85 | public function testRunImportCommandWithUserId() | ||
86 | { | ||
87 | $application = new Application($this->getClient()->getKernel()); | ||
88 | $application->add(new ImportCommand()); | ||
89 | |||
90 | $command = $application->find('wallabag:import'); | ||
91 | |||
92 | $tester = new CommandTester($command); | ||
93 | $tester->execute([ | ||
94 | 'command' => $command->getName(), | ||
95 | 'username' => 1, | ||
96 | 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.project_dir') . '/tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json', | ||
97 | '--useUserId' => true, | ||
98 | '--importer' => 'v2', | ||
99 | ]); | ||
100 | } | ||
85 | } | 101 | } |
diff --git a/tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php b/tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php index 74952847..af62550c 100644 --- a/tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php +++ b/tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php | |||
@@ -2,16 +2,16 @@ | |||
2 | 2 | ||
3 | namespace Tests\Wallabag\ImportBundle\Command; | 3 | namespace Tests\Wallabag\ImportBundle\Command; |
4 | 4 | ||
5 | use M6Web\Component\RedisMock\RedisMockFactory; | ||
5 | use Symfony\Bundle\FrameworkBundle\Console\Application; | 6 | use Symfony\Bundle\FrameworkBundle\Console\Application; |
6 | use Symfony\Component\Console\Tester\CommandTester; | 7 | use Symfony\Component\Console\Tester\CommandTester; |
7 | use Wallabag\ImportBundle\Command\RedisWorkerCommand; | ||
8 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | 8 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; |
9 | use M6Web\Component\RedisMock\RedisMockFactory; | 9 | use Wallabag\ImportBundle\Command\RedisWorkerCommand; |
10 | 10 | ||
11 | class RedisWorkerCommandTest extends WallabagCoreTestCase | 11 | class RedisWorkerCommandTest extends WallabagCoreTestCase |
12 | { | 12 | { |
13 | /** | 13 | /** |
14 | * @expectedException Symfony\Component\Console\Exception\RuntimeException | 14 | * @expectedException \Symfony\Component\Console\Exception\RuntimeException |
15 | * @expectedExceptionMessage Not enough arguments (missing: "serviceName") | 15 | * @expectedExceptionMessage Not enough arguments (missing: "serviceName") |
16 | */ | 16 | */ |
17 | public function testRunRedisWorkerCommandWithoutArguments() | 17 | public function testRunRedisWorkerCommandWithoutArguments() |
@@ -28,7 +28,7 @@ class RedisWorkerCommandTest extends WallabagCoreTestCase | |||
28 | } | 28 | } |
29 | 29 | ||
30 | /** | 30 | /** |
31 | * @expectedException Symfony\Component\Config\Definition\Exception\Exception | 31 | * @expectedException \Symfony\Component\Config\Definition\Exception\Exception |
32 | * @expectedExceptionMessage No queue or consumer found for service name | 32 | * @expectedExceptionMessage No queue or consumer found for service name |
33 | */ | 33 | */ |
34 | public function testRunRedisWorkerCommandWithBadService() | 34 | public function testRunRedisWorkerCommandWithBadService() |