Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5856f27

Browse files
committed
Improve tests
1 parent 78f2c7c commit 5856f27

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,32 +99,29 @@ public function testEmptyArrayIsInvalid()
9999
->assertRaised();
100100
}
101101

102-
/**
103-
* @dataProvider provideAllowNull
104-
*/
105-
public function testAllowNull(bool $allowNull)
102+
public function testAllowNullTrue()
106103
{
107-
$constraint = new NotBlank(array(
104+
$constraint = new NotBlank([
108105
'message' => 'myMessage',
109-
'allowNull' => $allowNull,
110-
));
106+
'allowNull' => true,
107+
]);
111108

112109
$this->validator->validate(null, $constraint);
110+
$this->assertNoViolation();
111+
}
113112

114-
if ($allowNull) {
115-
$this->assertNoViolation();
113+
public function testAllowNullFalse()
114+
{
115+
$constraint = new NotBlank([
116+
'message' => 'myMessage',
117+
'allowNull' => false,
118+
]);
116119

117-
return;
118-
}
120+
$this->validator->validate(null, $constraint);
119121

120122
$this->buildViolation('myMessage')
121123
->setParameter('{{ value }}', 'null')
122124
->setCode(NotBlank::IS_BLANK_ERROR)
123125
->assertRaised();
124126
}
125-
126-
public function provideAllowNull(): array
127-
{
128-
return array(array(true), array(false));
129-
}
130127
}

0 commit comments

Comments
 (0)