diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-09-11 20:24:04 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-09-11 22:15:31 +0200 |
commit | 015c7a8359c950f9621b38b11c3973860a981da8 (patch) | |
tree | c9564ff38242df100e19f2de77d8d640599c0ea2 /src/Wallabag/ImportBundle | |
parent | 7d862f83b95d24b4f081d73ca7b0bdf4435ae008 (diff) | |
download | wallabag-015c7a8359c950f9621b38b11c3973860a981da8.tar.gz wallabag-015c7a8359c950f9621b38b11c3973860a981da8.tar.zst wallabag-015c7a8359c950f9621b38b11c3973860a981da8.zip |
Add more tests
And ability to define how many messages can be hanle by the redis worker before stopping (usefull for tests)
Diffstat (limited to 'src/Wallabag/ImportBundle')
4 files changed, 7 insertions, 3 deletions
diff --git a/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php b/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php index 85c5a903..5f90e00f 100644 --- a/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php +++ b/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php | |||
@@ -5,6 +5,7 @@ namespace Wallabag\ImportBundle\Command; | |||
5 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | 5 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
6 | use Symfony\Component\Config\Definition\Exception\Exception; | 6 | use Symfony\Component\Config\Definition\Exception\Exception; |
7 | use Symfony\Component\Console\Input\InputArgument; | 7 | use Symfony\Component\Console\Input\InputArgument; |
8 | use Symfony\Component\Console\Input\InputOption; | ||
8 | use Symfony\Component\Console\Input\InputInterface; | 9 | use Symfony\Component\Console\Input\InputInterface; |
9 | use Symfony\Component\Console\Output\OutputInterface; | 10 | use Symfony\Component\Console\Output\OutputInterface; |
10 | use Simpleue\Worker\QueueWorker; | 11 | use Simpleue\Worker\QueueWorker; |
@@ -17,6 +18,7 @@ class RedisWorkerCommand extends ContainerAwareCommand | |||
17 | ->setName('wallabag:import:redis-worker') | 18 | ->setName('wallabag:import:redis-worker') |
18 | ->setDescription('Launch Redis worker') | 19 | ->setDescription('Launch Redis worker') |
19 | ->addArgument('serviceName', InputArgument::REQUIRED, 'Service to use: wallabag_v1, wallabag_v2, pocket or readability') | 20 | ->addArgument('serviceName', InputArgument::REQUIRED, 'Service to use: wallabag_v1, wallabag_v2, pocket or readability') |
21 | ->addOption('maxIterations', '', InputOption::VALUE_OPTIONAL, 'Number of iterations before stoping', false) | ||
20 | ; | 22 | ; |
21 | } | 23 | } |
22 | 24 | ||
@@ -33,7 +35,8 @@ class RedisWorkerCommand extends ContainerAwareCommand | |||
33 | 35 | ||
34 | $worker = new QueueWorker( | 36 | $worker = new QueueWorker( |
35 | $this->getContainer()->get('wallabag_import.queue.redis.'.$serviceName), | 37 | $this->getContainer()->get('wallabag_import.queue.redis.'.$serviceName), |
36 | $this->getContainer()->get('wallabag_import.consumer.redis.'.$serviceName) | 38 | $this->getContainer()->get('wallabag_import.consumer.redis.'.$serviceName), |
39 | $input->getOption('maxIterations') | ||
37 | ); | 40 | ); |
38 | 41 | ||
39 | $worker->start(); | 42 | $worker->start(); |
diff --git a/src/Wallabag/ImportBundle/Controller/ReadabilityController.php b/src/Wallabag/ImportBundle/Controller/ReadabilityController.php index 61243042..8775e8a3 100644 --- a/src/Wallabag/ImportBundle/Controller/ReadabilityController.php +++ b/src/Wallabag/ImportBundle/Controller/ReadabilityController.php | |||
@@ -31,7 +31,7 @@ class ReadabilityController extends Controller | |||
31 | $markAsRead = $form->get('mark_as_read')->getData(); | 31 | $markAsRead = $form->get('mark_as_read')->getData(); |
32 | $name = 'readability_'.$this->getUser()->getId().'.json'; | 32 | $name = 'readability_'.$this->getUser()->getId().'.json'; |
33 | 33 | ||
34 | if (in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { | 34 | if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { |
35 | $res = $readability | 35 | $res = $readability |
36 | ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) | 36 | ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) |
37 | ->setMarkAsRead($markAsRead) | 37 | ->setMarkAsRead($markAsRead) |
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagController.php b/src/Wallabag/ImportBundle/Controller/WallabagController.php index 1e6114c5..3c2dd6d1 100644 --- a/src/Wallabag/ImportBundle/Controller/WallabagController.php +++ b/src/Wallabag/ImportBundle/Controller/WallabagController.php | |||
@@ -45,7 +45,7 @@ abstract class WallabagController extends Controller | |||
45 | $markAsRead = $form->get('mark_as_read')->getData(); | 45 | $markAsRead = $form->get('mark_as_read')->getData(); |
46 | $name = $this->getUser()->getId().'.json'; | 46 | $name = $this->getUser()->getId().'.json'; |
47 | 47 | ||
48 | if (in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { | 48 | if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { |
49 | $res = $wallabag | 49 | $res = $wallabag |
50 | ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) | 50 | ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) |
51 | ->setMarkAsRead($markAsRead) | 51 | ->setMarkAsRead($markAsRead) |
diff --git a/src/Wallabag/ImportBundle/Form/Type/UploadImportType.php b/src/Wallabag/ImportBundle/Form/Type/UploadImportType.php index 92a167d9..f50424c1 100644 --- a/src/Wallabag/ImportBundle/Form/Type/UploadImportType.php +++ b/src/Wallabag/ImportBundle/Form/Type/UploadImportType.php | |||
@@ -15,6 +15,7 @@ class UploadImportType extends AbstractType | |||
15 | $builder | 15 | $builder |
16 | ->add('file', FileType::class, [ | 16 | ->add('file', FileType::class, [ |
17 | 'label' => 'import.form.file_label', | 17 | 'label' => 'import.form.file_label', |
18 | 'required' => true, | ||
18 | ]) | 19 | ]) |
19 | ->add('mark_as_read', CheckboxType::class, [ | 20 | ->add('mark_as_read', CheckboxType::class, [ |
20 | 'label' => 'import.form.mark_as_read_label', | 21 | 'label' => 'import.form.mark_as_read_label', |