aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php85
1 files changed, 85 insertions, 0 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
index 1954c654..23e7e786 100644
--- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
@@ -570,4 +570,89 @@ class ConfigControllerTest extends WallabagCoreTestCase
570 $config->set('demo_mode_enabled', 0); 570 $config->set('demo_mode_enabled', 0);
571 $config->set('demo_mode_username', 'wallabag'); 571 $config->set('demo_mode_username', 'wallabag');
572 } 572 }
573
574 public function testDeleteUserButtonVisibility()
575 {
576 $this->logInAs('admin');
577 $client = $this->getClient();
578
579 $crawler = $client->request('GET', '/config');
580
581 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
582 $this->assertContains('config.form_user.delete_account', $body[0]);
583
584 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
585
586 $user = $em
587 ->getRepository('WallabagUserBundle:User')
588 ->findOneByUsername('wallace');
589 $user->setExpired(1);
590 $em->persist($user);
591
592 $user = $em
593 ->getRepository('WallabagUserBundle:User')
594 ->findOneByUsername('empty');
595 $user->setExpired(1);
596 $em->persist($user);
597
598 $user = $em
599 ->getRepository('WallabagUserBundle:User')
600 ->findOneByUsername('bob');
601 $user->setExpired(1);
602 $em->persist($user);
603
604 $em->flush();
605
606 $crawler = $client->request('GET', '/config');
607
608 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
609 $this->assertNotContains('config.form_user.delete_account', $body[0]);
610
611 $client->request('GET', '/account/delete');
612 $this->assertEquals(403, $client->getResponse()->getStatusCode());
613
614 $user = $em
615 ->getRepository('WallabagUserBundle:User')
616 ->findOneByUsername('wallace');
617 $user->setExpired(0);
618 $em->persist($user);
619
620 $user = $em
621 ->getRepository('WallabagUserBundle:User')
622 ->findOneByUsername('empty');
623 $user->setExpired(0);
624 $em->persist($user);
625
626 $user = $em
627 ->getRepository('WallabagUserBundle:User')
628 ->findOneByUsername('bob');
629 $user->setExpired(0);
630 $em->persist($user);
631
632 $em->flush();
633 }
634
635 public function testDeleteAccount()
636 {
637 $this->logInAs('wallace');
638 $client = $this->getClient();
639
640 $crawler = $client->request('GET', '/config');
641
642 $deleteLink = $crawler->filter('.red')->last()->link();
643
644 $client->click($deleteLink);
645 $this->assertEquals(302, $client->getResponse()->getStatusCode());
646
647 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
648 $user = $em
649 ->getRepository('WallabagUserBundle:User')
650 ->createQueryBuilder('u')
651 ->where('u.username = :username')->setParameter('username', 'wallace')
652 ->getQuery()
653 ->getOneOrNullResult()
654 ;
655
656 $this->assertTrue(false !== $user);
657 }
573} 658}