aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Wallabag/AnnotationBundle/Entity/Annotation.php7
-rw-r--r--src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php4
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php17
-rw-r--r--src/Wallabag/CoreBundle/Helper/EntriesExport.php13
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.da.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.de.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.en.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.es.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.it.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml2
-rw-r--r--tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php37
-rw-r--r--tests/Wallabag/CoreBundle/Controller/TagControllerTest.php26
17 files changed, 84 insertions, 42 deletions
diff --git a/src/Wallabag/AnnotationBundle/Entity/Annotation.php b/src/Wallabag/AnnotationBundle/Entity/Annotation.php
index 90ee7c2d..c48d8731 100644
--- a/src/Wallabag/AnnotationBundle/Entity/Annotation.php
+++ b/src/Wallabag/AnnotationBundle/Entity/Annotation.php
@@ -7,6 +7,7 @@ use JMS\Serializer\Annotation\ExclusionPolicy;
7use JMS\Serializer\Annotation\Exclude; 7use JMS\Serializer\Annotation\Exclude;
8use JMS\Serializer\Annotation\VirtualProperty; 8use JMS\Serializer\Annotation\VirtualProperty;
9use JMS\Serializer\Annotation\SerializedName; 9use JMS\Serializer\Annotation\SerializedName;
10use JMS\Serializer\Annotation\Groups;
10use Wallabag\UserBundle\Entity\User; 11use Wallabag\UserBundle\Entity\User;
11use Wallabag\CoreBundle\Entity\Entry; 12use Wallabag\CoreBundle\Entity\Entry;
12 13
@@ -33,6 +34,8 @@ class Annotation
33 * @var string 34 * @var string
34 * 35 *
35 * @ORM\Column(name="text", type="text") 36 * @ORM\Column(name="text", type="text")
37 *
38 * @Groups({"entries_for_user", "export_all"})
36 */ 39 */
37 private $text; 40 private $text;
38 41
@@ -54,6 +57,8 @@ class Annotation
54 * @var string 57 * @var string
55 * 58 *
56 * @ORM\Column(name="quote", type="string") 59 * @ORM\Column(name="quote", type="string")
60 *
61 * @Groups({"entries_for_user", "export_all"})
57 */ 62 */
58 private $quote; 63 private $quote;
59 64
@@ -61,6 +66,8 @@ class Annotation
61 * @var array 66 * @var array
62 * 67 *
63 * @ORM\Column(name="ranges", type="array") 68 * @ORM\Column(name="ranges", type="array")
69 *
70 * @Groups({"entries_for_user", "export_all"})
64 */ 71 */
65 private $ranges; 72 private $ranges;
66 73
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php
index 6c6a331a..fedad009 100644
--- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php
+++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php
@@ -23,6 +23,9 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
23 $entry1->setContent('This is my content /o/'); 23 $entry1->setContent('This is my content /o/');
24 $entry1->setLanguage('en'); 24 $entry1->setLanguage('en');
25 25
26 $entry1->addTag($this->getReference('foo-tag'));
27 $entry1->addTag($this->getReference('baz-tag'));
28
26 $manager->persist($entry1); 29 $manager->persist($entry1);
27 30
28 $this->addReference('entry1', $entry1); 31 $this->addReference('entry1', $entry1);
@@ -96,6 +99,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
96 $entry6->setContent('This is my content /o/'); 99 $entry6->setContent('This is my content /o/');
97 $entry6->setArchived(true); 100 $entry6->setArchived(true);
98 $entry6->setLanguage('de'); 101 $entry6->setLanguage('de');
102 $entry6->addTag($this->getReference('bar-tag'));
99 103
100 $manager->persist($entry6); 104 $manager->persist($entry6);
101 105
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index a4b0d7a8..f2da3f4d 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -196,8 +196,6 @@ class Entry
196 * @ORM\JoinColumn(name="tag_id", referencedColumnName="id") 196 * @ORM\JoinColumn(name="tag_id", referencedColumnName="id")
197 * } 197 * }
198 * ) 198 * )
199 *
200 * @Groups({"entries_for_user", "export_all"})
201 */ 199 */
202 private $tags; 200 private $tags;
203 201
@@ -542,6 +540,21 @@ class Entry
542 } 540 }
543 541
544 /** 542 /**
543 * @VirtualProperty
544 * @SerializedName("tags")
545 * @Groups({"entries_for_user", "export_all"})
546 */
547 public function getSerializedTags()
548 {
549 $data = [];
550 foreach ($this->tags as $tag) {
551 $data[] = $tag->getLabel();
552 }
553
554 return $data;
555 }
556
557 /**
545 * @param Tag $tag 558 * @param Tag $tag
546 */ 559 */
547 public function addTag(Tag $tag) 560 public function addTag(Tag $tag)
diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
index 0c627dcd..e50c68a6 100644
--- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php
+++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
@@ -21,7 +21,6 @@ class EntriesExport
21 private $entries = []; 21 private $entries = [];
22 private $authors = ['wallabag']; 22 private $authors = ['wallabag'];
23 private $language = ''; 23 private $language = '';
24 private $tags = [];
25 private $footerTemplate = '<div style="text-align:center;"> 24 private $footerTemplate = '<div style="text-align:center;">
26 <p>Produced by wallabag with %EXPORT_METHOD%</p> 25 <p>Produced by wallabag with %EXPORT_METHOD%</p>
27 <p>Please open <a href="https://github.com/wallabag/wallabag/issues">an issue</a> if you have trouble with the display of this E-Book on your device.</p> 26 <p>Please open <a href="https://github.com/wallabag/wallabag/issues">an issue</a> if you have trouble with the display of this E-Book on your device.</p>
@@ -53,10 +52,6 @@ class EntriesExport
53 52
54 $this->entries = $entries; 53 $this->entries = $entries;
55 54
56 foreach ($entries as $entry) {
57 $this->tags[] = $entry->getTags();
58 }
59
60 return $this; 55 return $this;
61 } 56 }
62 57
@@ -159,8 +154,8 @@ class EntriesExport
159 154
160 // set tags as subjects 155 // set tags as subjects
161 foreach ($this->entries as $entry) { 156 foreach ($this->entries as $entry) {
162 foreach ($this->tags as $tag) { 157 foreach ($entry->getTags() as $tag) {
163 $book->setSubject($tag['value']); 158 $book->setSubject($tag->getLabel());
164 } 159 }
165 160
166 // the reader in Kobo Devices doesn't likes special caracters 161 // the reader in Kobo Devices doesn't likes special caracters
@@ -265,8 +260,8 @@ class EntriesExport
265 * Adding actual entries 260 * Adding actual entries
266 */ 261 */
267 foreach ($this->entries as $entry) { 262 foreach ($this->entries as $entry) {
268 foreach ($this->tags as $tag) { 263 foreach ($entry->getTags() as $tag) {
269 $pdf->SetKeywords($tag['value']); 264 $pdf->SetKeywords($tag->getLabel());
270 } 265 }
271 266
272 $pdf->AddPage(); 267 $pdf->AddPage();
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
index 01067035..2652a102 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
@@ -464,7 +464,7 @@ flashes:
464 # entry_saved_failed: 'Entry saved but fetching content failed' 464 # entry_saved_failed: 'Entry saved but fetching content failed'
465 # entry_updated: 'Entry updated' 465 # entry_updated: 'Entry updated'
466 # entry_reloaded: 'Entry reloaded' 466 # entry_reloaded: 'Entry reloaded'
467 # entry_reload_failed: 'Entry reloaded but fetching content failed' 467 # entry_reloaded_failed: 'Entry reloaded but fetching content failed'
468 entry_archived: 'Artikel arkiveret' 468 entry_archived: 'Artikel arkiveret'
469 entry_unarchived: 'Artikel ikke længere arkiveret' 469 entry_unarchived: 'Artikel ikke længere arkiveret'
470 entry_starred: 'Artikel markeret som favorit' 470 entry_starred: 'Artikel markeret som favorit'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
index 50195b05..e0f29b61 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
@@ -464,7 +464,7 @@ flashes:
464 entry_saved_failed: 'Eintrag gespeichert, aber das Abrufen des Inhalts ist fehlgeschlagen' 464 entry_saved_failed: 'Eintrag gespeichert, aber das Abrufen des Inhalts ist fehlgeschlagen'
465 entry_updated: 'Eintrag aktualisiert' 465 entry_updated: 'Eintrag aktualisiert'
466 entry_reloaded: 'Eintrag neugeladen' 466 entry_reloaded: 'Eintrag neugeladen'
467 entry_reload_failed: 'Eintrag neugeladen, aber das Abrufen des Inhalts ist fehlgeschlagen' 467 entry_reloaded_failed: 'Eintrag neugeladen, aber das Abrufen des Inhalts ist fehlgeschlagen'
468 entry_archived: 'Artikel archiviert' 468 entry_archived: 'Artikel archiviert'
469 entry_unarchived: 'Artikel dearchiviert' 469 entry_unarchived: 'Artikel dearchiviert'
470 entry_starred: 'Artikel favorisiert' 470 entry_starred: 'Artikel favorisiert'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
index 2aba86ff..b8e98112 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
@@ -463,7 +463,7 @@ flashes:
463 entry_saved_failed: 'Entry saved but fetching content failed' 463 entry_saved_failed: 'Entry saved but fetching content failed'
464 entry_updated: 'Entry updated' 464 entry_updated: 'Entry updated'
465 entry_reloaded: 'Entry reloaded' 465 entry_reloaded: 'Entry reloaded'
466 entry_reload_failed: 'Entry reloaded but fetching content failed' 466 entry_reloaded_failed: 'Entry reloaded but fetching content failed'
467 entry_archived: 'Entry archived' 467 entry_archived: 'Entry archived'
468 entry_unarchived: 'Entry unarchived' 468 entry_unarchived: 'Entry unarchived'
469 entry_starred: 'Entry starred' 469 entry_starred: 'Entry starred'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
index b7495510..70633bd7 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
@@ -464,7 +464,7 @@ flashes:
464 # entry_saved_failed: 'Entry saved but fetching content failed' 464 # entry_saved_failed: 'Entry saved but fetching content failed'
465 entry_updated: 'Entrada actualizada' 465 entry_updated: 'Entrada actualizada'
466 entry_reloaded: 'Entrada recargada' 466 entry_reloaded: 'Entrada recargada'
467 # entry_reload_failed: 'Entry reloaded but fetching content failed' 467 # entry_reloaded_failed: 'Entry reloaded but fetching content failed'
468 entry_archived: 'Artículo archivado' 468 entry_archived: 'Artículo archivado'
469 entry_unarchived: 'Artículo desarchivado' 469 entry_unarchived: 'Artículo desarchivado'
470 entry_starred: 'Artículo guardado en los favoritos' 470 entry_starred: 'Artículo guardado en los favoritos'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
index 13763564..074ab7a8 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
@@ -463,7 +463,7 @@ flashes:
463 # entry_saved_failed: 'Entry saved but fetching content failed' 463 # entry_saved_failed: 'Entry saved but fetching content failed'
464 entry_updated: 'مقاله به‌روز شد' 464 entry_updated: 'مقاله به‌روز شد'
465 entry_reloaded: 'مقاله به‌روز شد' 465 entry_reloaded: 'مقاله به‌روز شد'
466 # entry_reload_failed: 'Entry reloaded but fetching content failed' 466 # entry_reloaded_failed: 'Entry reloaded but fetching content failed'
467 entry_archived: 'مقاله بایگانی شد' 467 entry_archived: 'مقاله بایگانی شد'
468 entry_unarchived: 'مقاله از بایگانی درآمد' 468 entry_unarchived: 'مقاله از بایگانی درآمد'
469 entry_starred: 'مقاله برگزیده شد' 469 entry_starred: 'مقاله برگزیده شد'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
index 098bc9ff..6d85a5ae 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
@@ -464,7 +464,7 @@ flashes:
464 entry_saved_failed: 'Article enregistré mais impossible de récupérer le contenu' 464 entry_saved_failed: 'Article enregistré mais impossible de récupérer le contenu'
465 entry_updated: 'Article mis à jour' 465 entry_updated: 'Article mis à jour'
466 entry_reloaded: 'Article rechargé' 466 entry_reloaded: 'Article rechargé'
467 entry_reload_failed: "Article mis à jour mais impossible de récupérer le contenu" 467 entry_reloaded_failed: "Article mis à jour mais impossible de récupérer le contenu"
468 entry_archived: 'Article marqué comme lu' 468 entry_archived: 'Article marqué comme lu'
469 entry_unarchived: 'Article marqué comme non lu' 469 entry_unarchived: 'Article marqué comme non lu'
470 entry_starred: 'Article ajouté dans les favoris' 470 entry_starred: 'Article ajouté dans les favoris'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
index 390a4b60..15f7e774 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
@@ -464,7 +464,7 @@ flashes:
464 # entry_saved_failed: 'Entry saved but fetching content failed' 464 # entry_saved_failed: 'Entry saved but fetching content failed'
465 entry_updated: 'Contenuto aggiornato' 465 entry_updated: 'Contenuto aggiornato'
466 entry_reloaded: 'Contenuto ricaricato' 466 entry_reloaded: 'Contenuto ricaricato'
467 # entry_reload_failed: 'Entry reloaded but fetching content failed' 467 # entry_reloaded_failed: 'Entry reloaded but fetching content failed'
468 entry_archived: 'Contenuto archiviato' 468 entry_archived: 'Contenuto archiviato'
469 entry_unarchived: 'Contenuto dis-archiviato' 469 entry_unarchived: 'Contenuto dis-archiviato'
470 entry_starred: 'Contenuto segnato come preferito' 470 entry_starred: 'Contenuto segnato come preferito'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
index 990938a6..1d10be2a 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
@@ -464,7 +464,7 @@ flashes:
464 entry_saved_failed: 'Article salvat mai fracàs de la recuperacion del contengut' 464 entry_saved_failed: 'Article salvat mai fracàs de la recuperacion del contengut'
465 entry_updated: 'Article mes a jorn' 465 entry_updated: 'Article mes a jorn'
466 entry_reloaded: 'Article recargat' 466 entry_reloaded: 'Article recargat'
467 entry_reload_failed: "L'article es estat cargat de nòu mai la recuperacion del contengut a fracassat" 467 entry_reloaded_failed: "L'article es estat cargat de nòu mai la recuperacion del contengut a fracassat"
468 entry_archived: 'Article marcat coma legit' 468 entry_archived: 'Article marcat coma legit'
469 entry_unarchived: 'Article marcat coma pas legit' 469 entry_unarchived: 'Article marcat coma pas legit'
470 entry_starred: 'Article apondut dins los favorits' 470 entry_starred: 'Article apondut dins los favorits'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
index 6dd79641..9791a3b2 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
@@ -464,7 +464,7 @@ flashes:
464 entry_saved_failed: 'Wpis zapisany, ale wystąpił bład pobierania treści' 464 entry_saved_failed: 'Wpis zapisany, ale wystąpił bład pobierania treści'
465 entry_updated: 'Wpis zaktualizowany' 465 entry_updated: 'Wpis zaktualizowany'
466 entry_reloaded: 'Wpis ponownie załadowany' 466 entry_reloaded: 'Wpis ponownie załadowany'
467 entry_reload_failed: 'Wpis ponownie załadowany, ale wystąpił bład pobierania treści' 467 entry_reloaded_failed: 'Wpis ponownie załadowany, ale wystąpił bład pobierania treści'
468 entry_archived: 'Wpis dodany do archiwum' 468 entry_archived: 'Wpis dodany do archiwum'
469 entry_unarchived: 'Wpis usunięty z archiwum' 469 entry_unarchived: 'Wpis usunięty z archiwum'
470 entry_starred: 'Wpis oznaczony gwiazdkÄ…' 470 entry_starred: 'Wpis oznaczony gwiazdkÄ…'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
index a8d625d2..2b1d4f6d 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
@@ -464,7 +464,7 @@ flashes:
464 # entry_saved_failed: 'Entry saved but fetching content failed' 464 # entry_saved_failed: 'Entry saved but fetching content failed'
465 # entry_updated: 'Entry updated' 465 # entry_updated: 'Entry updated'
466 # entry_reloaded: 'Entry reloaded' 466 # entry_reloaded: 'Entry reloaded'
467 # entry_reload_failed: 'Entry reloaded but fetching content failed' 467 # entry_reloaded_failed: 'Entry reloaded but fetching content failed'
468 entry_archived: 'Articol arhivat' 468 entry_archived: 'Articol arhivat'
469 entry_unarchived: 'Articol dezarhivat' 469 entry_unarchived: 'Articol dezarhivat'
470 entry_starred: 'Articol adăugat la favorite' 470 entry_starred: 'Articol adăugat la favorite'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
index bcfd8ad4..8cfc245a 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
@@ -463,7 +463,7 @@ flashes:
463 # entry_saved_failed: 'Entry saved but fetching content failed' 463 # entry_saved_failed: 'Entry saved but fetching content failed'
464 # entry_updated: 'Entry updated' 464 # entry_updated: 'Entry updated'
465 entry_reloaded: 'Makale içeriği yenilendi' 465 entry_reloaded: 'Makale içeriği yenilendi'
466 # entry_reload_failed: 'Entry reloaded but fetching content failed' 466 # entry_reloaded_failed: 'Entry reloaded but fetching content failed'
467 entry_archived: 'Makale arÅŸivlendi' 467 entry_archived: 'Makale arÅŸivlendi'
468 entry_unarchived: 'Makale arşivden çıkartıldı' 468 entry_unarchived: 'Makale arşivden çıkartıldı'
469 entry_starred: 'Makale favorilere eklendi' 469 entry_starred: 'Makale favorilere eklendi'
diff --git a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php
index 47b86117..9ecd8bc4 100644
--- a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php
@@ -146,7 +146,9 @@ class ExportControllerTest extends WallabagCoreTestCase
146 ->get('doctrine.orm.entity_manager') 146 ->get('doctrine.orm.entity_manager')
147 ->getRepository('WallabagCoreBundle:Entry') 147 ->getRepository('WallabagCoreBundle:Entry')
148 ->createQueryBuilder('e') 148 ->createQueryBuilder('e')
149 ->select('e, t')
149 ->leftJoin('e.user', 'u') 150 ->leftJoin('e.user', 'u')
151 ->leftJoin('e.tags', 't')
150 ->where('u.username = :username')->setParameter('username', 'admin') 152 ->where('u.username = :username')->setParameter('username', 'admin')
151 ->andWhere('e.isArchived = true') 153 ->andWhere('e.isArchived = true')
152 ->getQuery() 154 ->getQuery()
@@ -169,6 +171,18 @@ class ExportControllerTest extends WallabagCoreTestCase
169 // +1 for title line 171 // +1 for title line
170 $this->assertEquals(count($contentInDB) + 1, count($csv)); 172 $this->assertEquals(count($contentInDB) + 1, count($csv));
171 $this->assertEquals('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]); 173 $this->assertEquals('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]);
174 $this->assertContains($contentInDB[0]['title'], $csv[1]);
175 $this->assertContains($contentInDB[0]['url'], $csv[1]);
176 $this->assertContains($contentInDB[0]['content'], $csv[1]);
177 $this->assertContains($contentInDB[0]['mimetype'], $csv[1]);
178 $this->assertContains($contentInDB[0]['language'], $csv[1]);
179 $this->assertContains($contentInDB[0]['createdAt']->format('d/m/Y h:i:s'), $csv[1]);
180
181 $expectedTag = [];
182 foreach ($contentInDB[0]['tags'] as $tag) {
183 $expectedTag[] = $tag['label'];
184 }
185 $this->assertContains(implode(', ', $expectedTag), $csv[1]);
172 } 186 }
173 187
174 public function testJsonExport() 188 public function testJsonExport()
@@ -176,29 +190,23 @@ class ExportControllerTest extends WallabagCoreTestCase
176 $this->logInAs('admin'); 190 $this->logInAs('admin');
177 $client = $this->getClient(); 191 $client = $this->getClient();
178 192
179 // to be sure results are the same
180 $contentInDB = $client->getContainer() 193 $contentInDB = $client->getContainer()
181 ->get('doctrine.orm.entity_manager') 194 ->get('doctrine.orm.entity_manager')
182 ->getRepository('WallabagCoreBundle:Entry') 195 ->getRepository('WallabagCoreBundle:Entry')
183 ->createQueryBuilder('e') 196 ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId());
184 ->leftJoin('e.user', 'u')
185 ->where('u.username = :username')->setParameter('username', 'admin')
186 ->getQuery()
187 ->getArrayResult();
188 197
189 ob_start(); 198 ob_start();
190 $crawler = $client->request('GET', '/export/all.json'); 199 $crawler = $client->request('GET', '/export/'.$contentInDB->getId().'.json');
191 ob_end_clean(); 200 ob_end_clean();
192 201
193 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 202 $this->assertEquals(200, $client->getResponse()->getStatusCode());
194 203
195 $headers = $client->getResponse()->headers; 204 $headers = $client->getResponse()->headers;
196 $this->assertEquals('application/json', $headers->get('content-type')); 205 $this->assertEquals('application/json', $headers->get('content-type'));
197 $this->assertEquals('attachment; filename="All articles.json"', $headers->get('content-disposition')); 206 $this->assertEquals('attachment; filename="'.$contentInDB->getTitle().'.json"', $headers->get('content-disposition'));
198 $this->assertEquals('UTF-8', $headers->get('content-transfer-encoding')); 207 $this->assertEquals('UTF-8', $headers->get('content-transfer-encoding'));
199 208
200 $content = json_decode($client->getResponse()->getContent(), true); 209 $content = json_decode($client->getResponse()->getContent(), true);
201 $this->assertEquals(count($contentInDB), count($content));
202 $this->assertArrayHasKey('id', $content[0]); 210 $this->assertArrayHasKey('id', $content[0]);
203 $this->assertArrayHasKey('title', $content[0]); 211 $this->assertArrayHasKey('title', $content[0]);
204 $this->assertArrayHasKey('url', $content[0]); 212 $this->assertArrayHasKey('url', $content[0]);
@@ -212,6 +220,17 @@ class ExportControllerTest extends WallabagCoreTestCase
212 $this->assertArrayHasKey('tags', $content[0]); 220 $this->assertArrayHasKey('tags', $content[0]);
213 $this->assertArrayHasKey('created_at', $content[0]); 221 $this->assertArrayHasKey('created_at', $content[0]);
214 $this->assertArrayHasKey('updated_at', $content[0]); 222 $this->assertArrayHasKey('updated_at', $content[0]);
223
224 $this->assertEquals($contentInDB->isArchived(), $content[0]['is_archived']);
225 $this->assertEquals($contentInDB->isStarred(), $content[0]['is_starred']);
226 $this->assertEquals($contentInDB->getTitle(), $content[0]['title']);
227 $this->assertEquals($contentInDB->getUrl(), $content[0]['url']);
228 $this->assertEquals([['text' => 'This is my annotation /o/', 'quote' => 'content']], $content[0]['annotations']);
229 $this->assertEquals($contentInDB->getMimetype(), $content[0]['mimetype']);
230 $this->assertEquals($contentInDB->getLanguage(), $content[0]['language']);
231 $this->assertEquals($contentInDB->getReadingtime(), $content[0]['reading_time']);
232 $this->assertEquals($contentInDB->getDomainname(), $content[0]['domain_name']);
233 $this->assertEquals(['foo', 'baz'], $content[0]['tags']);
215 } 234 }
216 235
217 public function testXmlExport() 236 public function testXmlExport()
diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
index 2c32393f..86a6cca2 100644
--- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
@@ -26,7 +26,7 @@ class TagControllerTest extends WallabagCoreTestCase
26 $entry = $client->getContainer() 26 $entry = $client->getContainer()
27 ->get('doctrine.orm.entity_manager') 27 ->get('doctrine.orm.entity_manager')
28 ->getRepository('WallabagCoreBundle:Entry') 28 ->getRepository('WallabagCoreBundle:Entry')
29 ->findOneByUsernameAndNotArchived('admin'); 29 ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId());
30 30
31 $crawler = $client->request('GET', '/view/'.$entry->getId()); 31 $crawler = $client->request('GET', '/view/'.$entry->getId());
32 32
@@ -43,9 +43,9 @@ class TagControllerTest extends WallabagCoreTestCase
43 $entry = $client->getContainer() 43 $entry = $client->getContainer()
44 ->get('doctrine.orm.entity_manager') 44 ->get('doctrine.orm.entity_manager')
45 ->getRepository('WallabagCoreBundle:Entry') 45 ->getRepository('WallabagCoreBundle:Entry')
46 ->findOneByUsernameAndNotArchived('admin'); 46 ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId());
47 47
48 $this->assertEquals(1, count($entry->getTags())); 48 $this->assertEquals(3, count($entry->getTags()));
49 49
50 // tag already exists and already assigned 50 // tag already exists and already assigned
51 $client->submit($form, $data); 51 $client->submit($form, $data);
@@ -56,7 +56,7 @@ class TagControllerTest extends WallabagCoreTestCase
56 ->getRepository('WallabagCoreBundle:Entry') 56 ->getRepository('WallabagCoreBundle:Entry')
57 ->find($entry->getId()); 57 ->find($entry->getId());
58 58
59 $this->assertEquals(1, count($newEntry->getTags())); 59 $this->assertEquals(3, count($newEntry->getTags()));
60 60
61 // tag already exists but still not assigned to this entry 61 // tag already exists but still not assigned to this entry
62 $data = [ 62 $data = [
@@ -71,7 +71,7 @@ class TagControllerTest extends WallabagCoreTestCase
71 ->getRepository('WallabagCoreBundle:Entry') 71 ->getRepository('WallabagCoreBundle:Entry')
72 ->find($entry->getId()); 72 ->find($entry->getId());
73 73
74 $this->assertEquals(2, count($newEntry->getTags())); 74 $this->assertEquals(3, count($newEntry->getTags()));
75 } 75 }
76 76
77 public function testAddMultipleTagToEntry() 77 public function testAddMultipleTagToEntry()
@@ -82,7 +82,7 @@ class TagControllerTest extends WallabagCoreTestCase
82 $entry = $client->getContainer() 82 $entry = $client->getContainer()
83 ->get('doctrine.orm.entity_manager') 83 ->get('doctrine.orm.entity_manager')
84 ->getRepository('WallabagCoreBundle:Entry') 84 ->getRepository('WallabagCoreBundle:Entry')
85 ->findOneByUsernameAndNotArchived('admin'); 85 ->findByUrlAndUserId('http://0.0.0.0/entry2', $this->getLoggedInUserId());
86 86
87 $crawler = $client->request('GET', '/view/'.$entry->getId()); 87 $crawler = $client->request('GET', '/view/'.$entry->getId());
88 88
@@ -101,9 +101,13 @@ class TagControllerTest extends WallabagCoreTestCase
101 ->find($entry->getId()); 101 ->find($entry->getId());
102 102
103 $tags = $newEntry->getTags()->toArray(); 103 $tags = $newEntry->getTags()->toArray();
104 foreach ($tags as $key => $tag) {
105 $tags[$key] = $tag->getLabel();
106 }
107
104 $this->assertGreaterThanOrEqual(2, count($tags)); 108 $this->assertGreaterThanOrEqual(2, count($tags));
105 $this->assertNotEquals(false, array_search('foo2', $tags), 'Tag foo2 is assigned to the entry'); 109 $this->assertNotFalse(array_search('foo2', $tags), 'Tag foo2 is assigned to the entry');
106 $this->assertNotEquals(false, array_search('bar2', $tags), 'Tag bar2 is assigned to the entry'); 110 $this->assertNotFalse(array_search('bar2', $tags), 'Tag bar2 is assigned to the entry');
107 } 111 }
108 112
109 public function testRemoveTagFromEntry() 113 public function testRemoveTagFromEntry()
@@ -114,7 +118,7 @@ class TagControllerTest extends WallabagCoreTestCase
114 $entry = $client->getContainer() 118 $entry = $client->getContainer()
115 ->get('doctrine.orm.entity_manager') 119 ->get('doctrine.orm.entity_manager')
116 ->getRepository('WallabagCoreBundle:Entry') 120 ->getRepository('WallabagCoreBundle:Entry')
117 ->findOneByUsernameAndNotArchived('admin'); 121 ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId());
118 122
119 $tag = $client->getContainer() 123 $tag = $client->getContainer()
120 ->get('doctrine.orm.entity_manager') 124 ->get('doctrine.orm.entity_manager')
@@ -140,7 +144,7 @@ class TagControllerTest extends WallabagCoreTestCase
140 $entry = $client->getContainer() 144 $entry = $client->getContainer()
141 ->get('doctrine.orm.entity_manager') 145 ->get('doctrine.orm.entity_manager')
142 ->getRepository('WallabagCoreBundle:Entry') 146 ->getRepository('WallabagCoreBundle:Entry')
143 ->findOneByUsernameAndNotArchived('admin'); 147 ->findByUrlAndUserId('http://0.0.0.0/entry4', $this->getLoggedInUserId());
144 148
145 $tag = $client->getContainer() 149 $tag = $client->getContainer()
146 ->get('doctrine.orm.entity_manager') 150 ->get('doctrine.orm.entity_manager')
@@ -160,6 +164,6 @@ class TagControllerTest extends WallabagCoreTestCase
160 $crawler = $client->request('GET', '/tag/list/'.$tag->getSlug()); 164 $crawler = $client->request('GET', '/tag/list/'.$tag->getSlug());
161 165
162 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 166 $this->assertEquals(200, $client->getResponse()->getStatusCode());
163 $this->assertCount(0, $crawler->filter('div[class=entry]')); 167 $this->assertCount(1, $crawler->filter('div[class=entry]'));
164 } 168 }
165} 169}