]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Added elCurator import 4175/head
authorNicolas Lœuillet <nicolas@loeuillet.org>
Thu, 7 Nov 2019 11:17:01 +0000 (12:17 +0100)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Fri, 15 Nov 2019 15:08:36 +0000 (16:08 +0100)
25 files changed:
app/config/config.yml
src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml
src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml
src/Wallabag/CoreBundle/Resources/translations/messages.th.yml
src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
src/Wallabag/ImportBundle/Controller/ElcuratorController.php [new file with mode: 0644]
src/Wallabag/ImportBundle/Import/ElcuratorImport.php [new file with mode: 0644]
src/Wallabag/ImportBundle/Resources/config/rabbit.yml
src/Wallabag/ImportBundle/Resources/config/redis.yml
src/Wallabag/ImportBundle/Resources/config/services.yml
src/Wallabag/ImportBundle/Resources/views/Elcurator/index.html.twig [new file with mode: 0644]
tests/Wallabag/ImportBundle/Controller/ElcuratorControllerTest.php [new file with mode: 0644]
tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php
tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php
tests/Wallabag/ImportBundle/fixtures/elcurator.json [new file with mode: 0644]

index 642e198d413e2a1c232ef4044346ff748633fc72..0b325afe53db78ef4179a53abd876c70b1d7146c 100644 (file)
@@ -261,6 +261,11 @@ old_sound_rabbit_mq:
             exchange_options:
                 name: 'wallabag.import.wallabag_v2'
                 type: topic
+        import_elcurator:
+            connection: default
+            exchange_options:
+                name: 'wallabag.import.elcurator'
+                type: topic
         import_firefox:
             connection: default
             exchange_options:
@@ -326,6 +331,15 @@ old_sound_rabbit_mq:
                 name: 'wallabag.import.wallabag_v2'
             callback: wallabag_import.consumer.amqp.wallabag_v2
             qos_options: {prefetch_count: "%rabbitmq_prefetch_count%"}
+        import_elcurator:
+            connection: default
+            exchange_options:
+                name: 'wallabag.import.elcurator'
+                type: topic
+            queue_options:
+                name: 'wallabag.import.elcurator'
+            callback: wallabag_import.consumer.amqp.elcurator
+            qos_options: {prefetch_count: "%rabbitmq_prefetch_count%"}
         import_firefox:
             connection: default
             exchange_options:
index 6f381408b586baaa7f4e458c63215a23af169efe..8573ba72ec837275c0b6250e58d80bb42608aa86 100644 (file)
@@ -465,6 +465,9 @@ import:
     # wallabag_v2:
     #     page_title: 'Import > Wallabag v2'
     #     description: 'This importer will import all your wallabag v2 articles. Go to All articles, then, on the export sidebar, click on "JSON". You will have a "All articles.json" file.'
+    # elcurator:
+    #     page_title: 'Import > elCurator'
+    #     description: 'This importer will import all your elCurator articles. Go to your preferences in your elCurator account and then, export your content. You will have a JSON file.'
     # readability:
     #     page_title: 'Import > Readability'
     #     description: 'This importer will import all your Readability articles. On the tools (https://www.readability.com/tools/) page, click on "Export your data" in the "Data Export" section. You will received an email to download a json (which does not end with .json in fact).'
index 7efb18aa3e5c7721b7a883a92b21c04ccf8a6bd2..50e67d47bc019231b3d85688f0bd27b4b4abbd27 100644 (file)
@@ -465,6 +465,9 @@ import:
     wallabag_v2:
         page_title: 'Aus wallabag v2 importieren'
         description: 'Dieser Import wird all deine Artikel aus wallabag v2 importieren. Gehe auf "Alle Artikel" und dann, in der Exportieren-Seitenleiste auf "JSON". Dabei erhältst du eine "All articles.json"-Datei.'
