@@ -25,11 +25,11 @@ function recoverpasswordAction()
25
25
{
26
26
throw new Zend_Exception ('Shouldn \'t be logged in ' );
27
27
}
28
- $ this ->_helper -> layout -> disableLayout ();
28
+ $ this ->disableLayout ();
29
29
$ email = $ this ->_getParam ('email ' );
30
30
if (isset ($ email ))
31
31
{
32
- $ this ->_helper -> viewRenderer -> setNoRender ();
32
+ $ this ->disableView ();
33
33
$ user = $ this ->User ->getByEmail ($ email );
34
34
35
35
// Check ifthe email is already registered
@@ -76,7 +76,7 @@ function make_seed_recoverpass()
76
76
$ text .= "Your new password is: " .$ pass ."<br> " ;
77
77
$ text .= "<br><br>Generated by MIDAS " ;
78
78
79
- if (mail ("$ email " , "MIDAS: Password request " , "$ text " , "From: \nReply-To: no-reply \nX-Mailer: PHP/ " . phpversion ()."\nMIME-Version: 1.0 \nContent-type: text/html; charset = iso-8859-1 " ))
79
+ if ($ this -> isTestingEnv () || mail ("$ email " , "MIDAS: Password request " , "$ text " , "From: \nReply-To: no-reply \nX-Mailer: PHP/ " . phpversion ()."\nMIME-Version: 1.0 \nContent-type: text/html; charset = iso-8859-1 " ))
80
80
{
81
81
$ this ->User ->save ($ user );
82
82
echo JsonComponent::encode (array (true , $ this ->t ('An Email has been sent to ' ).' ' .$ email ));
@@ -115,7 +115,7 @@ function registerAction()
115
115
$ this ->_redirect ("/ " );
116
116
}
117
117
$ this ->view ->form = $ this ->getFormAsArray ($ form );
118
- $ this ->_helper -> layout -> disableLayout ();
118
+ $ this ->disableLayout ();
119
119
$ this ->view ->jsonRegister = JsonComponent::encode (array (
120
120
'MessageNotValid ' => $ this ->t ('The e-mail is not valid ' ), 'MessageNotAvailable ' => $ this ->t ('This e-mail is not available ' ), 'MessagePassword ' => $ this ->t ('Password too short ' ), 'MessagePasswords ' => $ this ->t ('The passwords are not the same ' ), 'MessageLastname ' => $ this ->t ('Please set your lastname ' ), 'MessageTerms ' => $ this ->t ('Please validate the terms of service ' ), 'MessageFirstname ' => $ this ->t ('Please set your firstname ' )
121
121
));
@@ -128,7 +128,7 @@ function loginAction()
128
128
$ this ->Form ->User ->uri = $ this ->getRequest ()->getRequestUri ();
129
129
$ form = $ this ->Form ->User ->createLoginForm ();
130
130
$ this ->view ->form = $ this ->getFormAsArray ($ form );
131
- $ this ->_helper -> layout -> disableLayout ();
131
+ $ this ->disableLayout ();
132
132
if ($ this ->_request ->isPost ())
133
133
{
134
134
$ this ->_helper ->viewRenderer ->setNoRender ();
@@ -152,14 +152,21 @@ function loginAction()
152
152
$ passwordPrefix = Zend_Registry::get ('configGlobal ' )->password ->prefix ;
153
153
if ($ authLdap || $ userDao != false && md5 ($ passwordPrefix .$ form ->getValue ('password ' )) == $ userDao ->getPassword ())
154
154
{
155
+
155
156
$ remember = $ form ->getValue ('remerberMe ' );
156
157
if (isset ($ remember ) && $ remember == 1 )
157
158
{
158
- setcookie ('midasUtil ' , $ userDao ->getKey ().'- ' .md5 ($ userDao ->getPassword ()), time () + 60 * 60 * 24 * 30 , '/ ' ); //30 days
159
+ if (!$ this ->isTestingEnv ())
160
+ {
161
+ setcookie ('midasUtil ' , $ userDao ->getKey ().'- ' .md5 ($ userDao ->getPassword ()), time () + 60 * 60 * 24 * 30 , '/ ' ); //30 days
162
+ }
159
163
}
160
164
else
161
165
{
162
- setcookie ('midasUtil ' , null , time () + 60 * 60 * 24 * 30 , '/ ' ); //30 days
166
+ if (!$ this ->isTestingEnv ())
167
+ {
168
+ setcookie ('midasUtil ' , null , time () + 60 * 60 * 24 * 30 , '/ ' ); //30 days
169
+ }
163
170
}
164
171
Zend_Session::start ();
165
172
$ user = new Zend_Session_Namespace ('Auth_User ' );
@@ -168,6 +175,12 @@ function loginAction()
168
175
$ url = $ form ->getValue ('url ' );
169
176
$ user ->lock ();
170
177
$ this ->getLogger ()->info (__METHOD__ . " Log in : " . $ userDao ->getFullName ());
178
+ if ($ this ->isTestingEnv ())
179
+ {
180
+ echo 'Test Pass ' ;
181
+ $ this ->disableView ();
182
+ return ;
183
+ }
171
184
}
172
185
}
173
186
@@ -196,13 +209,13 @@ public function termofserviceAction()
196
209
/** valid entries (ajax)*/
197
210
public function validentryAction ()
198
211
{
199
- if (!$ this ->getRequest ()->isXmlHttpRequest ())
212
+ if (!$ this ->getRequest ()->isXmlHttpRequest () && ! $ this -> isTestingEnv () )
200
213
{
201
214
throw new Zend_Exception ("Why are you here? Should be ajax. " );
202
215
}
203
216
204
- $ this ->_helper -> layout -> disableLayout ();
205
- $ this ->_helper -> viewRenderer -> setNoRender ();
217
+ $ this ->disableLayout ();
218
+ $ this ->disableView ();
206
219
$ entry = $ this ->_getParam ("entry " );
207
220
$ type = $ this ->_getParam ("type " );
208
221
if (!is_string ($ entry ) || !is_string ($ type ))
@@ -255,10 +268,10 @@ public function settingsAction()
255
268
{
256
269
if (!$ this ->logged )
257
270
{
258
- $ this ->_helper -> viewRenderer -> setNoRender ();
271
+ $ this ->disableView ();
259
272
return false ;
260
273
}
261
- $ this ->_helper -> layout -> disableLayout ();
274
+ $ this ->disableLayout ();
262
275
263
276
$ userId = $ this ->_getParam ('userId ' );
264
277
if (isset ($ userId ) && $ userId != $ this ->userSession ->Dao ->getKey () && !$ this ->userSession ->Dao ->isAdmin ())
@@ -345,10 +358,21 @@ public function settingsAction()
345
358
}
346
359
if (isset ($ modifyPicture ) && $ this ->logged )
347
360
{
348
- $ upload = new Zend_File_Transfer ();
349
- $ upload ->receive ();
350
- $ path = $ upload ->getFileName ();
351
- if (!empty ($ path ) && file_exists ($ path ) && $ upload ->getFileSize () > 0 )
361
+ if ($ this ->isTestingEnv ())
362
+ {
363
+ //simulate file upload
364
+ $ path = BASE_PATH .'/tests/testfiles/search.png ' ;
365
+ $ size = filesize ($ path );
366
+ }
367
+ else
368
+ {
369
+ $ upload = new Zend_File_Transfer ();
370
+ $ upload ->receive ();
371
+ $ path = $ upload ->getFileName ();
372
+ $ size = $ upload ->getFileSize ();
373
+ }
374
+
375
+ if (!empty ($ path ) && file_exists ($ path ) && $ size > 0 )
352
376
{
353
377
//create thumbnail
354
378
$ thumbnailCreator = $ this ->Component ->Filter ->getFilter ('ThumbnailCreator ' );
0 commit comments