--- /dev/null
+<?php
+
+namespace Application\Migrations;
+
+use Doctrine\DBAL\Migrations\AbstractMigration;
+use Doctrine\DBAL\Schema\Schema;
+use Symfony\Component\DependencyInjection\ContainerAwareInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+class Version20161001072726 extends AbstractMigration implements ContainerAwareInterface
+{
+ /**
+ * @var ContainerInterface
+ */
+ private $container;
+
+ public function setContainer(ContainerInterface $container = null)
+ {
+ $this->container = $container;
+ }
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
+
+ /**
+ * @param Schema $schema
+ */
+ public function up(Schema $schema)
+ {
+ $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' DROP FOREIGN KEY FK_F035C9E5BA364942');
+ $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' DROP FOREIGN KEY FK_F035C9E5BAD26311');
+ $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' ADD CONSTRAINT FK_F035C9E5BA364942 FOREIGN KEY (entry_id) REFERENCES `entry` (id) ON DELETE CASCADE');
+ $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' ADD CONSTRAINT FK_F035C9E5BAD26311 FOREIGN KEY (tag_id) REFERENCES `tag` (id) ON DELETE CASCADE');
+ $this->addSql('ALTER TABLE '.$this->getTable('annotation').' DROP FOREIGN KEY FK_2E443EF2BA364942');
+ $this->addSql('ALTER TABLE '.$this->getTable('annotation').' ADD CONSTRAINT FK_2E443EF2BA364942 FOREIGN KEY (entry_id) REFERENCES `entry` (id) ON DELETE CASCADE');
+ }
+
+ /**
+ * @param Schema $schema
+ */
+ public function down(Schema $schema)
+ {
+ $this->abortIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
+
+ $this->addSql('ALTER TABLE '.$this->getTable('annotation').' DROP FOREIGN KEY FK_2E443EF2BA364942');
+ $this->addSql('ALTER TABLE '.$this->getTable('annotation').' ADD CONSTRAINT FK_2E443EF2BA364942 FOREIGN KEY (entry_id) REFERENCES entry (id)');
+ $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' DROP FOREIGN KEY FK_F035C9E5BA364942');
+ $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' DROP FOREIGN KEY FK_F035C9E5BAD26311');
+ $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' ADD CONSTRAINT FK_F035C9E5BA364942 FOREIGN KEY (entry_id) REFERENCES entry (id)');
+ $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' ADD CONSTRAINT FK_F035C9E5BAD26311 FOREIGN KEY (tag_id) REFERENCES tag (id)');
+ }
+}
* @Exclude
*
* @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Entry", inversedBy="annotations")
- * @ORM\JoinColumn(name="entry_id", referencedColumnName="id")
+ * @ORM\JoinColumn(name="entry_id", referencedColumnName="id", onDelete="cascade")
*/
private $entry;
return $this->redirect($this->generateUrl('config').'?tagging-rule='.$rule->getId().'#set5');
}
+ /**
+ * Remove all annotations OR tags OR entries for the current user.
+ *
+ * @Route("/reset/{type}", requirements={"id" = "annotations|tags|entries"}, name="config_reset")
+ *
+ * @return RedirectResponse
+ */
+ public function resetAction($type)
+ {
+ $em = $this->getDoctrine()->getManager();
+
+ switch ($type) {
+ case 'annotations':
+ $em->createQuery('DELETE FROM Wallabag\AnnotationBundle\Entity\Annotation a WHERE a.user = '.$this->getUser()->getId())
+ ->execute();
+ break;
+
+ case 'tags':
+ $tags = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findAllTags($this->getUser()->getId());
+
+ if (empty($tags)) {
+ break;
+ }
+
+ $this->getDoctrine()
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->removeTags($this->getUser()->getId(), $tags);
+ break;
+
+ case 'entries':
+ $em->createQuery('DELETE FROM Wallabag\CoreBundle\Entity\Entry e WHERE e.user = '.$this->getUser()->getId())
+ ->execute();
+ }
+
+ $this->get('session')->getFlashBag()->add(
+ 'notice',
+ 'flashes.config.notice.'.$type.'_reset'
+ );
+
+ return $this->redirect($this->generateUrl('config').'#set3');
+ }
+
/**
* Validate that a rule can be edited/deleted by the current user.
*
* @ORM\JoinTable(
* name="entry_tag",
* joinColumns={
- * @ORM\JoinColumn(name="entry_id", referencedColumnName="id")
+ * @ORM\JoinColumn(name="entry_id", referencedColumnName="id", onDelete="cascade")
* },
* inverseJoinColumns={
- * @ORM\JoinColumn(name="tag_id", referencedColumnName="id")
+ * @ORM\JoinColumn(name="tag_id", referencedColumnName="id", onDelete="cascade")
* }
* )
*/
->getArrayResult();
}
+ /**
+ * Find all tags.
+ *
+ * @param int $userId
+ *
+ * @return array
+ */
+ public function findAllTags($userId)
+ {
+ return $this->createQueryBuilder('t')
+ ->select('t')
+ ->leftJoin('t.entries', 'e')
+ ->where('e.user = :userId')->setParameter('userId', $userId)
+ ->getQuery()
+ ->getResult();
+ }
+
/**
* Used only in test case to get a tag for our entry.
*
email_label: 'Emailadresse'
# twoFactorAuthentication_label: 'Two factor authentication'
delete:
- # title: Delete my account (danger zone !)
+ # title: Delete my account (a.k.a danger zone)
# description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out.
- # confirm: Are you really sure? (it can't be UNDONE)
+ # confirm: Are you really sure? (THIS CAN'T BE UNDONE)
# button: Delete my account
+ reset:
+ # title: Reset area (a.k.a danger zone)
+ # description: By hiting buttons below you'll have ability to remove some informations from your account. Be aware that these actions are IRREVERSIBLE.
+ # annotations: Remove ALL annotations
+ # tags: Remove ALL tags
+ # entries: Remove ALL entries
+ # confirm: Are you really really sure? (THIS CAN'T BE UNDONE)
form_password:
old_password_label: 'Gammel adgangskode'
new_password_label: 'Ny adgangskode'
# tagging_rules_deleted: 'Tagging rule deleted'
# user_added: 'User "%username%" added'
# rss_token_updated: 'RSS token updated'
+ # annotations_reset: Annotations reset
+ # tags_reset: Tags reset
+ # entries_reset: Entries reset
entry:
notice:
# entry_already_saved: 'Entry already saved on %date%'
email_label: 'E-Mail-Adresse'
twoFactorAuthentication_label: 'Zwei-Faktor-Authentifizierung'
delete:
- # title: Delete my account (danger zone !)
+ # title: Delete my account (a.k.a danger zone)
# description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out.
- # confirm: Are you really sure? (it can't be UNDONE)
+ # confirm: Are you really sure? (THIS CAN'T BE UNDONE)
# button: Delete my account
+ reset:
+ # title: Reset area (a.k.a danger zone)
+ # description: By hiting buttons below you'll have ability to remove some informations from your account. Be aware that these actions are IRREVERSIBLE.
+ # annotations: Remove ALL annotations
+ # tags: Remove ALL tags
+ # entries: Remove ALL entries
+ # confirm: Are you really really sure? (THIS CAN'T BE UNDONE)
form_password:
old_password_label: 'Altes Kennwort'
new_password_label: 'Neues Kennwort'
tagging_rules_deleted: 'Tagging-Regel gelöscht'
user_added: 'Benutzer "%username%" erstellt'
rss_token_updated: 'RSS-Token aktualisiert'
+ # annotations_reset: Annotations reset
+ # tags_reset: Tags reset
+ # entries_reset: Entries reset
entry:
notice:
entry_already_saved: 'Eintrag bereits am %date% gespeichert'
email_label: 'Email'
twoFactorAuthentication_label: 'Two factor authentication'
delete:
- title: Delete my account (danger zone !)
+ title: Delete my account (a.k.a danger zone)
description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out.
- confirm: Are you really sure? (it can't be UNDONE)
+ confirm: Are you really sure? (THIS CAN'T BE UNDONE)
button: Delete my account
+ reset:
+ title: Reset area (a.k.a danger zone)
+ description: By hiting buttons below you'll have ability to remove some informations from your account. Be aware that these actions are IRREVERSIBLE.
+ annotations: Remove ALL annotations
+ tags: Remove ALL tags
+ entries: Remove ALL entries
+ confirm: Are you really really sure? (THIS CAN'T BE UNDONE)
form_password:
old_password_label: 'Current password'
new_password_label: 'New password'
tagging_rules_updated: 'Tagging rules updated'
tagging_rules_deleted: 'Tagging rule deleted'
rss_token_updated: 'RSS token updated'
+ annotations_reset: Annotations reset
+ tags_reset: Tags reset
+ entries_reset: Entries reset
entry:
notice:
entry_already_saved: 'Entry already saved on %date%'
email_label: 'Direccion e-mail'
twoFactorAuthentication_label: 'Autentificación de dos factores'
delete:
- # title: Delete my account (danger zone !)
+ # title: Delete my account (a.k.a danger zone)
# description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out.
- # confirm: Are you really sure? (it can't be UNDONE)
+ # confirm: Are you really sure? (THIS CAN'T BE UNDONE)
# button: Delete my account
+ reset:
+ # title: Reset area (a.k.a danger zone)
+ # description: By hiting buttons below you'll have ability to remove some informations from your account. Be aware that these actions are IRREVERSIBLE.
+ # annotations: Remove ALL annotations
+ # tags: Remove ALL tags
+ # entries: Remove ALL entries
+ # confirm: Are you really really sure? (THIS CAN'T BE UNDONE)
form_password:
old_password_label: 'Contraseña actual'
new_password_label: 'Nueva contraseña'
tagging_rules_deleted: 'Regla de etiquetado actualizada'
user_added: 'Usuario "%username%" añadido'
rss_token_updated: 'RSS token actualizado'
+ # annotations_reset: Annotations reset
+ # tags_reset: Tags reset
+ # entries_reset: Entries reset
entry:
notice:
entry_already_saved: 'Entrada ya guardada por %fecha%'
email_label: 'نشانی ایمیل'
twoFactorAuthentication_label: 'تأیید ۲مرحلهای'
delete:
- # title: Delete my account (danger zone !)
+ # title: Delete my account (a.k.a danger zone)
# description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out.
- # confirm: Are you really sure? (it can't be UNDONE)
+ # confirm: Are you really sure? (THIS CAN'T BE UNDONE)
# button: Delete my account
+ reset:
+ # title: Reset area (a.k.a danger zone)
+ # description: By hiting buttons below you'll have ability to remove some informations from your account. Be aware that these actions are IRREVERSIBLE.
+ # annotations: Remove ALL annotations
+ # tags: Remove ALL tags
+ # entries: Remove ALL entries
+ # confirm: Are you really really sure? (THIS CAN'T BE UNDONE)
form_password:
old_password_label: 'رمز قدیمی'
new_password_label: 'رمز تازه'
tagging_rules_deleted: 'قانون برچسبگذاری پاک شد'
user_added: 'کابر "%username%" افزوده شد'
rss_token_updated: 'کد آر-اس-اس بهروز شد'
+ # annotations_reset: Annotations reset
+ # tags_reset: Tags reset
+ # entries_reset: Entries reset
entry:
notice:
entry_already_saved: 'این مقاله در تاریخ %date% ذخیره شده بود'
delete:
title: Supprimer mon compte (attention danger !)
description: Si vous confirmez la suppression de votre compte, TOUS les articles, TOUS les tags, TOUTES les annotations et votre compte seront DÉFINITIVEMENT supprimé (c'est IRRÉVERSIBLE). Vous serez ensuite déconnecté.
- confirm: Vous êtes vraiment sûr ? (c'est IRRÉVERSIBLE !)
+ confirm: Vous êtes vraiment sûr ? (C'EST IRREVERSIBLE)
button: 'Supprimer mon compte'
+ reset:
+ title: Réinitialisation (attention danger !)
+ description: En cliquant sur les boutons ci-dessous vous avez la possibilité de supprimer certaines informations de votre compte. Attention, ces actions sont IRREVERSIBLES !
+ annotations: Supprimer TOUTES les annotations
+ tags: Supprimer TOUS les tags
+ entries: Supprimer TOUS les articles
+ confirm: Êtes-vous vraiment vraiment sûr ? (C'EST IRREVERSIBLE)
form_password:
old_password_label: 'Mot de passe actuel'
new_password_label: 'Nouveau mot de passe'
tagging_rules_deleted: 'Règle supprimée'
user_added: 'Utilisateur "%username%" ajouté'
rss_token_updated: 'Jeton RSS mis à jour'
+ annotations_reset: Annotations supprimées
+ tags_reset: Tags supprimés
+ entries_reset: Articles supprimés
entry:
notice:
entry_already_saved: 'Article déjà sauvergardé le %date%'
email_label: 'E-mail'
twoFactorAuthentication_label: 'Two factor authentication'
delete:
- # title: Delete my account (danger zone !)
+ # title: Delete my account (a.k.a danger zone)
# description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out.
- # confirm: Are you really sure? (it can't be UNDONE)
+ # confirm: Are you really sure? (THIS CAN'T BE UNDONE)
# button: Delete my account
+ reset:
+ # title: Reset area (a.k.a danger zone)
+ # description: By hiting buttons below you'll have ability to remove some informations from your account. Be aware that these actions are IRREVERSIBLE.
+ # annotations: Remove ALL annotations
+ # tags: Remove ALL tags
+ # entries: Remove ALL entries
+ # confirm: Are you really really sure? (THIS CAN'T BE UNDONE)
form_password:
old_password_label: 'Password corrente'
new_password_label: 'Nuova password'
tagging_rules_deleted: 'Regola di tagging aggiornate'
user_added: 'Utente "%username%" aggiunto'
rss_token_updated: 'RSS token aggiornato'
+ # annotations_reset: Annotations reset
+ # tags_reset: Tags reset
+ # entries_reset: Entries reset
entry:
notice:
entry_already_saved: 'Contenuto già salvato in data %date%'
email_label: 'Adreça de corrièl'
twoFactorAuthentication_label: 'Dobla autentificacion'
delete:
- # title: Delete my account (danger zone !)
+ # title: Delete my account (a.k.a danger zone)
# description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out.
- # confirm: Are you really sure? (it can't be UNDONE)
+ # confirm: Are you really sure? (THIS CAN'T BE UNDONE)
# button: Delete my account
+ reset:
+ # title: Reset area (a.k.a danger zone)
+ # description: By hiting buttons below you'll have ability to remove some informations from your account. Be aware that these actions are IRREVERSIBLE.
+ # annotations: Remove ALL annotations
+ # tags: Remove ALL tags
+ # entries: Remove ALL entries
+ # confirm: Are you really really sure? (THIS CAN'T BE UNDONE)
form_password:
old_password_label: 'Senhal actual'
new_password_label: 'Senhal novèl'
tagging_rules_deleted: 'Règla suprimida'
user_added: 'Utilizaire "%username%" ajustat'
rss_token_updated: 'Geton RSS mes a jorn'
+ # annotations_reset: Annotations reset
+ # tags_reset: Tags reset
+ # entries_reset: Entries reset
entry:
notice:
entry_already_saved: 'Article ja salvargardat lo %date%'
description: Jeżeli usuniesz swoje konto, wszystkie twoje artykuły, tagi, adnotacje, oraz konto zostaną trwale usunięte (operacja jest NIEODWRACALNA). Następnie zostaniesz wylogowany.
confirm: Jesteś pewien? (tej operacji NIE MOŻNA cofnąć)
button: Usuń moje konto
+ reset:
+ # title: Reset area (a.k.a danger zone)
+ # description: By hiting buttons below you'll have ability to remove some informations from your account. Be aware that these actions are IRREVERSIBLE.
+ # annotations: Remove ALL annotations
+ # tags: Remove ALL tags
+ # entries: Remove ALL entries
+ # confirm: Are you really really sure? (THIS CAN'T BE UNDONE)
form_password:
old_password_label: 'Stare hasło'
new_password_label: 'Nowe hasło'
tagging_rules_deleted: 'Reguła tagowania usunięta'
user_added: 'Użytkownik "%username%" dodany'
rss_token_updated: 'Token kanału RSS zaktualizowany'
+ # annotations_reset: Annotations reset
+ # tags_reset: Tags reset
+ # entries_reset: Entries reset
entry:
notice:
entry_already_saved: 'Wpis już został dodany %date%'
email_label: 'E-mail'
# twoFactorAuthentication_label: 'Two factor authentication'
delete:
- # title: Delete my account (danger zone !)
+ # title: Delete my account (a.k.a danger zone)
# description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out.
- # confirm: Are you really sure? (it can't be UNDONE)
+ # confirm: Are you really sure? (THIS CAN'T BE UNDONE)
# button: Delete my account
+ reset:
+ # title: Reset area (a.k.a danger zone)
+ # description: By hiting buttons below you'll have ability to remove some informations from your account. Be aware that these actions are IRREVERSIBLE.
+ # annotations: Remove ALL annotations
+ # tags: Remove ALL tags
+ # entries: Remove ALL entries
+ # confirm: Are you really really sure? (THIS CAN'T BE UNDONE)
form_password:
old_password_label: 'Parola veche'
new_password_label: 'Parola nouă'
# tagging_rules_deleted: 'Tagging rule deleted'
# user_added: 'User "%username%" added'
# rss_token_updated: 'RSS token updated'
+ # annotations_reset: Annotations reset
+ # tags_reset: Tags reset
+ # entries_reset: Entries reset
entry:
notice:
# entry_already_saved: 'Entry already saved on %date%'
email_label: 'E-posta'
twoFactorAuthentication_label: 'İki adımlı doğrulama'
delete:
- # title: Delete my account (danger zone !)
+ # title: Delete my account (a.k.a danger zone)
# description: If you remove your account, ALL your articles, ALL your tags, ALL your annotations and your account will be PERMANENTLY removed (it can't be UNDONE). You'll then be logged out.
- # confirm: Are you really sure? (it can't be UNDONE)
+ # confirm: Are you really sure? (THIS CAN'T BE UNDONE)
# button: Delete my account
+ reset:
+ # title: Reset area (a.k.a danger zone)
+ # description: By hiting buttons below you'll have ability to remove some informations from your account. Be aware that these actions are IRREVERSIBLE.
+ # annotations: Remove ALL annotations
+ # tags: Remove ALL tags
+ # entries: Remove ALL entries
+ # confirm: Are you really really sure? (THIS CAN'T BE UNDONE)
form_password:
old_password_label: 'Eski şifre'
new_password_label: 'Yeni şifre'
tagging_rules_deleted: 'Tagging rule deleted'
user_added: 'User "%username%" added'
rss_token_updated: 'RSS token updated'
+ # annotations_reset: Annotations reset
+ # tags_reset: Tags reset
+ # entries_reset: Entries reset
entry:
notice:
entry_already_saved: 'Entry already saved on %date%'
{{ form_widget(form.user._token) }}
</form>
+ <br /><hr /><br />
+
+ <div class="row">
+ <h5>{{ 'config.reset.title'|trans }}</h5>
+ <p>{{ 'config.reset.description'|trans }}</p>
+ <a href="{{ path('config_reset', { type: 'annotations'}) }}" onclick="return confirm('{{ 'config.reset.confirm'|trans|escape('js') }}')" class="waves-effect waves-light btn red">
+ {{ 'config.reset.annotations'|trans }}
+ </a>
+ <a href="{{ path('config_reset', { type: 'tags'}) }}" onclick="return confirm('{{ 'config.reset.confirm'|trans|escape('js') }}')" class="waves-effect waves-light btn red">
+ {{ 'config.reset.tags'|trans }}
+ </a>
+ <a href="{{ path('config_reset', { type: 'entries'}) }}" onclick="return confirm('{{ 'config.reset.confirm'|trans|escape('js') }}')" class="waves-effect waves-light btn red">
+ {{ 'config.reset.entries'|trans }}
+ </a>
+ </div>
+
{% if enabled_users > 1 %}
<br /><hr /><br />
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Wallabag\CoreBundle\Entity\Config;
use Wallabag\UserBundle\Entity\User;
+use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\CoreBundle\Entity\Tag;
+use Wallabag\AnnotationBundle\Entity\Annotation;
class ConfigControllerTest extends WallabagCoreTestCase
{
$this->assertEmpty($entries);
}
+
+ public function testReset()
+ {
+ $this->logInAs('empty');
+ $client = $this->getClient();
+
+ $em = $client->getContainer()->get('doctrine.orm.entity_manager');
+
+ $user = static::$kernel->getContainer()->get('security.token_storage')->getToken()->getUser();
+
+ $tag = new Tag();
+ $tag->setLabel('super');
+ $em->persist($tag);
+
+ $entry = new Entry($user);
+ $entry->setUrl('http://www.lemonde.fr/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html');
+ $entry->setContent('Youhou');
+ $entry->setTitle('Youhou');
+ $entry->addTag($tag);
+ $em->persist($entry);
+
+ $entry2 = new Entry($user);
+ $entry2->setUrl('http://www.lemonde.de/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html');
+ $entry2->setContent('Youhou');
+ $entry2->setTitle('Youhou');
+ $entry2->addTag($tag);
+ $em->persist($entry2);
+
+ $annotation = new Annotation($user);
+ $annotation->setText('annotated');
+ $annotation->setQuote('annotated');
+ $annotation->setRanges([]);
+ $annotation->setEntry($entry);
+ $em->persist($annotation);
+
+ $em->flush();
+
+ // reset annotations
+ $crawler = $client->request('GET', '/config#set3');
+
+ $this->assertEquals(200, $client->getResponse()->getStatusCode());
+
+ $crawler = $client->click($crawler->selectLink('config.reset.annotations')->link());
+
+ $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertContains('flashes.config.notice.annotations_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
+
+ $annotationsReset = $em
+ ->getRepository('WallabagAnnotationBundle:Annotation')
+ ->findAnnotationsByPageId($entry->getId(), $user->getId());
+
+ $this->assertEmpty($annotationsReset, 'Annotations were reset');
+
+ // reset tags
+ $crawler = $client->request('GET', '/config#set3');
+
+ $this->assertEquals(200, $client->getResponse()->getStatusCode());
+
+ $crawler = $client->click($crawler->selectLink('config.reset.tags')->link());
+
+ $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertContains('flashes.config.notice.tags_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
+
+ $tagReset = $em
+ ->getRepository('WallabagCoreBundle:Tag')
+ ->countAllTags($user->getId());
+
+ $this->assertEquals(0, $tagReset, 'Tags were reset');
+
+ // reset entries
+ $crawler = $client->request('GET', '/config#set3');
+
+ $this->assertEquals(200, $client->getResponse()->getStatusCode());
+
+ $crawler = $client->click($crawler->selectLink('config.reset.entries')->link());
+
+ $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertContains('flashes.config.notice.entries_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
+
+ $entryReset = $em
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->countAllEntriesByUsername($user->getId());
+
+ $this->assertEquals(0, $entryReset, 'Entries were reset');
+ }
+
+ public function testResetEntriesCascade()
+ {
+ $this->logInAs('empty');
+ $client = $this->getClient();
+
+ $em = $client->getContainer()->get('doctrine.orm.entity_manager');
+
+ $user = static::$kernel->getContainer()->get('security.token_storage')->getToken()->getUser();
+
+ $tag = new Tag();
+ $tag->setLabel('super');
+ $em->persist($tag);
+
+ $entry = new Entry($user);
+ $entry->setUrl('http://www.lemonde.fr/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html');
+ $entry->setContent('Youhou');
+ $entry->setTitle('Youhou');
+ $entry->addTag($tag);
+ $em->persist($entry);
+
+ $annotation = new Annotation($user);
+ $annotation->setText('annotated');
+ $annotation->setQuote('annotated');
+ $annotation->setRanges([]);
+ $annotation->setEntry($entry);
+ $em->persist($annotation);
+
+ $em->flush();
+
+ $crawler = $client->request('GET', '/config#set3');
+
+ $this->assertEquals(200, $client->getResponse()->getStatusCode());
+
+ $crawler = $client->click($crawler->selectLink('config.reset.entries')->link());
+
+ $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertContains('flashes.config.notice.entries_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
+
+ $entryReset = $em
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->countAllEntriesByUsername($user->getId());
+
+ $this->assertEquals(0, $entryReset, 'Entries were reset');
+
+ $tagReset = $em
+ ->getRepository('WallabagCoreBundle:Tag')
+ ->countAllTags($user->getId());
+
+ $this->assertEquals(0, $tagReset, 'Tags were reset');
+
+ $annotationsReset = $em
+ ->getRepository('WallabagAnnotationBundle:Annotation')
+ ->findAnnotationsByPageId($entry->getId(), $user->getId());
+
+ $this->assertEmpty($annotationsReset, 'Annotations were reset');
+ }
}