@@ -880,100 +880,6 @@ public function testValidationStopsAtFailedPresenceCheck()
880
880
$ this ->assertEquals (['validation.present ' ], $ v ->errors ()->get ('name ' ));
881
881
}
882
882
883
- public function testValidatePassword ()
884
- {
885
- // Fails when user is not logged in.
886
- $ auth = m::mock (Guard::class);
887
- $ auth ->shouldReceive ('guard ' )->andReturn ($ auth );
888
- $ auth ->shouldReceive ('guest ' )->andReturn (true );
889
-
890
- $ hasher = m::mock (Hasher::class);
891
-
892
- $ container = m::mock (Container::class);
893
- $ container ->shouldReceive ('make ' )->with ('auth ' )->andReturn ($ auth );
894
- $ container ->shouldReceive ('make ' )->with ('hash ' )->andReturn ($ hasher );
895
-
896
- $ trans = $ this ->getTranslator ();
897
- $ trans ->shouldReceive ('get ' )->andReturnArg (0 );
898
-
899
- $ v = new Validator ($ trans , ['password ' => 'foo ' ], ['password ' => 'password ' ]);
900
- $ v ->setContainer ($ container );
901
-
902
- $ this ->assertFalse ($ v ->passes ());
903
-
904
- // Fails when password is incorrect.
905
- $ user = m::mock (Authenticatable::class);
906
- $ user ->shouldReceive ('getAuthPassword ' );
907
-
908
- $ auth = m::mock (Guard::class);
909
- $ auth ->shouldReceive ('guard ' )->andReturn ($ auth );
910
- $ auth ->shouldReceive ('guest ' )->andReturn (false );
911
- $ auth ->shouldReceive ('user ' )->andReturn ($ user );
912
-
913
- $ hasher = m::mock (Hasher::class);
914
- $ hasher ->shouldReceive ('check ' )->andReturn (false );
915
-
916
- $ container = m::mock (Container::class);
917
- $ container ->shouldReceive ('make ' )->with ('auth ' )->andReturn ($ auth );
918
- $ container ->shouldReceive ('make ' )->with ('hash ' )->andReturn ($ hasher );
919
-
920
- $ trans = $ this ->getTranslator ();
921
- $ trans ->shouldReceive ('get ' )->andReturnArg (0 );
922
-
923
- $ v = new Validator ($ trans , ['password ' => 'foo ' ], ['password ' => 'password ' ]);
924
- $ v ->setContainer ($ container );
925
-
926
- $ this ->assertFalse ($ v ->passes ());
927
-
928
- // Succeeds when password is correct.
929
- $ user = m::mock (Authenticatable::class);
930
- $ user ->shouldReceive ('getAuthPassword ' );
931
-
932
- $ auth = m::mock (Guard::class);
933
- $ auth ->shouldReceive ('guard ' )->andReturn ($ auth );
934
- $ auth ->shouldReceive ('guest ' )->andReturn (false );
935
- $ auth ->shouldReceive ('user ' )->andReturn ($ user );
936
-
937
- $ hasher = m::mock (Hasher::class);
938
- $ hasher ->shouldReceive ('check ' )->andReturn (true );
939
-
940
- $ container = m::mock (Container::class);
941
- $ container ->shouldReceive ('make ' )->with ('auth ' )->andReturn ($ auth );
942
- $ container ->shouldReceive ('make ' )->with ('hash ' )->andReturn ($ hasher );
943
-
944
- $ trans = $ this ->getTranslator ();
945
- $ trans ->shouldReceive ('get ' )->andReturnArg (0 );
946
-
947
- $ v = new Validator ($ trans , ['password ' => 'foo ' ], ['password ' => 'password ' ]);
948
- $ v ->setContainer ($ container );
949
-
950
- $ this ->assertTrue ($ v ->passes ());
951
-
952
- // We can use a specific guard.
953
- $ user = m::mock (Authenticatable::class);
954
- $ user ->shouldReceive ('getAuthPassword ' );
955
-
956
- $ auth = m::mock (Guard::class);
957
- $ auth ->shouldReceive ('guard ' )->with ('custom ' )->andReturn ($ auth );
958
- $ auth ->shouldReceive ('guest ' )->andReturn (false );
959
- $ auth ->shouldReceive ('user ' )->andReturn ($ user );
960
-
961
- $ hasher = m::mock (Hasher::class);
962
- $ hasher ->shouldReceive ('check ' )->andReturn (true );
963
-
964
- $ container = m::mock (Container::class);
965
- $ container ->shouldReceive ('make ' )->with ('auth ' )->andReturn ($ auth );
966
- $ container ->shouldReceive ('make ' )->with ('hash ' )->andReturn ($ hasher );
967
-
968
- $ trans = $ this ->getTranslator ();
969
- $ trans ->shouldReceive ('get ' )->andReturnArg (0 );
970
-
971
- $ v = new Validator ($ trans , ['password ' => 'foo ' ], ['password ' => 'password:custom ' ]);
972
- $ v ->setContainer ($ container );
973
-
974
- $ this ->assertTrue ($ v ->passes ());
975
- }
976
-
977
883
public function testValidatePresent ()
978
884
{
979
885
$ trans = $ this ->getIlluminateArrayTranslator ();
0 commit comments