+    # elcurator:
+    #     page_title: 'Import > elCurator'
+    #     description: 'This importer will import all your elCurator articles. Go to your preferences in your elCurator account and then, export your content. You will have a JSON file.'
     readability:
         page_title: 'Aus Readability importieren'
         description: 'Dieser Import wird all deine Artikel aus Readability importieren. Auf der Tools Seite (https://www.readability.com/tools/) klickst du auf "Exportiere deine Daten" in dem Abschnitt "Datenexport". Du wirst eine E-Mail mit einem Downloadlink zu einer json Datei, die aber nicht auf .json endet, erhalten'
index cf98e408738cdc9a42d8a404096d991987e84a13..206d35627e338325c6a4300f59cb39b58c2e8584 100644 (file)
@@ -465,6 +465,9 @@ import:
     wallabag_v2:
         page_title: 'Import > Wallabag v2'
         description: 'This importer will import all your wallabag v2 articles. Go to All articles, then, on the export sidebar, click on "JSON". You will have a "All articles.json" file.'
+    elcurator:
+        page_title: 'Import > elCurator'
+        description: 'This importer will import all your elCurator articles. Go to your preferences in your elCurator account and then, export your content. You will have a JSON file.'
     readability:
         page_title: 'Import > Readability'
         description: 'This importer will import all your Readability articles. On the tools (https://www.readability.com/tools/) page, click on "Export your data" in the "Data Export" section. You will received an email to download a json (which does not end with .json in fact).'
index b7cdd261e511a5caaf3de3ccf715a42726f1024f..10f5e79a85962d3475b5e36c845bd07e5bc6d35d 100644 (file)
@@ -465,6 +465,9 @@ import:
     wallabag_v2:
         page_title: 'Importar > Wallabag v2'
         description: 'Importa todos tus artículos de wallabag v2. En la sección Todos los artículos, en la barra lateral, haga clic en "JSON". Obtendrás un archivo llamado "All articles.json".'
+    # elcurator:
+    #     page_title: 'Import > elCurator'
+    #     description: 'This importer will import all your elCurator articles. Go to your preferences in your elCurator account and then, export your content. You will have a JSON file.'
     readability:
         page_title: 'Importar > Readability'
         description: 'Importa todos tus artículos de Readability. En la página de herramientas (https://www.readability.com/tools/), haga clic en "Exportar tus datos" en la sección "Exportar datos". Recibirás un correo electrónico para descargar un JSON (que no tiene extensión .json).'
index 66e83e16a7d856b9fec9b4b1016b3552888983d7..730b7e68f901dd6cc43509787cc77acc2088885c 100644 (file)
@@ -465,6 +465,9 @@ import:
     wallabag_v2:
         page_title: 'درون‌ریزی > Wallabag v2'
         description: 'این برنامه همهٔ داده‌های شما را در نسخهٔ ۲ wallabag درون‌ریزی می‌کند. به بخش «همهٔ مقاله‌ها» بروید و در بخش «برون‌ریزی» روی "JSON" کلیک کنید. با این کار شما پرونده‌ای به شکل "All articles.json" دریافت خواهید کرد.'
+    # elcurator:
+    #     page_title: 'Import > elCurator'
+    #     description: 'This importer will import all your elCurator articles. Go to your preferences in your elCurator account and then, export your content. You will have a JSON file.'
     readability:
         page_title: 'درون‌ریزی > Readability'
         # description: 'This importer will import all your Readability articles. On the tools (https://www.readability.com/tools/) page, click on "Export your data" in the "Data Export" section. You will received an email to download a json (which does not end with .json in fact).'
index 6fb856f2d714b7d862391aa5e2328452ad93b907..1eecd111aa6dcf5154271aeb1fe583a0f38205a5 100644 (file)
@@ -465,6 +465,9 @@ import:
     wallabag_v2:
         page_title: "Importer > wallabag v2"
         description: "Cet outil va importer tous vos articles d’une autre instance de wallabag v2. Allez dans tous vos articles, puis, sur la barre latérale, cliquez sur « JSON ». Vous allez récupérer un fichier « All articles.json »"
