@@ -34,21 +34,21 @@ protected function setUp(): void
34
34
$ this ->validator ->initialize ($ this ->context );
35
35
}
36
36
37
- public function testValidateWithWrongConstraint ()
37
+ public function testValidateWithWrongConstraint (): void
38
38
{
39
39
$ this ->expectException (\LogicException::class);
40
40
$ this ->validator ->validate ('foo ' , new NotNull ());
41
41
}
42
42
43
- public function testValidateWithNoEntity ()
43
+ public function testValidateWithNoEntity (): void
44
44
{
45
45
$ constraint = new EntityExist ();
46
46
47
47
$ this ->expectException (\LogicException::class);
48
48
$ this ->validator ->validate ('foobar ' , $ constraint );
49
49
}
50
50
51
- public function testValidateValidEntity ()
51
+ public function testValidateValidEntity (): void
52
52
{
53
53
$ this ->context ->expects ($ this ->never ())->method ('buildViolation ' );
54
54
$ constraint = new EntityExist ();
@@ -57,6 +57,7 @@ public function testValidateValidEntity()
57
57
$ repository = $ this ->getMockBuilder (EntityRepository::class)
58
58
->disableOriginalConstructor ()
59
59
->getMock ();
60
+
60
61
$ repository
61
62
->expects ($ this ->once ())
62
63
->method ('findOneBy ' )
@@ -75,7 +76,7 @@ public function testValidateValidEntity()
75
76
/**
76
77
* @dataProvider getEmptyOrNull
77
78
*/
78
- public function testValidateSkipsIfValueEmptyOrNull ($ value )
79
+ public function testValidateSkipsIfValueEmptyOrNull ($ value ): void
79
80
{
80
81
$ this ->context ->expects ($ this ->never ())->method ('buildViolation ' );
81
82
$ constraint = new EntityExist ();
@@ -84,6 +85,7 @@ public function testValidateSkipsIfValueEmptyOrNull($value)
84
85
$ repository = $ this ->getMockBuilder (EntityRepository::class)
85
86
->disableOriginalConstructor ()
86
87
->getMock ();
88
+
87
89
$ repository
88
90
->expects ($ this ->exactly (0 ))
89
91
->method ('findOneBy ' )
@@ -99,13 +101,13 @@ public function testValidateSkipsIfValueEmptyOrNull($value)
99
101
$ this ->validator ->validate ($ value , $ constraint );
100
102
}
101
103
102
- public function getEmptyOrNull ()
104
+ public function getEmptyOrNull (): \ Generator
103
105
{
104
106
yield ['' ];
105
107
yield [null ];
106
108
}
107
109
108
- public function testValidateValidEntityWithCustomProperty ()
110
+ public function testValidateValidEntityWithCustomProperty (): void
109
111
{
110
112
$ this ->context ->expects ($ this ->never ())->method ('buildViolation ' );
111
113
$ constraint = new EntityExist ();
@@ -115,6 +117,7 @@ public function testValidateValidEntityWithCustomProperty()
115
117
$ repository = $ this ->getMockBuilder (EntityRepository::class)
116
118
->disableOriginalConstructor ()
117
119
->getMock ();
120
+
118
121
$ repository
119
122
->expects ($ this ->once ())
120
123
->method ('findOneBy ' )
@@ -130,7 +133,7 @@ public function testValidateValidEntityWithCustomProperty()
130
133
$ this ->validator ->validate ('foobar ' , $ constraint );
131
134
}
132
135
133
- public function testValidateInvalidEntity ()
136
+ public function testValidateInvalidEntity (): void
134
137
{
135
138
$ violationBuilder = $ this ->getMockBuilder (ConstraintViolationBuilderInterface::class)->getMock ();
136
139
$ violationBuilder ->method ('setParameter ' )->will ($ this ->returnSelf ());
@@ -142,6 +145,7 @@ public function testValidateInvalidEntity()
142
145
$ repository = $ this ->getMockBuilder (EntityRepository::class)
143
146
->disableOriginalConstructor ()
144
147
->getMock ();
148
+
145
149
$ repository
146
150
->expects ($ this ->once ())
147
151
->method ('findOneBy ' )
@@ -152,6 +156,6 @@ public function testValidateInvalidEntity()
152
156
->method ('getRepository ' )
153
157
->willReturn ($ repository );
154
158
155
- $ this ->validator ->validate (' foobar ' , $ constraint );
159
+ $ this ->validator ->validate (1 , $ constraint );
156
160
}
157
161
}
0 commit comments