@@ -851,15 +851,11 @@ public function seeNumRecords(int $expectedNum, string $className, array $criter
851
851
public function logout ()
852
852
{
853
853
$ container = $ this ->_getContainer ();
854
-
855
854
if ($ container ->has ('security.token_storage ' )) {
856
855
$ tokenStorage = $ this ->grabService ('security.token_storage ' );
857
856
$ tokenStorage ->setToken (null );
858
857
}
859
858
860
- if (!$ container ->has ('session ' )) {
861
- $ this ->fail ("Symfony container doesn't have 'session' service " );
862
- }
863
859
$ session = $ this ->grabService ('session ' );
864
860
865
861
$ sessionName = $ session ->getName ();
@@ -893,12 +889,6 @@ public function logout()
893
889
*/
894
890
public function seeInSession (string $ attrib , $ value = null )
895
891
{
896
- $ container = $ this ->_getContainer ();
897
-
898
- if (!$ container ->has ('session ' )) {
899
- $ this ->fail ("Symfony container doesn't have 'session' service " );
900
- }
901
-
902
892
$ session = $ this ->grabService ('session ' );
903
893
904
894
if (!$ session ->has ($ attrib )) {
@@ -925,12 +915,6 @@ public function seeInSession(string $attrib, $value = null)
925
915
*/
926
916
public function amOnAction (string $ action , array $ params = [])
927
917
{
928
- $ container = $ this ->_getContainer ();
929
-
930
- if (!$ container ->has ('router ' )) {
931
- $ this ->fail ("Symfony container doesn't have 'router' service " );
932
- }
933
-
934
918
$ router = $ this ->grabService ('router ' );
935
919
936
920
$ routes = $ router ->getRouteCollection ()->getIterator ();
@@ -964,12 +948,6 @@ public function amOnAction(string $action, array $params = [])
964
948
*/
965
949
public function seeAuthentication (bool $ remembered = false )
966
950
{
967
- $ container = $ this ->_getContainer ();
968
-
969
- if (!$ container ->has ('security.helper ' )) {
970
- $ this ->fail ("Symfony container doesn't have 'security.helper' service " );
971
- }
972
-
973
951
$ security = $ this ->grabService ('security.helper ' );
974
952
975
953
$ user = $ security ->getUser ();
@@ -1026,12 +1004,6 @@ public function submitSymfonyForm(string $name, array $fields)
1026
1004
*/
1027
1005
public function seeUserHasRole (string $ role )
1028
1006
{
1029
- $ container = $ this ->_getContainer ();
1030
-
1031
- if (!$ container ->has ('security.helper ' )) {
1032
- $ this ->fail ("Symfony container doesn't have 'security.helper' service " );
1033
- }
1034
-
1035
1007
$ security = $ this ->grabService ('security.helper ' );
1036
1008
1037
1009
$ user = $ security ->getUser ();
@@ -1063,12 +1035,6 @@ public function seeUserHasRole(string $role)
1063
1035
*/
1064
1036
public function dontSeeAuthentication (bool $ remembered = true )
1065
1037
{
1066
- $ container = $ this ->_getContainer ();
1067
-
1068
- if (!$ container ->has ('security.helper ' )) {
1069
- $ this ->fail ("Symfony container doesn't have 'security.helper' service " );
1070
- }
1071
-
1072
1038
$ security = $ this ->grabService ('security.helper ' );
1073
1039
1074
1040
$ role = $ remembered ? 'IS_AUTHENTICATED_REMEMBERED ' : 'IS_AUTHENTICATED_FULLY ' ;
@@ -1092,12 +1058,6 @@ public function dontSeeAuthentication(bool $remembered = true)
1092
1058
*/
1093
1059
public function grabParameter (string $ name )
1094
1060
{
1095
- $ container = $ this ->_getContainer ();
1096
-
1097
- if (!$ container ->has ('parameter_bag ' )) {
1098
- $ this ->fail ("Symfony container doesn't have 'parameter_bag' service " );
1099
- return null ;
1100
- }
1101
1061
$ parameterBag = $ this ->grabService ('parameter_bag ' );
1102
1062
return $ parameterBag ->get ($ name );
1103
1063
}
@@ -1115,12 +1075,6 @@ public function grabParameter(string $name)
1115
1075
*/
1116
1076
public function seeCurrentActionIs (string $ action )
1117
1077
{
1118
- $ container = $ this ->_getContainer ();
1119
-
1120
- if (!$ container ->has ('router ' )) {
1121
- $ this ->fail ("Symfony container doesn't have 'router' service " );
1122
- }
1123
-
1124
1078
$ router = $ this ->grabService ('router ' );
1125
1079
1126
1080
$ routes = $ router ->getRouteCollection ()->getIterator ();
@@ -1154,35 +1108,19 @@ public function seeCurrentActionIs(string $action)
1154
1108
*/
1155
1109
public function seeUserPasswordDoesNotNeedRehash (UserInterface $ user = null )
1156
1110
{
1157
- $ container = $ this ->_getContainer ();
1158
-
1159
1111
if ($ user === null ) {
1160
- if (!$ container ->has ('security.helper ' )) {
1161
- $ this ->fail ("Symfony container doesn't have 'security.helper' service " );
1162
- }
1163
-
1164
1112
$ security = $ this ->grabService ('security.helper ' );
1165
1113
if (!$ user = $ security ->getUser ()) {
1166
1114
$ this ->fail ('No user found to validate ' );
1167
1115
}
1168
1116
}
1169
-
1170
- if (!$ container ->has ('security.user_password_encoder.generic ' )) {
1171
- $ this ->fail ("Symfony container doesn't have 'security.user_password_encoder.generic' service " );
1172
- }
1173
-
1174
1117
$ encoder = $ this ->grabService ('security.user_password_encoder.generic ' );
1175
1118
1176
1119
$ this ->assertFalse ($ encoder ->needsRehash ($ user ), 'User password needs rehash ' );
1177
1120
}
1178
1121
1179
1122
public function amLoggedInAs (UserInterface $ user , string $ firewallName = 'main ' , $ firewallContext = null )
1180
1123
{
1181
- $ container = $ this ->_getContainer ();
1182
- if (!$ container ->has ('session ' )) {
1183
- $ this ->fail ("Symfony container doesn't have 'session' service " );
1184
- }
1185
-
1186
1124
$ session = $ this ->grabService ('session ' );
1187
1125
1188
1126
if ($ this ->config ['guard ' ]) {
0 commit comments