+    # elcurator:
+    #     page_title: 'Import > elCurator'
+    #     description: 'This importer will import all your elCurator articles. Go to your preferences in your elCurator account and then, export your content. You will have a JSON file.'
     readability:
         page_title: "Importer > Readability"
         description: "Cet outil va importer toutes vos données de Readability. Sur la page des outils (https://www.readability.com/tools/), cliquez sur « Export your data » dans la section « Data Export ». Vous allez recevoir un courriel avec un lien pour télécharger le json."
index 3640e0a0b87efe5315dce8b7b614720a3a773d91..f1a8e3b15493ff909fa048a816592e2b1187d273 100644 (file)
@@ -465,6 +465,9 @@ import:
     wallabag_v2:
         page_title: 'Importa da > Wallabag v2'
         description: 'Questo importatore copierà tutti i tuoi dati da un wallabag v2. Vai in "Tutti i contenuti", e, nella barra laterale di esportazione, clicca su "JSON". Otterrai un file "Tutti i contenuti.json'
+    # elcurator:
+    #     page_title: 'Import > elCurator'
+    #     description: 'This importer will import all your elCurator articles. Go to your preferences in your elCurator account and then, export your content. You will have a JSON file.'
     readability:
         page_title: 'Importa da > Readability'
         description: 'Questo importatore copierà tutti i tuoi articoli da Readability. Nella pagina strumenti (https://www.readability.com/tools/), clicca su "Export your data" nella sezione "Data Export". Riceverai una E-mail per scaricare un file json (che tuttavia non termina con .json).'
index cd60566a1ebfa7ccfcfcfa3369d5e478111463dc..89bf8b16c0dfd0d6fabf9a9249008095da1aaad6 100644 (file)
@@ -465,6 +465,9 @@ import:
     wallabag_v2:
         page_title: 'Importar > Wallabag v2'
         description: "Aquesta aisina importarà totas vòstras donadas d'una instància mai de wallabag v2. Anatz dins totes vòstres articles, puèi, sus la barra laterala, clicatz sus \"JSON\". Traparetz un fichièr \"All articles.json\"."
+    # elcurator:
+    #     page_title: 'Import > elCurator'
+    #     description: 'This importer will import all your elCurator articles. Go to your preferences in your elCurator account and then, export your content. You will have a JSON file.'
     readability:
         page_title: 'Importar > Readability'
         description: "Aquesta aisina importarà totas vòstres articles de Readability. Sus la pagina de l'aisina (https://www.readability.com/tools/), clicatz sus \"Export your data\" dins la seccion \"Data Export\". Recebretz un corrièl per telecargar un json (qu'acaba pas amb un .json de fach)."
index 909f70583c4c99979c38c2f9afc1a2320f4b82fa..0118ad218188d99832c0ddde19e61a34145ae2a8 100644 (file)
@@ -465,6 +465,9 @@ import:
     wallabag_v2:
         page_title: 'Import > Wallabag v2'
         description: 'Ten importer, zaimportuje wszystkie twoje artykułu z wallabag v2. Idź do wszystkich artykułów, a następnie na panelu exportu kliknij na "JSON". Otrzymasz plik "All articles.json".'
+    # elcurator:
+    #     page_title: 'Import > elCurator'
+    #     description: 'This importer will import all your elCurator articles. Go to your preferences in your elCurator account and then, export your content. You will have a JSON file.'
     readability:
         page_title: 'Import > Readability'
         description: 'Ten importer, zaimportuje wszystkie twoje artykuły z Readability. Na stronie narzędzi (https://www.readability.com/tools/), kliknij na "Export your data" w sekcji "Data Export". Otrzymach email z plikiem JSON (plik nie będzie zawierał rozszerzenia .json).'
index 47e7b4db8853cc1c3cf8dae32052c748fe8262b4..d0082cdac123d937ca0b9dcc31df6f8376878445 100644 (file)
@@ -465,6 +465,9 @@ import:
     wallabag_v2:
         page_title: 'Importar > Wallabag v2'
         description: 'Com este importador você importa todos os seus artigos do wallabag v2. Vá em Todos os artigos e então, na barra lateral de exportação, clique em "JSON". Você irá criar um arquivo "All articles.json".'
