diff options
author | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2016-10-07 13:55:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-07 13:55:55 +0200 |
commit | bf71a734f64a911549e188a5c69ac8e08eec896e (patch) | |
tree | 0e40afc2a85658705fdf4a1a6b8e7c6c3d7dfbc3 | |
parent | 9d127b3b9365c73bc393bc303545f24c159cee31 (diff) | |
parent | 74e1f7433a5fc0a9bbf3942a22917e0dd1cc6923 (diff) | |
download | wallabag-bf71a734f64a911549e188a5c69ac8e08eec896e.tar.gz wallabag-bf71a734f64a911549e188a5c69ac8e08eec896e.tar.zst wallabag-bf71a734f64a911549e188a5c69ac8e08eec896e.zip |
Merge pull request #2332 from wallabag/tags-export
Fix relations export for Entry
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; | |||
7 | use JMS\Serializer\Annotation\Exclude; | 7 | use JMS\Serializer\Annotation\Exclude; |
8 | use JMS\Serializer\Annotation\VirtualProperty; | 8 | use JMS\Serializer\Annotation\VirtualProperty; |
9 | use JMS\Serializer\Annotation\SerializedName; | 9 | use JMS\Serializer\Annotation\SerializedName; |
10 | use JMS\Serializer\Annotation\Groups; | ||
10 | use Wallabag\UserBundle\Entity\User; | 11 | use Wallabag\UserBundle\Entity\User; |
11 | use Wallabag\CoreBundle\Entity\Entry; | 12 | use 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 40644ff5..b04b9512 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml | |||
@@ -462,7 +462,7 @@ flashes: | |||
462 | # entry_saved_failed: 'Entry saved but fetching content failed' | 462 | # entry_saved_failed: 'Entry saved but fetching content failed' |
463 | # entry_updated: 'Entry updated' | 463 | # entry_updated: 'Entry updated' |
464 | # entry_reloaded: 'Entry reloaded' | 464 | # entry_reloaded: 'Entry reloaded' |
465 | # entry_reload_failed: 'Entry reloaded but fetching content failed' | 465 | # entry_reloaded_failed: 'Entry reloaded but fetching content failed' |
466 | entry_archived: 'Artikel arkiveret' | 466 | entry_archived: 'Artikel arkiveret' |
467 | entry_unarchived: 'Artikel ikke længere arkiveret' | 467 | entry_unarchived: 'Artikel ikke længere arkiveret' |
468 | entry_starred: 'Artikel markeret som favorit' | 468 | 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 130ab2cd..6ea3f5c5 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml | |||
@@ -462,7 +462,7 @@ flashes: | |||
462 | entry_saved_failed: 'Eintrag gespeichert, aber das Abrufen des Inhalts ist fehlgeschlagen' | 462 | entry_saved_failed: 'Eintrag gespeichert, aber das Abrufen des Inhalts ist fehlgeschlagen' |
463 | entry_updated: 'Eintrag aktualisiert' | 463 | entry_updated: 'Eintrag aktualisiert' |
464 | entry_reloaded: 'Eintrag neugeladen' | 464 | entry_reloaded: 'Eintrag neugeladen' |
465 | entry_reload_failed: 'Eintrag neugeladen, aber das Abrufen des Inhalts ist fehlgeschlagen' | 465 | entry_reloaded_failed: 'Eintrag neugeladen, aber das Abrufen des Inhalts ist fehlgeschlagen' |
466 | entry_archived: 'Artikel archiviert' | 466 | entry_archived: 'Artikel archiviert' |
467 | entry_unarchived: 'Artikel dearchiviert' | 467 | entry_unarchived: 'Artikel dearchiviert' |
468 | entry_starred: 'Artikel favorisiert' | 468 | 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 91abe162..38631e24 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml | |||
@@ -461,7 +461,7 @@ flashes: | |||
461 | entry_saved_failed: 'Entry saved but fetching content failed' | 461 | entry_saved_failed: 'Entry saved but fetching content failed' |
462 | entry_updated: 'Entry updated' | 462 | entry_updated: 'Entry updated' |
463 | entry_reloaded: 'Entry reloaded' | 463 | entry_reloaded: 'Entry reloaded' |
464 | entry_reload_failed: 'Entry reloaded but fetching content failed' | 464 | entry_reloaded_failed: 'Entry reloaded but fetching content failed' |
465 | entry_archived: 'Entry archived' | 465 | entry_archived: 'Entry archived' |
466 | entry_unarchived: 'Entry unarchived' | 466 | entry_unarchived: 'Entry unarchived' |
467 | entry_starred: 'Entry starred' | 467 | 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 25d2f3a2..a1fc34ef 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml | |||
@@ -462,7 +462,7 @@ flashes: | |||
462 | # entry_saved_failed: 'Entry saved but fetching content failed' | 462 | # entry_saved_failed: 'Entry saved but fetching content failed' |
463 | entry_updated: 'Entrada actualizada' | 463 | entry_updated: 'Entrada actualizada' |
464 | entry_reloaded: 'Entrada recargada' | 464 | entry_reloaded: 'Entrada recargada' |
465 | # entry_reload_failed: 'Entry reloaded but fetching content failed' | 465 | # entry_reloaded_failed: 'Entry reloaded but fetching content failed' |
466 | entry_archived: 'ArtÃculo archivado' | 466 | entry_archived: 'ArtÃculo archivado' |
467 | entry_unarchived: 'ArtÃculo desarchivado' | 467 | entry_unarchived: 'ArtÃculo desarchivado' |
468 | entry_starred: 'ArtÃculo guardado en los favoritos' | 468 | 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 b02ffea0..740302c5 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml | |||
@@ -461,7 +461,7 @@ flashes: | |||
461 | # entry_saved_failed: 'Entry saved but fetching content failed' | 461 | # entry_saved_failed: 'Entry saved but fetching content failed' |
462 | entry_updated: 'مقاله به‌روز شد' | 462 | entry_updated: 'مقاله به‌روز شد' |
463 | entry_reloaded: 'مقاله به‌روز شد' | 463 | entry_reloaded: 'مقاله به‌روز شد' |
464 | # entry_reload_failed: 'Entry reloaded but fetching content failed' | 464 | # entry_reloaded_failed: 'Entry reloaded but fetching content failed' |
465 | entry_archived: 'مقاله بایگانی شد' | 465 | entry_archived: 'مقاله بایگانی شد' |
466 | entry_unarchived: 'مقاله از بایگانی درآمد' | 466 | entry_unarchived: 'مقاله از بایگانی درآمد' |
467 | entry_starred: 'مقاله برگزیده شد' | 467 | entry_starred: 'مقاله برگزیده شد' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 598205b0..ad4fc99f 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml | |||
@@ -462,7 +462,7 @@ flashes: | |||
462 | entry_saved_failed: 'Article enregistré mais impossible de récupérer le contenu' | 462 | entry_saved_failed: 'Article enregistré mais impossible de récupérer le contenu' |
463 | entry_updated: 'Article mis à jour' | 463 | entry_updated: 'Article mis à jour' |
464 | entry_reloaded: 'Article rechargé' | 464 | entry_reloaded: 'Article rechargé' |
465 | entry_reload_failed: "Article mis à jour mais impossible de récupérer le contenu" | 465 | entry_reloaded_failed: "Article mis à jour mais impossible de récupérer le contenu" |
466 | entry_archived: 'Article marqué comme lu' | 466 | entry_archived: 'Article marqué comme lu' |
467 | entry_unarchived: 'Article marqué comme non lu' | 467 | entry_unarchived: 'Article marqué comme non lu' |
468 | entry_starred: 'Article ajouté dans les favoris' | 468 | 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 c58c929f..e0bd9d8b 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml | |||
@@ -462,7 +462,7 @@ flashes: | |||
462 | # entry_saved_failed: 'Entry saved but fetching content failed' | 462 | # entry_saved_failed: 'Entry saved but fetching content failed' |
463 | entry_updated: 'Contenuto aggiornato' | 463 | entry_updated: 'Contenuto aggiornato' |
464 | entry_reloaded: 'Contenuto ricaricato' | 464 | entry_reloaded: 'Contenuto ricaricato' |
465 | # entry_reload_failed: 'Entry reloaded but fetching content failed' | 465 | # entry_reloaded_failed: 'Entry reloaded but fetching content failed' |
466 | entry_archived: 'Contenuto archiviato' | 466 | entry_archived: 'Contenuto archiviato' |
467 | entry_unarchived: 'Contenuto dis-archiviato' | 467 | entry_unarchived: 'Contenuto dis-archiviato' |
468 | entry_starred: 'Contenuto segnato come preferito' | 468 | 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 8f06434d..b26bed87 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml | |||
@@ -462,7 +462,7 @@ flashes: | |||
462 | entry_saved_failed: 'Article salvat mai fracàs de la recuperacion del contengut' | 462 | entry_saved_failed: 'Article salvat mai fracàs de la recuperacion del contengut' |
463 | entry_updated: 'Article mes a jorn' | 463 | entry_updated: 'Article mes a jorn' |
464 | entry_reloaded: 'Article recargat' | 464 | entry_reloaded: 'Article recargat' |
465 | entry_reload_failed: "L'article es estat cargat de nòu mai la recuperacion del contengut a fracassat" | 465 | entry_reloaded_failed: "L'article es estat cargat de nòu mai la recuperacion del contengut a fracassat" |
466 | entry_archived: 'Article marcat coma legit' | 466 | entry_archived: 'Article marcat coma legit' |
467 | entry_unarchived: 'Article marcat coma pas legit' | 467 | entry_unarchived: 'Article marcat coma pas legit' |
468 | entry_starred: 'Article apondut dins los favorits' | 468 | 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 7f28e648..285d73e5 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml | |||
@@ -462,7 +462,7 @@ flashes: | |||
462 | entry_saved_failed: 'Wpis zapisany, ale wystąpił bład pobierania treści' | 462 | entry_saved_failed: 'Wpis zapisany, ale wystąpił bład pobierania treści' |
463 | entry_updated: 'Wpis zaktualizowany' | 463 | entry_updated: 'Wpis zaktualizowany' |
464 | entry_reloaded: 'Wpis ponownie załadowany' | 464 | entry_reloaded: 'Wpis ponownie załadowany' |
465 | entry_reload_failed: 'Wpis ponownie załadowany, ale wystąpił bład pobierania treści' | 465 | entry_reloaded_failed: 'Wpis ponownie załadowany, ale wystąpił bład pobierania treści' |
466 | entry_archived: 'Wpis dodany do archiwum' | 466 | entry_archived: 'Wpis dodany do archiwum' |
467 | entry_unarchived: 'Wpis usunięty z archiwum' | 467 | entry_unarchived: 'Wpis usunięty z archiwum' |
468 | entry_starred: 'Wpis oznaczony gwiazdkÄ…' | 468 | 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 4e0e454c..fba6f998 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml | |||
@@ -462,7 +462,7 @@ flashes: | |||
462 | # entry_saved_failed: 'Entry saved but fetching content failed' | 462 | # entry_saved_failed: 'Entry saved but fetching content failed' |
463 | # entry_updated: 'Entry updated' | 463 | # entry_updated: 'Entry updated' |
464 | # entry_reloaded: 'Entry reloaded' | 464 | # entry_reloaded: 'Entry reloaded' |
465 | # entry_reload_failed: 'Entry reloaded but fetching content failed' | 465 | # entry_reloaded_failed: 'Entry reloaded but fetching content failed' |
466 | entry_archived: 'Articol arhivat' | 466 | entry_archived: 'Articol arhivat' |
467 | entry_unarchived: 'Articol dezarhivat' | 467 | entry_unarchived: 'Articol dezarhivat' |
468 | entry_starred: 'Articol adăugat la favorite' | 468 | 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 02b3aae6..1694e212 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml | |||
@@ -461,7 +461,7 @@ flashes: | |||
461 | # entry_saved_failed: 'Entry saved but fetching content failed' | 461 | # entry_saved_failed: 'Entry saved but fetching content failed' |
462 | # entry_updated: 'Entry updated' | 462 | # entry_updated: 'Entry updated' |
463 | entry_reloaded: 'Makale içeriği yenilendi' | 463 | entry_reloaded: 'Makale içeriği yenilendi' |
464 | # entry_reload_failed: 'Entry reloaded but fetching content failed' | 464 | # entry_reloaded_failed: 'Entry reloaded but fetching content failed' |
465 | entry_archived: 'Makale arÅŸivlendi' | 465 | entry_archived: 'Makale arÅŸivlendi' |
466 | entry_unarchived: 'Makale arşivden çıkartıldı' | 466 | entry_unarchived: 'Makale arşivden çıkartıldı' |
467 | entry_starred: 'Makale favorilere eklendi' | 467 | 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 | } |