@@ -347,4 +347,45 @@ public function testEmptyChoice()
347347 $ fpErrors = $ this ->getAllErrorsOnPage ('empty_choice/0/1 ' , null , 'form_choice_submit ' );
348348 $ this ->assertErrorsEqual ($ sfErrors , $ fpErrors , 'Choice fields have all the errors. ' );
349349 }
350+
351+ public function testPasswordField ()
352+ {
353+ $ btnId = 'form_password_field_submit ' ;
354+ // Check the valid values
355+ $ sfErrors = $ this ->getAllErrorsOnPage ('password_field/1/0 ' , null , $ btnId );
356+ $ fpErrors = $ this ->getAllErrorsOnPage ('password_field/1/1 ' , null , $ btnId );
357+ $ this ->assertErrorsEqual ($ sfErrors , $ fpErrors , 'Choice fields are valid. ' );
358+
359+ $ session = $ this ->session ;
360+ $ changeAndGetErrors = function ($ first , $ second ) use ($ session ) {
361+ $ page = $ session ->getPage ();
362+ $ submit = $ page ->findButton ('form_password_field_submit ' );
363+
364+ // Check the Length constraint
365+ $ page ->findField ('form_password_field_password_first ' )->setValue ($ first );
366+ $ page ->findField ('form_password_field_password_second ' )->setValue ($ second );
367+ $ submit ->click ();
368+ $ errors = array ();
369+ /** @var \Behat\Mink\Element\NodeElement $item */
370+ foreach ($ page ->findAll ('css ' , 'ul.form-errors li ' ) as $ item ) {
371+ $ errors [] = $ item ->getText ();
372+ }
373+
374+ return $ errors ;
375+ };
376+
377+ $ sfErrors = array (
378+ $ this ->getAllErrorsOnPage ('password_field/0/0 ' , null , $ btnId ), // blank fields
379+ $ changeAndGetErrors ('a ' , 'a ' ), // too short
380+ $ changeAndGetErrors ('lorem ' , 'qwerty ' ), // not equal
381+ );
382+
383+ $ fpErrors = array (
384+ $ this ->getAllErrorsOnPage ('password_field/0/1 ' , null , $ btnId ), // blank fields
385+ $ changeAndGetErrors ('a ' , 'a ' ), // too short
386+ $ changeAndGetErrors ('lorem ' , 'qwerty ' ), // not equal
387+ );
388+
389+ $ this ->assertEquals ($ sfErrors , $ fpErrors , 'All the errors are correct ' );
390+ }
350391}
0 commit comments