+    # elcurator:
+    #     page_title: 'Import > elCurator'
+    #     description: 'This importer will import all your elCurator articles. Go to your preferences in your elCurator account and then, export your content. You will have a JSON file.'
     readability:
         page_title: 'Importar > Readability'
         description: 'Este importador pode importar todos os artigos do Readability. Nas página ferramentas (https://www.readability.com/tools/), clique em "Export your data" na seção "Data Export". Você receberá um e-mail para fazer o download de um json (que de fato não termina com .json).'
index 380b52337773c14f6bbcafcbfe9ae7fb29d28937..c8e2dfb40af40769eca7302b53a8538f8d715d2d 100644 (file)
@@ -465,6 +465,9 @@ import:
     # wallabag_v2:
     #     page_title: 'Import > Wallabag v2'
     #     description: 'This importer will import all your wallabag v2 articles. Go to All articles, then, on the export sidebar, click on "JSON". You will have a "All articles.json" file.'
+    # elcurator:
+    #     page_title: 'Import > elCurator'
+    #     description: 'This importer will import all your elCurator articles. Go to your preferences in your elCurator account and then, export your content. You will have a JSON file.'
     # readability:
     #     page_title: 'Import > Readability'
     #     description: 'This importer will import all your Readability articles. On the tools (https://www.readability.com/tools/) page, click on "Export your data" in the "Data Export" section. You will received an email to download a json (which does not end with .json in fact).'
index a47525c6505c050462007c91a54448f03263f499..41379f90fdcc8d89eae196135e763981f126c7e2 100644 (file)
@@ -465,6 +465,9 @@ import:
     wallabag_v2:
         page_title: 'Импорт > Wallabag v2'
         description: 'Функция импорта добавит все ваши записи wallabag v2. Перейдите ко всем статьям, затем на боковой панели экспорта нажмите "JSON". У вас появится файл со всеми записями "All articles.json".'
+    # elcurator:
+    #     page_title: 'Import > elCurator'
+    #     description: 'This importer will import all your elCurator articles. Go to your preferences in your elCurator account and then, export your content. You will have a JSON file.'
     readability:
         page_title: 'Импорт > Readability'
         description: 'Функция импорта добавит все ваши записи для чтения. На странице инструментов (https://www.readability.com/tools/) нажмите "Экспорт ваших данных" в разделе "Экспорт данных". Вы получите электронное письмо для загрузки json (что не заканчивается только .json файлом).'
index 5879c48fb33f3794540f7c12dd575051801ffeea..b5a3bcb6129bd6e5c5852a8dfa360a86132fe03c 100644 (file)
@@ -465,6 +465,9 @@ import:
     wallabag_v2:
         page_title: 'นำเข้าข้อมูล > Wallabag v2'
         description: 'สำหรับผู้นำเข้าข้อมูลจะ import บทความ wallabag v2 ทั้งหมดของคุณ ไปยังบทความทั้งหมด, ดังนั้น, บน export sidebar, click ที่ "JSON" คุณจะมีไฟล์ "All articles.json"'
+    # elcurator:
+    #     page_title: 'Import > elCurator'
+    #     description: 'This importer will import all your elCurator articles. Go to your preferences in your elCurator account and then, export your content. You will have a JSON file.'
     readability:
         page_title: 'นำเข้าข้อมูล > Readability'
         description: 'สำหรับผู้นำเข้าข้อมูลจะ import บทความ Readability ทั้งหมดของคุณ ไปที่เครื่องมือ (https://www.readability.com/tools/) ของหน้านั้น, click ที่ "Export your data" ในส่วน "Data Export" คุณจะได้รับ email ไป download json (which does not end with .json in fact).'
