Skip to content

Commit f615c9a

Browse files
committed
feat(php-validation): ParameterizedTest added
1 parent 24b9c66 commit f615c9a

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

tests/ParameterizedTest.php

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
require 'vendor/autoload.php';
4+
5+
use Atakde\PhpValidation\Validator;
6+
use PHPUnit\Framework\TestCase;
7+
8+
final class ParameterizedTest extends TestCase
9+
{
10+
protected $validator;
11+
12+
protected function setUp()
13+
{
14+
$this->validator = new Validator;
15+
}
16+
17+
/**
18+
* @dataProvider provider
19+
*/
20+
public function testAdd($params, $rules)
21+
{
22+
$this->validator->validate(['myInput' => 'string'], ['myInput' => 'my string']); // giving a string value
23+
$this->assertTrue($this->validator->passes());
24+
}
25+
26+
public function provider()
27+
{
28+
return [
29+
[['myInput' => 'required|string'], ['myInput' => 'my string']],
30+
[['myInput' => 'required|numeric'], ['myInput' => '123']],
31+
[['myInput' => 'required|email'], ['myInput' => '[email protected]']]
32+
];
33+
}
34+
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)