Browse Source

test fct: inscription (light)

bastien 13 years ago
parent
commit
48e9153da2
1 changed files with 44 additions and 0 deletions
  1. 44 0
      src/Muzich/CoreBundle/Tests/Controller/IndexControllerTest.php

+ 44 - 0
src/Muzich/CoreBundle/Tests/Controller/IndexControllerTest.php View File

@@ -38,4 +38,48 @@ class IndexControllerTest extends FunctionalTest
38 38
     $user = $this->getUser();
39 39
     $this->assertEquals('paul', $user->getUsername());
40 40
   }
41
+  
42
+  public function testRegistration()
43
+  {
44
+    /**
45
+     * Inscription d'un utilisateur
46
+     */
47
+    $this->client = self::createClient();
48
+
49
+    $this->crawler = $this->client->request('GET', $this->generateUrl('index'));
50
+    $this->isResponseSuccess();
51
+
52
+    $this->assertEquals('anon.', $this->getUser());
53
+    
54
+    $this->exist('div.register');
55
+    $this->exist('form[action="'.($url = $this->generateUrl('register')).'"]');
56
+    $this->exist('form[action="'.$url.'"] input[id="fos_user_registration_form_username"]');
57
+    $this->exist('form[action="'.$url.'"] input[id="fos_user_registration_form_email"]');
58
+    $this->exist('form[action="'.$url.'"] input[id="fos_user_registration_form_plainPassword_first"]');
59
+    $this->exist('form[action="'.$url.'"] input[id="fos_user_registration_form_plainPassword_second"]');
60
+    $this->exist('form[action="'.$url.'"] input[type="submit"]');
61
+    
62
+    $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
63
+    $form['fos_user_registration_form[username]'] = 'raoul';
64
+    $form['fos_user_registration_form[email]'] = 'raoul.45gf64z@gmail.com';
65
+    $form['fos_user_registration_form[plainPassword][first]'] = 'toor';
66
+    $form['fos_user_registration_form[plainPassword][second]'] = 'toor';
67
+    $this->submit($form);
68
+    
69
+    $this->isResponseRedirection();
70
+    $this->followRedirection();
71
+    $this->isResponseSuccess();
72
+
73
+    $user = $this->getUser();
74
+    $this->assertEquals('raoul', $user->getUsername());
75
+    
76
+    /*
77
+     * TODO: Vérifier les données en base
78
+     */
79
+  }
80
+  
81
+  /*
82
+   * TODO: Vérifier le comportement des formulaires lorsque l'on rentre de mauvaises données
83
+   */
84
+  
41 85
 }