index d023e3686377ad8f59b1a5e6397f3b12358a121c..4aaef78183c4911a3a0ee6f2c2042044dd520a70 100644 (file)
@@ -465,6 +465,9 @@ import:
     wallabag_v2:
         page_title: 'İçe Aktar > Wallabag v2'
         # description: 'This importer will import all your wallabag v2 articles. Go to All articles, then, on the export sidebar, click on "JSON". You will have a "All articles.json" file.'
+    # elcurator:
+    #     page_title: 'Import > elCurator'
+    #     description: 'This importer will import all your elCurator articles. Go to your preferences in your elCurator account and then, export your content. You will have a JSON file.'
     readability:
         page_title: 'İçe Aktar > Readability'
         # description: 'This importer will import all your Readability articles. On the tools (https://www.readability.com/tools/) page, click on "Export your data" in the "Data Export" section. You will received an email to download a json (which does not end with .json in fact).'
diff --git a/src/Wallabag/ImportBundle/Controller/ElcuratorController.php b/src/Wallabag/ImportBundle/Controller/ElcuratorController.php
new file mode 100644 (file)
index 0000000..174c2c9
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+
+namespace Wallabag\ImportBundle\Controller;
+
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\Annotation\Route;
+
+class ElcuratorController extends WallabagController
+{
+    /**
+     * @Route("/elcurator", name="import_elcurator")
+     */
+    public function indexAction(Request $request)
+    {
+        return parent::indexAction($request);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    protected function getImportService()
+    {
+        $service = $this->get('wallabag_import.elcurator.import');
+
+        if ($this->get('craue_config')->get('import_with_rabbitmq')) {
+            $service->setProducer($this->get('old_sound_rabbit_mq.import_elcurator_producer'));
+        } elseif ($this->get('craue_config')->get('import_with_redis')) {
+            $service->setProducer($this->get('wallabag_import.producer.redis.elcurator'));
+        }
+
+        return $service;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    protected function getImportTemplate()
+    {
+        return 'WallabagImportBundle:Elcurator:index.html.twig';
+    }
+}
diff --git a/src/Wallabag/ImportBundle/Import/ElcuratorImport.php b/src/Wallabag/ImportBundle/Import/ElcuratorImport.php
new file mode 100644 (file)
index 0000000..d128161
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+
+namespace Wallabag\ImportBundle\Import;
+
+class ElcuratorImport extends WallabagImport
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function getName()
+    {
+        return 'elcurator';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getUrl()
+    {
+        return 'import_elcurator';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getDescription()
+    {
+        return 'import.elcurator.description';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    protected function prepareEntry($entry = [])
+    {
+        return [
+            'url' => $entry['url'],
+            'title' => $entry['title'],
+            'created_at' => $entry['created_at'],
+            'is_archived' => 0,
+            'is_starred' => $entry['is_saved'],
+        ] + $entry;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    protected function setEntryAsRead(array $importedEntry)
+    {
+        $importedEntry['is_archived'] = 1;
+
+        return $importedEntry;
+    }
+}
index e9ecb8467dd4d4a6f3a13c3f6d15d627d40440ac..0bf0e761c1f69881d3c8b71497bd8945dcdcec51 100644 (file)
@@ -48,6 +48,14 @@ services:
             - "@wallabag_import.wallabag_v2.import"
             - "@event_dispatcher"
             - "@logger"
+    wallabag_import.consumer.amqp.elcurator:
+        class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
+        arguments:
+            - "@doctrine.orm.entity_manager"
+            - "@wallabag_user.user_repository"
+            - "@wallabag_import.elcurator.import"
+            - "@event_dispatcher"
+            - "@logger"
     wallabag_import.consumer.amqp.firefox:
         class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
         arguments:
index 091cdba002a9e22b472c9b1ad9e980fc7404efe6..40a6e22406c5e5249d2caf052f5924f78110ba45 100644 (file)
@@ -126,6 +126,27 @@ services:
             - "@event_dispatcher"
             - "@logger"
 
+    # elcurator
+    wallabag_import.queue.redis.elcurator:
+        class: Simpleue\Queue\RedisQueue
+        arguments:
+            - "@wallabag_core.redis.client"
+            - "wallabag.import.elcurator"
+
+    wallabag_import.producer.redis.elcurator:
+        class: Wallabag\ImportBundle\Redis\Producer
+        arguments:
+            - "@wallabag_import.queue.redis.elcurator"
+
+    wallabag_import.consumer.redis.elcurator:
+        class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer
+        arguments:
+            - "@doctrine.orm.entity_manager"
+            - "@wallabag_user.user_repository"
+            - "@wallabag_import.elcurator.import"
+            - "@event_dispatcher"
+            - "@logger"
+
     # firefox
     wallabag_import.queue.redis.firefox:
         class: Simpleue\Queue\RedisQueue
index 973c0d03ebb2963e930b39d5535858ea1187b9f5..d824da4ab113bbf908f16594ae3081e51afa866f 100644 (file)
@@ -48,6 +48,18 @@ services:
         tags:
             -  { name: wallabag_import.import, alias: wallabag_v2 }
 
+    wallabag_import.elcurator.import:
+        class: Wallabag\ImportBundle\Import\ElcuratorImport
+        arguments:
+            - "@doctrine.orm.entity_manager"
+            - "@wallabag_core.content_proxy"
+            - "@wallabag_core.tags_assigner"
+            - "@event_dispatcher"
+        calls:
+            - [ setLogger, [ "@logger" ]]
+        tags:
+            -  { name: wallabag_import.import, alias: elcurator }
+
     wallabag_import.readability.import:
         class: Wallabag\ImportBundle\Import\ReadabilityImport
         arguments:
diff --git a/src/Wallabag/ImportBundle/Resources/views/Elcurator/index.html.twig b/src/Wallabag/ImportBundle/Resources/views/Elcurator/index.html.twig
new file mode 100644 (file)
index 0000000..e3a0d70
--- /dev/null
@@ -0,0 +1,3 @@
+{% extends "WallabagImportBundle:WallabagV1:index.html.twig" %}
+
+{% block title %}{{ 'import.elcurator.page_title'|trans }}{% endblock %}
diff --git a/tests/Wallabag/ImportBundle/Controller/ElcuratorControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ElcuratorControllerTest.php
new file mode 100644 (file)
index 0000000..1850705
--- /dev/null
@@ -0,0 +1,132 @@
+<?php
+
+namespace Tests\Wallabag\ImportBundle\Controller;
+
+use Symfony\Component\HttpFoundation\File\UploadedFile;
+use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
+
+class ElcuratorControllerTest extends WallabagCoreTestCase
+{
+    public function testImportElcurator()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $crawler = $client->request('GET', '/import/elcurator');
+
+        $this->assertSame(200, $client->getResponse()->getStatusCode());
+        $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+        $this->assertSame(1, $crawler->filter('input[type=file]')->count());
+    }
+
+    public function testImportElcuratorWithRabbitEnabled()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 1);
+
+        $crawler = $client->request('GET', '/import/elcurator');
+
+        $this->assertSame(200, $client->getResponse()->getStatusCode());
+        $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+        $this->assertSame(1, $crawler->filter('input[type=file]')->count());
+
+        $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
+    }
+
+    public function testImportElcuratorBadFile()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $crawler = $client->request('GET', '/import/elcurator');
+        $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
+
+        $data = [
+            'upload_import_file[file]' => '',
+        ];
+
+        $client->submit($form, $data);
+
+        $this->assertSame(200, $client->getResponse()->getStatusCode());
+    }
+
+    public function testImportElcuratorWithRedisEnabled()
+    {
+        $this->checkRedis();
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $client->getContainer()->get('craue_config')->set('import_with_redis', 1);
+
+        $crawler = $client->request('GET', '/import/elcurator');
+
+        $this->assertSame(200, $client->getResponse()->getStatusCode());
+        $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+        $this->assertSame(1, $crawler->filter('input[type=file]')->count());
+
+        $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
+
+        $file = new UploadedFile(__DIR__ . '/../fixtures/elcurator.json', 'elcurator.json');
+
+        $data = [
+            'upload_import_file[file]' => $file,
+        ];
+
+        $client->submit($form, $data);
+
+        $this->assertSame(302, $client->getResponse()->getStatusCode());
+
+        $crawler = $client->followRedirect();
+
+        $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
+        $this->assertContains('flashes.import.notice.summary', $body[0]);
+
+        $this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.elcurator'));
+
+        $client->getContainer()->get('craue_config')->set('import_with_redis', 0);
+    }
+
+    public function testImportElcuratorWithFile()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $crawler = $client->request('GET', '/import/elcurator');
+        $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
+
+        $file = new UploadedFile(__DIR__ . '/../fixtures/elcurator.json', 'elcurator.json');
+
+        $data = [
+            'upload_import_file[file]' => $file,
+        ];
+
+        $client->submit($form, $data);
+
+        $this->assertSame(302, $client->getResponse()->getStatusCode());
+
+        $crawler = $client->followRedirect();
+
+        $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
+        $this->assertContains('flashes.import.notice.summary', $body[0]);
+
+        $content = $client->getContainer()
+            ->get('doctrine.orm.entity_manager')
+            ->getRepository('WallabagCoreBundle:Entry')
+            ->findByUrlAndUserId(
+                'https://devblog.lexik.fr/qualite-de-code-integration-de-php-git-hooks-dans-symfony2/',
+                $this->getLoggedInUserId()
+            );
+
+        $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
+
+        $this->assertSame('Qualité de code - Intégration de php-git-hooks dans Symfony2 - Experts Symfony et Drupal - Lexik', $content->getTitle());
+        $this->assertSame('2015-09-09', $content->getCreatedAt()->format('Y-m-d'));
+        $this->assertTrue($content->isStarred(), 'Entry is starred');
+
+        $tags = $content->getTags();
+        $this->assertContains('tag1', $tags, 'It includes the "tag1" tag');
+        $this->assertContains('tag2', $tags, 'It includes the "tag2" tag');
+    }
+}
index e1ec7c657dacbc18059a0f6a75a49e1bd54e0e83..f0edb78de7137ec5e7c423445ca1681b80ccc6a4 100644 (file)
@@ -24,6 +24,6 @@ class ImportControllerTest extends WallabagCoreTestCase
         $crawler = $client->request('GET', '/import/');
 
         $this->assertSame(200, $client->getResponse()->getStatusCode());
