-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
/
GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php
107 lines (92 loc) · 3.42 KB
/
GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Tests\Constraints;
use Symfony\Component\Validator\Constraints\PositiveOrZero;
/**
* @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
*/
class GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest extends GreaterThanOrEqualValidatorTest
{
protected function createConstraint(array $options = null)
{
return new PositiveOrZero();
}
/**
* {@inheritdoc}
*/
public function provideValidComparisons()
{
return [
[0, 0],
[1, 0],
[2, 0],
[2.5, 0],
['0', '0'],
['333', '0'],
[null, 0],
];
}
/**
* {@inheritdoc}
*/
public function provideInvalidComparisons()
{
return [
[-1, '-1', 0, '0', 'integer'],
[-2, '-2', 0, '0', 'integer'],
[-2.5, '-2.5', 0, '0', 'integer'],
];
}
public function testThrowsConstraintExceptionIfPropertyPath()
{
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
$this->expectExceptionMessage('The "propertyPath" option of the "Symfony\Component\Validator\Constraints\PositiveOrZero" constraint cannot be set.');
return new PositiveOrZero(['propertyPath' => 'field']);
}
public function testThrowsConstraintExceptionIfValue()
{
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
$this->expectExceptionMessage('The "value" option of the "Symfony\Component\Validator\Constraints\PositiveOrZero" constraint cannot be set.');
return new PositiveOrZero(['value' => 0]);
}
/**
* @dataProvider provideInvalidConstraintOptions
*/
public function testThrowsConstraintExceptionIfNoValueOrPropertyPath($options)
{
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
$this->expectExceptionMessage('requires either the "value" or "propertyPath" option to be set.');
$this->markTestSkipped('Value option always set for PositiveOrZero constraint');
}
public function testThrowsConstraintExceptionIfBothValueAndPropertyPath()
{
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
$this->expectExceptionMessage('requires only one of the "value" or "propertyPath" options to be set, not both.');
$this->markTestSkipped('Value option is set for PositiveOrZero constraint automatically');
}
public function testInvalidValuePath()
{
$this->markTestSkipped('PropertyPath option is not used in PositiveOrZero constraint');
}
/**
* @dataProvider provideValidComparisonsToPropertyPath
*/
public function testValidComparisonToPropertyPath($comparedValue)
{
$this->markTestSkipped('PropertyPath option is not used in PositiveOrZero constraint');
}
/**
* @dataProvider provideValidComparisonsToPropertyPath
*/
public function testValidComparisonToPropertyPathOnArray($comparedValue)
{
$this->markTestSkipped('PropertyPath option is not used in Positive constraint');
}
}