UserControllerTest.php 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. <?php
  2. namespace Muzich\CoreBundle\Tests\Controller;
  3. use Muzich\CoreBundle\lib\FunctionalTest;
  4. class UserControllerTest extends FunctionalTest
  5. {
  6. public function testTagsFavoritesSuccess()
  7. {
  8. /**
  9. * Inscription d'un utilisateur
  10. */
  11. $this->client = self::createClient();
  12. $hardtek_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek')->getId();
  13. $tribe_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe')->getId();
  14. $this->crawler = $this->client->request('GET', $this->generateUrl('home'));
  15. $this->isResponseSuccess();
  16. $this->procedure_registration_success(
  17. 'raoulc.def4v65sds@gmail.com'
  18. );
  19. // Il ne doit y avoir aucun enregistrements de tags favoris
  20. $Favorites = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
  21. ->findBy(array(
  22. 'user' => $this->getUser()->getId()
  23. ))
  24. ;
  25. $this->assertEquals(0, count($Favorites));
  26. $this->goToPage($this->generateUrl('start'));
  27. // On a attérit sur la page de présentation et de selection des tags favoris
  28. $this->exist('form[action="'.($url = $this->generateUrl('update_tag_favorites')).'"]');
  29. $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
  30. $form['tag_favorites_form[tags]'] = json_encode(array($hardtek_id,$tribe_id));
  31. $this->submit($form);
  32. $this->isResponseRedirection();
  33. $this->followRedirection();
  34. $this->isResponseSuccess();
  35. // Désormais il y a deux tags favoris pour cet utilisateur
  36. $Favorites = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
  37. ->findBy(array(
  38. 'user' => $this->getUser()->getId()
  39. ))
  40. ;
  41. $this->assertEquals(2, count($Favorites));
  42. $Favorites = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
  43. ->findBy(array(
  44. 'user' => $this->getUser()->getId(),
  45. 'tag' => $hardtek_id
  46. ))
  47. ;
  48. $this->assertEquals(1, count($Favorites));
  49. $Favorites = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
  50. ->findBy(array(
  51. 'user' => $this->getUser()->getId(),
  52. 'tag' => $tribe_id
  53. ))
  54. ;
  55. $this->assertEquals(1, count($Favorites));
  56. }
  57. /**
  58. * Test du changement de mot de passe par le baisis de la page 'Mon compte'
  59. */
  60. public function testChangePassword()
  61. {
  62. $this->client = self::createClient();
  63. $this->connectUser('bux', 'toor');
  64. // Ouverture de la page Mon compte
  65. $this->crawler = $this->client->request('GET', $this->generateUrl('my_account'));
  66. $this->exist('form[action="'.($url = $this->generateUrl(
  67. 'change_password', array('open' => 'change_password')
  68. )).'"]');
  69. $this->exist('form[action="'.$url.'"] input[id="user_password_plain_password_first"]');
  70. $this->exist('form[action="'.$url.'"] input[id="user_password_plain_password_second"]');
  71. $this->exist('form[action="'.$url.'"] input[type="submit"]');
  72. $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
  73. $form['user_password[plain_password][first]'] = 'trololo';
  74. $form['user_password[plain_password][second]'] = 'trololo';
  75. $this->submit($form);
  76. $this->isResponseRedirection();
  77. $this->followRedirection();
  78. $this->isResponseSuccess();
  79. // On se déconnecte
  80. $this->disconnectUser();
  81. // Et on se connecte avec le nouveau mot de passe
  82. $this->connectUser('bux', 'trololo');
  83. }
  84. /**
  85. * Test du formulaire de mise a jour des tags par le baisis de la page 'Mon compte'
  86. */
  87. public function testUpdateFavoriteTags()
  88. {
  89. $this->client = self::createClient();
  90. $this->connectUser('bob', 'toor');
  91. // Ouverture de la page Mon compte
  92. $this->crawler = $this->client->request('GET', $this->generateUrl('my_account'));
  93. $hardtek_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek')->getId();
  94. $tribe_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe')->getId();
  95. // Bob n'a aucun tag préféré
  96. $prefereds = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
  97. ->findBy(array('user' => $this->getUser()->getId()))
  98. ;
  99. $this->assertEquals(0, count($prefereds));
  100. $this->exist('form[action="'.($url = $this->generateUrl(
  101. 'update_tag_favorites', array('redirect' => 'account')
  102. )).'"]');
  103. $this->exist('form[action="'.$url.'"] input[type="submit"]');
  104. $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
  105. $form['tag_favorites_form[tags]'] = json_encode(array($hardtek_id,$tribe_id));
  106. $this->submit($form);
  107. $this->isResponseRedirection();
  108. $this->followRedirection();
  109. $this->isResponseSuccess();
  110. // On a été redirigé sur la page Mon compte
  111. $this->exist('form[action="'.$url.'"]');
  112. // On vérifie la présence en base des enregistrements
  113. $prefereds = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
  114. ->findBy(array('user' => $this->getUser()->getId()))
  115. ;
  116. $this->assertEquals(2, count($prefereds));
  117. // On vérifie la présence en base des enregistrements
  118. $prefereds = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
  119. ->findBy(array(
  120. 'user' => $this->getUser()->getId(),
  121. 'tag' => $hardtek_id
  122. ))
  123. ;
  124. $this->assertEquals(1, count($prefereds));
  125. // On vérifie la présence en base des enregistrements
  126. $prefereds = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
  127. ->findBy(array(
  128. 'user' => $this->getUser()->getId(),
  129. 'tag' => $tribe_id
  130. ))
  131. ;
  132. $this->assertEquals(1, count($prefereds));
  133. }
  134. /**
  135. * Test de al procédure de changement d'email.
  136. */
  137. public function testChangeEmail()
  138. {
  139. $this->client = self::createClient();
  140. $this->connectUser('bob', 'toor');
  141. $bob = $this->findUserByUsername('bob');
  142. // Ouverture de la page Mon compte
  143. $this->crawler = $this->client->request('GET', $this->generateUrl('my_account'));
  144. // Le mail en cours n'est pas celui que nous voulons mettre
  145. $this->assertFalse($bob->getEmail() == 'trololololooo@trolo.com');
  146. // Nous n'avons pas encore demandé de nouveau mail
  147. $this->assertTrue($bob->getEmailRequested() == null);
  148. $this->assertTrue($bob->getEmailRequestedDatetime() == null);
  149. // On fait un premier essaie avec une email mal formulé
  150. $this->exist('form[action="'.($url = $this->generateUrl(
  151. 'change_email_request'
  152. )).'"]');
  153. $this->exist('form[action="'.$url.'"] input[type="submit"]');
  154. $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
  155. $form['form[email]'] = 'trololololooo@trolo';
  156. $this->submit($form);
  157. // Il n'y as pas de redirection
  158. $this->isResponseSuccess();
  159. $bob = $this->findUserByUsername('bob');
  160. // Les champs n'ont pas bougés
  161. $this->assertFalse($bob->getEmail() == 'trololololooo@trolo.com');
  162. // Nous n'avons pas encore demandé de nouveau mail
  163. $this->assertTrue($bob->getEmailRequested() == null);
  164. $this->assertTrue($bob->getEmailRequestedDatetime() == null);
  165. $this->exist('form[action="'.($url = $this->generateUrl(
  166. 'change_email_request'
  167. )).'"]');
  168. $this->exist('form[action="'.$url.'"] input[type="submit"]');
  169. $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
  170. $form['form[email]'] = 'trololololooo@trolo.com';
  171. $this->submit($form);
  172. // Ce coup-ci c'est bien une redirection
  173. $this->isResponseRedirection();
  174. // Un mail a été envoyé
  175. $mc = $this->getMailerMessageDataCollector();
  176. $this->assertEquals(1, $mc->getMessageCount());
  177. $mails = $mc->getMessages();
  178. $mail = $mails[0];
  179. // Les champs ont bougés
  180. $bob = $this->findUserByUsername('bob');
  181. $this->assertFalse($bob->getEmail() == 'trololololooo@trolo.com');
  182. $this->assertFalse($bob->getEmailRequested() == null);
  183. $this->assertTrue($bob->getEmailRequested() == 'trololololooo@trolo.com');
  184. $this->assertFalse($bob->getEmailRequestedDatetime() == null);
  185. $this->followRedirection();
  186. $this->isResponseSuccess();
  187. // On ouvre un lien erroné
  188. $badurl = $this->generateUrl(
  189. 'change_email_confirm',
  190. array('token' => $this->getUser()->getConfirmationToken()),
  191. true
  192. );
  193. $this->crawler = $this->client->request('GET', $badurl);
  194. $this->isResponseRedirection();
  195. $this->followRedirection();
  196. $this->isResponseSuccess();
  197. $this->exist('div.error');
  198. // Et les champs ont pas bougés
  199. $bob = $this->findUserByUsername('bob');
  200. $this->assertFalse($bob->getEmail() == 'trololololooo@trolo.com');
  201. $this->assertFalse($bob->getEmailRequested() == null);
  202. $this->assertTrue($bob->getEmailRequested() == 'trololololooo@trolo.com');
  203. $this->assertFalse($bob->getEmailRequestedDatetime() == null);
  204. $this->assertTrue(!is_null(strpos($mail->getBody(), ($url = $this->generateUrl(
  205. 'change_email_confirm',
  206. array('token' => $token = hash('sha256', $bob->getConfirmationToken().'trololololooo@trolo.com')),
  207. true
  208. )))));
  209. // On ouvre le bon lien
  210. $this->crawler = $this->client->request('GET', $url);
  211. // C'est un succés
  212. $this->isResponseRedirection();
  213. $this->followRedirection();
  214. $this->isResponseSuccess();
  215. $this->notExist('div.error');
  216. // Et les champs ont bougés
  217. $bob = $this->findUserByUsername('bob');
  218. $this->assertTrue($bob->getEmail() == 'trololololooo@trolo.com');
  219. $this->assertTrue($bob->getEmailRequested() == null);
  220. $this->assertFalse($bob->getEmailRequestedDatetime() == null);
  221. // Par contre si on refait une demande maintenant ca échoue (délais entre demandes)
  222. $this->exist('form[action="'.($url = $this->generateUrl(
  223. 'change_email_request'
  224. )).'"]');
  225. $this->exist('form[action="'.$url.'"] input[type="submit"]');
  226. $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
  227. $form['form[email]'] = 'trololololooo222@trolo.com';
  228. $this->submit($form);
  229. // Il n'y as pas de redirection
  230. $this->isResponseRedirection();
  231. $this->followRedirection();
  232. $this->isResponseSuccess();
  233. $this->exist('div.error');
  234. // Et les champs ont bougés
  235. $bob = $this->findUserByUsername('bob');
  236. $this->assertTrue($bob->getEmail() == 'trololololooo@trolo.com');
  237. $this->assertTrue($bob->getEmailRequested() == null);
  238. $this->assertFalse($bob->getEmailRequestedDatetime() == null);
  239. // Si par contre on manipule le dateTime on pourra
  240. $bob = $this->findUserByUsername('bob');
  241. $bob->setEmailRequestedDatetime(
  242. $this->getUser()->getEmailRequestedDatetime()
  243. - $this->getContainer()->getParameter('changeemail_security_delay')
  244. );
  245. $this->getDoctrine()->getEntityManager()->flush();
  246. $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
  247. $form['form[email]'] = 'trololololooo222@trolo.com';
  248. $this->submit($form);
  249. // Ce coup-ci c'est bien une redirection
  250. $this->isResponseRedirection();
  251. // Un mail a été envoyé
  252. $mc = $this->getMailerMessageDataCollector();
  253. $this->assertEquals(1, $mc->getMessageCount());
  254. $mails = $mc->getMessages();
  255. $mail = $mails[0];
  256. $this->assertTrue(!is_null(strpos($mail->getBody(), ($url = $this->generateUrl(
  257. 'change_email_confirm',
  258. array('token' => hash('sha256', $this->getUser()->getConfirmationToken().'trololololooo222@trolo.com')),
  259. true
  260. )))));
  261. // Les champs ont bougés
  262. $bob = $this->findUserByUsername('bob');
  263. $this->assertFalse($bob->getEmail() == 'trololololooo222@trolo.com');
  264. $this->assertFalse($bob->getEmailRequested() == null);
  265. $this->assertTrue($bob->getEmailRequested() == 'trololololooo222@trolo.com');
  266. $this->assertFalse($bob->getEmailRequestedDatetime() == null);
  267. $this->followRedirection();
  268. $this->isResponseSuccess();
  269. }
  270. public function testAddElementTagToFavorites()
  271. {
  272. $this->client = self::createClient();
  273. $this->connectUser('paul', 'toor');
  274. $paul = $this->getUser();
  275. // D'après les fixtures paul n'a pas de tags favoris
  276. $fav = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
  277. ->findBy(array(
  278. 'user' => $paul->getId()
  279. ))
  280. ;
  281. $this->assertEquals(0, count($fav));
  282. // Ajout d'un tag en favoris (ajax)
  283. $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')
  284. ->findOneByName('Tribe')
  285. ;
  286. $url = $this->generateUrl('ajax_tag_add_to_favorites', array(
  287. 'tag_id' => $tribe->getId(),
  288. 'token' => $paul->getPersonalHash($tribe->getId())
  289. ));
  290. $crawler = $this->client->request('GET', $url, array(), array(), array(
  291. 'HTTP_X-Requested-With' => 'XMLHttpRequest',
  292. ));
  293. $this->isResponseSuccess();
  294. $fav = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
  295. ->findBy(array(
  296. 'user' => $paul->getId()
  297. ))
  298. ;
  299. $this->assertEquals(1, count($fav));
  300. $this->assertEquals('Tribe', $fav[0]->getTag()->getName());
  301. // Si on rajoute le même tag il ne doit pas y avoir de changement
  302. $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')
  303. ->findOneByName('Tribe')
  304. ;
  305. $url = $this->generateUrl('ajax_tag_add_to_favorites', array(
  306. 'tag_id' => $tribe->getId(),
  307. 'token' => $paul->getPersonalHash($tribe->getId())
  308. ));
  309. $crawler = $this->client->request('GET', $url, array(), array(), array(
  310. 'HTTP_X-Requested-With' => 'XMLHttpRequest',
  311. ));
  312. $this->isResponseSuccess();
  313. $fav = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
  314. ->findBy(array(
  315. 'user' => $paul->getId()
  316. ))
  317. ;
  318. $this->assertEquals(1, count($fav));
  319. $this->assertEquals('Tribe', $fav[0]->getTag()->getName());
  320. // Si on ajoute un nouveau tag
  321. $hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')
  322. ->findOneByName('Hardtek')
  323. ;
  324. $url = $this->generateUrl('ajax_tag_add_to_favorites', array(
  325. 'tag_id' => $hardtek->getId(),
  326. 'token' => $paul->getPersonalHash($hardtek->getId())
  327. ));
  328. $crawler = $this->client->request('GET', $url, array(), array(), array(
  329. 'HTTP_X-Requested-With' => 'XMLHttpRequest',
  330. ));
  331. $this->isResponseSuccess();
  332. $fav = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
  333. ->findBy(array(
  334. 'user' => $paul->getId()
  335. ))
  336. ;
  337. $this->assertEquals(2, count($fav));
  338. $this->assertEquals('Tribe', $fav[0]->getTag()->getName());
  339. $this->assertEquals('Hardtek', $fav[1]->getTag()->getName());
  340. }
  341. public function testUpdateAddress()
  342. {
  343. $this->client = self::createClient();
  344. $this->connectUser('paul', 'toor');
  345. $paul = $this->getUser();
  346. // D'après les fixtures, pas d'adresse pour paul
  347. $this->assertEquals($paul->getTown(), null);
  348. $this->assertEquals($paul->getCountry(), null);
  349. $crawler = $this->client->request(
  350. 'POST',
  351. $this->generateUrl('update_address', array('token' => $this->getUser()->getPersonalHash())),
  352. array(
  353. 'town' => '',
  354. 'country' => ''
  355. ),
  356. array(),
  357. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  358. );
  359. $this->isResponseSuccess();
  360. $response = json_decode($this->client->getResponse()->getContent(), true);
  361. $this->assertEquals($response['status'], 'error');
  362. $this->assertEquals(count($response['errors']), '2');
  363. $this->assertEquals($response['errors'], array(
  364. $this->getContainer()->get('translator')->trans('my_account.address.form.errors.notown', array(), 'userui'),
  365. $this->getContainer()->get('translator')->trans('my_account.address.form.errors.nocountry', array(), 'userui')
  366. ));
  367. $paul = $this->getUser();
  368. $this->assertEquals($paul->getTown(), null);
  369. $this->assertEquals($paul->getCountry(), null);
  370. /////
  371. $crawler = $this->client->request(
  372. 'POST',
  373. $this->generateUrl('update_address', array('token' => $this->getUser()->getPersonalHash())),
  374. array(
  375. 'town' => 'peyruis',
  376. 'country' => ''
  377. ),
  378. array(),
  379. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  380. );
  381. $this->isResponseSuccess();
  382. $response = json_decode($this->client->getResponse()->getContent(), true);
  383. $this->assertEquals($response['status'], 'error');
  384. $this->assertEquals(count($response['errors']), '1');
  385. $this->assertEquals($response['errors'], array(
  386. $this->getContainer()->get('translator')->trans('my_account.address.form.errors.nocountry', array(), 'userui')
  387. ));
  388. $paul = $this->getUser();
  389. $this->assertEquals($paul->getTown(), null);
  390. $this->assertEquals($paul->getCountry(), null);
  391. /////
  392. $crawler = $this->client->request(
  393. 'POST',
  394. $this->generateUrl('update_address', array('token' => $this->getUser()->getPersonalHash())),
  395. array(
  396. 'town' => 'peyruis',
  397. 'country' => 'france'
  398. ),
  399. array(),
  400. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  401. );
  402. $this->isResponseSuccess();
  403. $response = json_decode($this->client->getResponse()->getContent(), true);
  404. $paul = $this->getUser();
  405. $this->assertEquals($response['status'], 'success');
  406. $this->assertEquals($paul->getTown(), 'peyruis');
  407. $this->assertEquals($paul->getCountry(), 'france');
  408. }
  409. public function testPreferencesUpdate()
  410. {
  411. $this->client = self::createClient();
  412. $this->connectUser('paul', 'toor');
  413. $paul = $this->getUser();
  414. $this->crawler = $this->client->request('GET', $this->generateUrl('my_account'));
  415. $this->isResponseSuccess();
  416. $this->assertEquals(true, $paul->mail_newsletter);
  417. $this->assertEquals(true, $paul->mail_partner);
  418. $form = $this->selectForm('div#myaccount_preferences form input[type="submit"]');
  419. $form['form[mail_newsletter]']->untick();
  420. $form['form[mail_partner]']->untick();
  421. $this->submit($form);
  422. $this->isResponseRedirection();
  423. $this->followRedirection();
  424. $this->isResponseSuccess();
  425. $paul = $this->getUser('paul');
  426. $this->assertEquals(false, $paul->mail_newsletter);
  427. $this->assertEquals(false, $paul->mail_partner);
  428. }
  429. public function testPrivacyUpdate()
  430. {
  431. $this->client = self::createClient();
  432. $bux = $this->findUserByUsername('bux');
  433. $this->checkFavoritesViewable($bux, true);
  434. $this->connectUser('bux', 'toor');
  435. $this->updateFavoritePrivacy(false);
  436. $this->disconnectUser();
  437. $this->checkFavoritesViewable($bux, false);
  438. $this->connectUser('paul', 'toor');
  439. $this->checkFavoritesViewable($bux, false);
  440. $this->disconnectUser();
  441. $this->connectUser('bux', 'toor');
  442. $this->checkFavoritesViewable($bux, true);
  443. }
  444. protected function checkFavoritesViewable($user, $public)
  445. {
  446. $this->goToPage($this->generateUrl('favorite_user_list', array('slug' => $user->getSlug(), '_locale' => 'fr')));
  447. $this->isResponseSuccess();
  448. if ($public)
  449. $this->notExist('p.favorites_no_publics');
  450. if (!$public)
  451. $this->exist('p.favorites_no_publics');
  452. }
  453. protected function updateFavoritePrivacy($public)
  454. {
  455. $this->goToPage($this->generateUrl('my_account'));
  456. $form = $this->selectForm('form.privacy input[type="submit"]');
  457. if ($public)
  458. $form['user_privacy[favorites_publics]']->tick();
  459. if (!$public)
  460. $form['user_privacy[favorites_publics]']->untick();
  461. $this->submit($form);
  462. $this->isResponseRedirection();
  463. $this->followRedirection();
  464. $this->isResponseSuccess();
  465. }
  466. public function testDeleteUser()
  467. {
  468. $this->client = self::createClient();
  469. $joelle = $this->findUserByUsername('joelle');
  470. $this->assertEquals('joelle', $joelle->getUsername());
  471. $this->assertEquals('joelle@root', $joelle->getEmail());
  472. $this->connectUser('joelle', 'toor');
  473. $this->deleteUser('toor');
  474. $joelle = $this->findOneBy('User', array('id' => $joelle->getId()));
  475. $this->assertTrue('joelle' != $joelle->getUsername());
  476. $this->assertTrue('joelle@mail.com' != $joelle->getEmail());
  477. $this->connectUser('joelle', 'toor', null, false);
  478. }
  479. protected function deleteUser($password)
  480. {
  481. $this->goToPage($this->generateUrl('my_account'));
  482. $this->exist('form.delete');
  483. $form = $this->selectForm('form.delete input[type="submit"]');
  484. $form['delete_user_form[current_password]'] = $password;
  485. $this->submit($form);
  486. $this->isResponseRedirection();
  487. $this->followRedirection();
  488. $this->isResponseRedirection();
  489. $this->followRedirection();
  490. //$this->outputDebug();
  491. $this->isResponseSuccess();
  492. }
  493. }