@@ -90,98 +90,111 @@ protected function setUp()
90
90
->getMock ();
91
91
}
92
92
93
- /***
94
- * Test isPersistent() when the session has id and enable persistent
95
- */
96
- public function testIsPersistentWhenSessionId ()
97
- {
98
- $ this ->session ->expects ($ this ->any ())->method ('getId ' )
99
- ->willReturn (1 );
100
- $ this ->helper ->expects ($ this ->any ())->method ('getSession ' )
101
- ->willReturn ($ this ->session );
102
- $ this ->dataHelper ->expects ($ this ->any ())->method ('isEnabled ' )
103
- ->willReturn (true );
104
-
105
- $ this ->assertEquals (true , $ this ->helper ->isPersistent ());
106
- }
107
-
108
- /***
109
- * Test isPersistent() when the no session id and enable persistent
93
+ /**
94
+ * Test isPersistent() function
95
+ *
96
+ * @param int|null $id
97
+ * @param boolean $isEnabled
98
+ * @param boolean $expected
99
+ * @dataProvider isPersistentDataProvider
110
100
*/
111
- public function testIsPersistentWhenNoSessionId ( )
101
+ public function testIsPersistent ( $ id , $ isEnabled , $ expected )
112
102
{
113
103
$ this ->session ->expects ($ this ->any ())->method ('getId ' )
114
- ->willReturn (null );
104
+ ->willReturn ($ id );
115
105
$ this ->helper ->expects ($ this ->any ())->method ('getSession ' )
116
106
->willReturn ($ this ->session );
117
107
$ this ->dataHelper ->expects ($ this ->any ())->method ('isEnabled ' )
118
- ->willReturn (true );
108
+ ->willReturn ($ isEnabled );
119
109
120
- $ this ->assertEquals (false , $ this ->helper ->isPersistent ());
110
+ $ this ->assertEquals ($ expected , $ this ->helper ->isPersistent ());
121
111
}
122
112
123
113
/**
124
- * Test isRememberMeChecked() when enable all config
114
+ * Data Provider for test isPersistent()
115
+ *
116
+ * @return array
125
117
*/
126
- public function testIsRememberMeCheckedWhenEnabledAll ()
118
+ public function isPersistentDataProvider ()
127
119
{
128
- $ testCase = [
129
- 'dataset ' => [
130
- ' enabled ' => true ,
131
- ' remember_me_enabled ' => true ,
132
- ' remember_me_checked_default ' => true
120
+ return [
121
+ 'session_id_and_enable_persistent ' => [
122
+ 1 ,
123
+ true ,
124
+ true
133
125
],
134
- 'expected ' => true
126
+ 'no_session_id_and_enable_persistent ' => [
127
+ null ,
128
+ true ,
129
+ false
130
+ ]
135
131
];
136
- $ this ->executeTestIsRememberMeChecked ($ testCase );
137
132
}
138
133
139
134
/**
140
- * Test isRememberMeChecked() when config persistent is disabled
135
+ * Test isRememberMeChecked() function
136
+ *
137
+ * @param boolean|null $checked
138
+ * @param boolean $isEnabled
139
+ * @param boolean $isRememberMeEnabled
140
+ * @param boolean $isRememberMeCheckedDefault
141
+ * @param boolean $expected
142
+ * @dataProvider isRememberMeCheckedProvider
141
143
*/
142
- public function testIsRememberMeCheckedWhenAtLeastOnceDisabled ()
143
- {
144
- $ testCase = [
145
- 'dataset ' => [
146
- 'enabled ' => false ,
147
- 'remember_me_enabled ' => true ,
148
- 'remember_me_checked_default ' => true
149
- ],
150
- 'expected ' => false
151
- ];
152
- $ this ->executeTestIsRememberMeChecked ($ testCase );
153
- }
144
+ public function testIsRememberMeChecked (
145
+ $ checked ,
146
+ $ isEnabled ,
147
+ $ isRememberMeEnabled ,
148
+ $ isRememberMeCheckedDefault ,
149
+ $ expected
150
+ ) {
151
+ $ this ->helper ->setRememberMeChecked ($ checked );
152
+ $ this ->dataHelper ->expects ($ this ->any ())->method ('isEnabled ' )
153
+ ->willReturn ($ isEnabled );
154
+ $ this ->dataHelper ->expects ($ this ->any ())->method ('isRememberMeEnabled ' )
155
+ ->willReturn ($ isRememberMeEnabled );
156
+ $ this ->dataHelper ->expects ($ this ->any ())->method ('isRememberMeCheckedDefault ' )
157
+ ->willReturn ($ isRememberMeCheckedDefault );
154
158
155
- /**
156
- * Test isRememberMeChecked() when setRememberMeChecked(false)
157
- */
158
- public function testIsRememberMeCheckedWhenSetValue ()
159
- {
160
- $ testCase = [
161
- 'dataset ' => [
162
- 'enabled ' => true ,
163
- 'remember_me_enabled ' => true ,
164
- 'remember_me_checked_default ' => true
165
- ],
166
- 'expected ' => false
167
- ];
168
- $ this ->helper ->setRememberMeChecked (false );
169
- $ this ->executeTestIsRememberMeChecked ($ testCase );
159
+ $ this ->assertEquals ($ expected , $ this ->helper ->isRememberMeChecked ());
170
160
}
171
161
172
162
/**
173
- * Execute test isRememberMeChecked() function
163
+ * Data Provider for test isRememberMeChecked()
174
164
*
175
- * @param array $testCase
165
+ * @return array
176
166
*/
177
- public function executeTestIsRememberMeChecked ( $ testCase )
167
+ public function isRememberMeCheckedProvider ( )
178
168
{
179
- $ this ->dataHelper ->expects ($ this ->any ())->method ('isEnabled ' )
180
- ->willReturn ($ testCase ['dataset ' ]['enabled ' ]);
181
- $ this ->dataHelper ->expects ($ this ->any ())->method ('isRememberMeEnabled ' )
182
- ->willReturn ($ testCase ['dataset ' ]['remember_me_enabled ' ]);
183
- $ this ->dataHelper ->expects ($ this ->any ())->method ('isRememberMeCheckedDefault ' )
184
- ->willReturn ($ testCase ['dataset ' ]['remember_me_checked_default ' ]);
185
- $ this ->assertEquals ($ testCase ['expected ' ], $ this ->helper ->isRememberMeChecked ());
169
+ return [
170
+ 'enable_all_config ' => [
171
+ null ,
172
+ true ,
173
+ true ,
174
+ true ,
175
+ true
176
+ ],
177
+ 'at_least_once_disabled ' => [
178
+ null ,
179
+ false ,
180
+ true ,
181
+ true ,
182
+ false
183
+ ],
184
+ 'set_remember_me_checked_false ' => [
185
+ false ,
186
+ true ,
187
+ true ,
188
+ true ,
189
+ false
190
+ ],
191
+ 'set_remember_me_checked_true ' => [
192
+ true ,
193
+ false ,
194
+ true ,
195
+ true ,
196
+ true
197
+ ]
198
+ ];
186
199
}
187
200
}
0 commit comments