Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit 9ee1159

Browse files
AndrolGenhaldXerkus
authored andcommitted
Refactored NotEmpty constructor test to use data provider
1 parent a7466e6 commit 9ee1159

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

test/NotEmptyTest.php

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,29 @@ public function setUp()
2727
$this->validator = new NotEmpty();
2828
}
2929

30-
public function testConstructorWithTypeArray()
30+
/**
31+
* Ensures that the validator follows expected behavior
32+
*
33+
* @param array $types Array of type strings or constants
34+
* @param integer $expected Expected value of calculated type
35+
*
36+
* @return void
37+
* @dataProvider constructorWithTypeArrayProvider
38+
*/
39+
public function testConstructorWithTypeArray($types, $expected)
3140
{
32-
$validator = new NotEmpty([
33-
'php',
34-
'boolean'
35-
]);
36-
$this->assertEquals(NotEmpty::PHP, $validator->getType());
37-
38-
$validator = new NotEmpty([
39-
'boolean',
40-
'boolean'
41-
]);
42-
$this->assertEquals(NotEmpty::BOOLEAN, $validator->getType());
43-
44-
$validator = new NotEmpty([
45-
NotEmpty::PHP,
46-
NotEmpty::BOOLEAN
47-
]);
48-
$this->assertEquals(NotEmpty::PHP, $validator->getType());
41+
$validator = new NotEmpty($types);
42+
$this->assertEquals($expected, $validator->getType());
43+
}
4944

50-
$validator = new NotEmpty([
51-
NotEmpty::BOOLEAN,
52-
NotEmpty::BOOLEAN
53-
]);
54-
$this->assertEquals(NotEmpty::BOOLEAN, $validator->getType());
45+
public function constructorWithTypeArrayProvider()
46+
{
47+
return [
48+
[['php', 'boolean'], NotEmpty::PHP],
49+
[['boolean', 'boolean'], NotEmpty::BOOLEAN],
50+
[[NotEmpty::PHP, NotEmpty::BOOLEAN], NotEmpty::PHP],
51+
[[NotEmpty::BOOLEAN, NotEmpty::BOOLEAN], NotEmpty::BOOLEAN],
52+
];
5553
}
5654

5755
/**

0 commit comments

Comments
 (0)