@@ -290,20 +290,26 @@ public static function providePermitEmpty(): iterable
290
290
}
291
291
292
292
/**
293
- * @dataProvider provideMatchesCases
293
+ * @dataProvider provideMatches
294
294
*/
295
295
public function testMatches (array $ data , bool $ expected ): void
296
296
{
297
297
$ this ->validation ->setRules (['foo ' => 'matches[bar] ' ]);
298
298
$ this ->assertSame ($ expected , $ this ->validation ->run ($ data ));
299
299
}
300
300
301
- public static function provideMatchesCases (): iterable
301
+ public static function provideMatches (): iterable
302
302
{
303
303
yield from [
304
- [['foo ' => null , 'bar ' => null ], true ],
305
- [['foo ' => 'match ' , 'bar ' => 'match ' ], true ],
306
- [['foo ' => 'match ' , 'bar ' => 'nope ' ], false ],
304
+ 'foo bar not exist ' => [[], false ],
305
+ 'bar not exist ' => [['foo ' => null ], false ],
306
+ 'foo not exist ' => [['bar ' => null ], true ], // should be false?
307
+ 'foo bar null ' => [['foo ' => null , 'bar ' => null ], true ],
308
+ 'foo bar string match ' => [['foo ' => 'match ' , 'bar ' => 'match ' ], true ],
309
+ 'foo bar string not match ' => [['foo ' => 'match ' , 'bar ' => 'nope ' ], false ],
310
+ 'foo bar float match ' => [['foo ' => 1.2 , 'bar ' => 1.2 ], false ], // should be true
311
+ 'foo bar float not match ' => [['foo ' => 1.2 , 'bar ' => 2.3 ], false ],
312
+ 'foo bar bool match ' => [['foo ' => true , 'bar ' => true ], false ], // should be true
307
313
];
308
314
}
309
315
@@ -325,12 +331,27 @@ public static function provideMatchesNestedCases(): iterable
325
331
}
326
332
327
333
/**
328
- * @dataProvider provideMatchesCases
334
+ * @dataProvider provideDiffers
329
335
*/
330
336
public function testDiffers (array $ data , bool $ expected ): void
331
337
{
332
338
$ this ->validation ->setRules (['foo ' => 'differs[bar] ' ]);
333
- $ this ->assertSame (! $ expected , $ this ->validation ->run ($ data ));
339
+ $ this ->assertSame ($ expected , $ this ->validation ->run ($ data ));
340
+ }
341
+
342
+ public static function provideDiffers (): iterable
343
+ {
344
+ yield from [
345
+ 'foo bar not exist ' => [[], false ],
346
+ 'bar not exist ' => [['foo ' => null ], false ],
347
+ 'foo not exist ' => [['bar ' => null ], false ],
348
+ 'foo bar null ' => [['foo ' => null , 'bar ' => null ], false ],
349
+ 'foo bar string match ' => [['foo ' => 'match ' , 'bar ' => 'match ' ], false ],
350
+ 'foo bar string not match ' => [['foo ' => 'match ' , 'bar ' => 'nope ' ], true ],
351
+ 'foo bar float match ' => [['foo ' => 1.2 , 'bar ' => 1.2 ], true ], // should be false
352
+ 'foo bar float not match ' => [['foo ' => 1.2 , 'bar ' => 2.3 ], true ],
353
+ 'foo bar bool match ' => [['foo ' => true , 'bar ' => true ], true ], // should be false
354
+ ];
334
355
}
335
356
336
357
/**
0 commit comments