Browse Source

Mise a jour des tests pour le token d'iscription.

bastien 13 years ago
parent
commit
ecf7ab83e3

+ 25 - 5
src/Muzich/CoreBundle/Tests/Controller/IndexControllerTest.php View File

@@ -3,6 +3,7 @@
3 3
 namespace Muzich\CoreBundle\Tests\Controller;
4 4
 
5 5
 use Muzich\CoreBundle\lib\FunctionalTest;
6
+use Muzich\CoreBundle\Entity\RegistrationToken;
6 7
 
7 8
 class IndexControllerTest extends FunctionalTest
8 9
 {
@@ -77,6 +78,13 @@ class IndexControllerTest extends FunctionalTest
77 78
 
78 79
     $this->assertEquals('anon.', $this->getUser());
79 80
     
81
+    // On a besoin d'un token pour le moment
82
+    $token = new RegistrationToken();
83
+    $token->setToken('4vcsdv54svqcc3q1v54sdv6qs');
84
+    $em = $this->getDoctrine()->getEntityManager();
85
+    $em->persist($token);
86
+    $em->flush();
87
+    
80 88
     $this->exist('div.register');
81 89
     $this->exist('form[action="'.($url = $this->generateUrl('register')).'"]');
82 90
     $this->exist('form[action="'.$url.'"] input[id="fos_user_registration_form_username"]');
@@ -89,7 +97,8 @@ class IndexControllerTest extends FunctionalTest
89 97
       'raoula', 
90 98
       'raoula.def4v65sds@gmail.com', 
91 99
       'toor', 
92
-      'toor'
100
+      'toor',
101
+      '4vcsdv54svqcc3q1v54sdv6qs'
93 102
     );
94 103
   }
95 104
   
@@ -101,12 +110,20 @@ class IndexControllerTest extends FunctionalTest
101 110
      */
102 111
     $this->client = self::createClient();
103 112
 
113
+    // On a besoin d'un token pour le moment
114
+    $token = new RegistrationToken();
115
+    $token->setToken('45gf645jgf6xqz4dc');
116
+    $em = $this->getDoctrine()->getEntityManager();
117
+    $em->persist($token);
118
+    $em->flush();
119
+    
104 120
     // Mots de passe différents
105 121
     $this->procedure_registration_failure(
106 122
       'raoulb', 
107 123
       'raoulb.def4v65sds@gmail.com', 
108 124
       'toor', 
109
-      'toorr'
125
+      'toorr',
126
+      '45gf645jgf6xqz4dc'
110 127
     );
111 128
 
112 129
     // Pseudo trop court
@@ -114,7 +131,8 @@ class IndexControllerTest extends FunctionalTest
114 131
       'ra', 
115 132
       'raoulb.def4v65sds@gmail.com', 
116 133
       'toor', 
117
-      'toor'
134
+      'toor',
135
+      '45gf645jgf6xqz4dc'
118 136
     );
119 137
     
120 138
     // Pseudo trop long
@@ -124,7 +142,8 @@ class IndexControllerTest extends FunctionalTest
124 142
          .'uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuul', 
125 143
       'raoulb.def4v65sds@gmail.com', 
126 144
       'toor', 
127
-      'toor'
145
+      'toor',
146
+      '45gf645jgf6xqz4dc'
128 147
     );
129 148
 
130 149
     // Email invalide
@@ -132,7 +151,8 @@ class IndexControllerTest extends FunctionalTest
132 151
       'raoulc', 
133 152
       'raoulb.def4v65sds@gmail', 
134 153
       'toor', 
135
-      'toor'
154
+      'toor',
155
+      '45gf645jgf6xqz4dc'
136 156
     );
137 157
   }
138 158
   

+ 8 - 5
src/Muzich/CoreBundle/lib/FunctionalTest.php View File

@@ -77,17 +77,18 @@ class FunctionalTest extends WebTestCase
77 77
     $this->crawler = $this->client->request('GET', $this->generateUrl('fos_user_security_logout'));
78 78
   }
79 79
   
80
-  protected function validate_registrate_user_form($form, $username, $email, $pass1, $pass2)
80
+  protected function validate_registrate_user_form($form, $username, $email, $pass1, $pass2, $token)
81 81
   {
82 82
     $form['fos_user_registration_form[username]'] = $username;
83 83
     $form['fos_user_registration_form[email]'] = $email;
84 84
     $form['fos_user_registration_form[plainPassword][first]'] = $pass1;
85 85
     // Un des mots de passe est incorrect
86 86
     $form['fos_user_registration_form[plainPassword][second]'] = $pass2;
87
+    $form['fos_user_registration_form[token]'] = $token;
87 88
     $this->submit($form);
88 89
   }
89 90
   
90
-  protected function procedure_registration_success($username, $email, $pass1, $pass2)
91
+  protected function procedure_registration_success($username, $email, $pass1, $pass2, $token)
91 92
   {
92 93
     $this->crawler = $this->client->request('GET', $this->generateUrl('index'));
93 94
     $this->isResponseSuccess();
@@ -100,7 +101,8 @@ class FunctionalTest extends WebTestCase
100 101
       $username, 
101 102
       $email, 
102 103
       $pass1,
103
-      $pass2
104
+      $pass2,
105
+      $token
104 106
     );
105 107
     
106 108
     
@@ -127,7 +129,7 @@ class FunctionalTest extends WebTestCase
127 129
     }
128 130
   }
129 131
   
130
-  protected function procedure_registration_failure($username, $email, $pass1, $pass2)
132
+  protected function procedure_registration_failure($username, $email, $pass1, $pass2, $token)
131 133
   {
132 134
     $this->crawler = $this->client->request('GET', $this->generateUrl('index'));
133 135
     $this->isResponseSuccess();
@@ -140,7 +142,8 @@ class FunctionalTest extends WebTestCase
140 142
       $username, 
141 143
       $email, 
142 144
       $pass1,
143
-      $pass2
145
+      $pass2,
146
+      $token
144 147
     );
145 148
     
146 149
     $this->isResponseSuccess();