-        $this->assertSame(8, $crawler->filter('blockquote')->count());
+        $this->assertSame(9, $crawler->filter('blockquote')->count());
     }
 }
index 90192278c22d6c5ee5e10b48c217bbd927b7f6b1..963759b1e76829a0da9e267342ccf95308f19530 100644 (file)
@@ -121,6 +121,7 @@ class PinboardControllerTest extends WallabagCoreTestCase
         $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
         $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://ma.ttias.be is ok');
         $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://ma.ttias.be is ok');
+        $this->assertNull($content->getLanguage(), 'Language for https://ma.ttias.be is null');
 
         $tags = $content->getTags();
         $this->assertContains('foot', $tags, 'It includes the "foot" tag');
diff --git a/tests/Wallabag/ImportBundle/fixtures/elcurator.json b/tests/Wallabag/ImportBundle/fixtures/elcurator.json
new file mode 100644 (file)
index 0000000..58972d9
--- /dev/null
@@ -0,0 +1,13 @@
+[
+    {
+        "created_at": "2015-09-09 11:10:32 UTC",
+        "title": "Qualité de code - Intégration de php-git-hooks dans Symfony2 - Experts Symfony et Drupal - Lexik",
+        "url": "https://devblog.lexik.fr/qualite-de-code-integration-de-php-git-hooks-dans-symfony2/",
+        "description": null,
+        "tags": [
+            "tag1",
+            "tag2"
+        ],
+        "is_saved": true
+    }
+]