@@ -16,7 +16,7 @@ final class PasswordHashEndToEndTest extends TestCase {
16
16
* Test using the stronger but system-specific hashes, with a possible fallback to
17
17
* the weaker portable hashes.
18
18
*
19
- * @dataProvider dataSets
19
+ * @dataProvider dataSetsSuccess
20
20
*
21
21
* @param string $input The text to hash and compare with.
22
22
*
@@ -33,7 +33,7 @@ public function testStrongerSystemSpecificHashSuccess($input) {
33
33
* Test using the stronger but system-specific hashes, with a possible fallback to
34
34
* the weaker portable hashes.
35
35
*
36
- * @dataProvider dataSets
36
+ * @dataProvider dataSetsFail
37
37
*
38
38
* @param string $input The text to hash.
39
39
* @param string $compare The text to compare the hash with.
@@ -50,7 +50,7 @@ public function testStrongerSystemSpecificHashFail($input, $compare) {
50
50
/**
51
51
* Test using the weaker portable hashes.
52
52
*
53
- * @dataProvider dataSets
53
+ * @dataProvider dataSetsSuccess
54
54
*
55
55
* @param string $input The text to hash and compare with.
56
56
*
@@ -67,7 +67,7 @@ public function testWeakerPortableHashSuccess($input) {
67
67
/**
68
68
* Test using the weaker portable hashes.
69
69
*
70
- * @dataProvider dataSets
70
+ * @dataProvider dataSetsFail
71
71
*
72
72
* @param string $input The text to hash.
73
73
* @param string $compare The text to compare the hash with.
@@ -87,6 +87,30 @@ public function testWeakerPortableHashFail($input, $compare) {
87
87
*
88
88
* @return array
89
89
*/
90
+ public static function dataSetsSuccess () {
91
+ $ data = self ::dataSets ();
92
+ foreach ($ data as $ key => $ value ) {
93
+ // The `compare` parameter is only needed for the "fail" tests.
94
+ unset($ data [$ key ]['compare ' ]);
95
+ }
96
+
97
+ return $ data ;
98
+ }
99
+
100
+ /**
101
+ * Data provider.
102
+ *
103
+ * @return array
104
+ */
105
+ public static function dataSetsFail () {
106
+ return self ::dataSets ();
107
+ }
108
+
109
+ /**
110
+ * Data provider helper.
111
+ *
112
+ * @return array
113
+ */
90
114
public static function dataSets () {
91
115
return array (
92
116
'initial test case ' => array (
@@ -99,7 +123,7 @@ public static function dataSets() {
99
123
/**
100
124
* Test the generated hash is correctly calculated using the weaker portable hashes.
101
125
*
102
- * @dataProvider dataGeneratedHash
126
+ * @dataProvider dataGeneratedHashSuccess
103
127
*
104
128
* @param string $expected_hash The expected password hash output.
105
129
* @param string $input The text to hash and compare with.
@@ -112,10 +136,25 @@ public function testGeneratedHashSuccess($expected_hash, $input) {
112
136
$ this ->assertTrue ($ t_hasher ->CheckPassword ($ input , $ expected_hash ));
113
137
}
114
138
139
+ /**
140
+ * Data provider.
141
+ *
142
+ * @return array
143
+ */
144
+ public static function dataGeneratedHashSuccess () {
145
+ $ data = self ::dataGeneratedHash ();
146
+ foreach ($ data as $ key => $ value ) {
147
+ // The `compare` parameter is only needed for the "fail" tests.
148
+ unset($ data [$ key ]['compare ' ]);
149
+ }
150
+
151
+ return $ data ;
152
+ }
153
+
115
154
/**
116
155
* Test the generated hash is correctly calculated using the weaker portable hashes.
117
156
*
118
- * @dataProvider dataGeneratedHash
157
+ * @dataProvider dataGeneratedHashFail
119
158
*
120
159
* @param string $expected_hash The expected password hash output.
121
160
* @param string $input Unused.
@@ -134,6 +173,15 @@ public function testGeneratedHashFail($expected_hash, $input, $compare) {
134
173
*
135
174
* @return array
136
175
*/
176
+ public static function dataGeneratedHashFail () {
177
+ return self ::dataGeneratedHash ();
178
+ }
179
+
180
+ /**
181
+ * Data provider helper.
182
+ *
183
+ * @return array
184
+ */
137
185
public static function dataGeneratedHash () {
138
186
return array (
139
187
'initial test case ' => array (
0 commit comments