This repository was archived by the owner on Jan 31, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,12 @@ public function addHash($options)
117
117
}
118
118
119
119
foreach ($ options as $ value ) {
120
+ if (! is_string ($ value )) {
121
+ throw new Exception \InvalidArgumentException (sprintf (
122
+ 'Hash must be a string, %s received ' ,
123
+ is_object ($ value ) ? get_class ($ value ) : gettype ($ value )
124
+ ));
125
+ }
120
126
$ this ->options ['hash ' ][$ value ] = $ algorithm ;
121
127
}
122
128
Original file line number Diff line number Diff line change @@ -239,4 +239,18 @@ public function testConstructorCanAcceptAllOptionsAsDiscreteArguments()
239
239
$ options = $ r ->getValue ($ validator );
240
240
$ this ->assertSame ($ algorithm , $ options ['algorithm ' ]);
241
241
}
242
+
243
+ /**
244
+ * @dataProvider invalidHashTypes
245
+ *
246
+ * @param mixed $hash
247
+ */
248
+ public function testInvalidHashProvidedInArrayFormat ($ hash )
249
+ {
250
+ $ validator = new File \Hash ('12345 ' );
251
+
252
+ $ this ->expectException (InvalidArgumentException::class);
253
+ $ this ->expectExceptionMessage ('Hash must be a string ' );
254
+ $ validator ->addHash ([$ hash ]);
255
+ }
242
256
}
You can’t perform that action at this time.
0 commit comments