18
18
19
19
class LengthValidatorTest extends ConstraintValidatorTestCase
20
20
{
21
- // 🧚♀️ "Woman Fairy" emoji ZWJ sequence
22
- private const SINGLE_GRAPHEME_WITH_FOUR_CODEPOINTS_AND_THIRTEEN_BYTES = "\u{1F9DA}\u{200D}\u{2640}\u{FE0F}" ;
23
-
24
21
protected function createValidator (): LengthValidator
25
22
{
26
23
return new LengthValidator ();
@@ -162,23 +159,23 @@ public function testValidNormalizedValues($value)
162
159
public function testValidGraphemesValues ()
163
160
{
164
161
$ constraint = new Length (min: 1 , max: 1 , countUnit: Length::COUNT_GRAPHEMES );
165
- $ this ->validator ->validate (self :: SINGLE_GRAPHEME_WITH_FOUR_CODEPOINTS_AND_THIRTEEN_BYTES , $ constraint );
162
+ $ this ->validator ->validate (" A \u{0300}" , $ constraint );
166
163
167
164
$ this ->assertNoViolation ();
168
165
}
169
166
170
167
public function testValidCodepointsValues ()
171
168
{
172
- $ constraint = new Length (min: 4 , max: 4 , countUnit: Length::COUNT_CODEPOINTS );
173
- $ this ->validator ->validate (self :: SINGLE_GRAPHEME_WITH_FOUR_CODEPOINTS_AND_THIRTEEN_BYTES , $ constraint );
169
+ $ constraint = new Length (min: 2 , max: 2 , countUnit: Length::COUNT_CODEPOINTS );
170
+ $ this ->validator ->validate (" A \u{0300}" , $ constraint );
174
171
175
172
$ this ->assertNoViolation ();
176
173
}
177
174
178
175
public function testValidBytesValues ()
179
176
{
180
- $ constraint = new Length (min: 13 , max: 13 , countUnit: Length::COUNT_BYTES );
181
- $ this ->validator ->validate (self :: SINGLE_GRAPHEME_WITH_FOUR_CODEPOINTS_AND_THIRTEEN_BYTES , $ constraint );
177
+ $ constraint = new Length (min: 3 , max: 3 , countUnit: Length::COUNT_BYTES );
178
+ $ this ->validator ->validate (" A \u{0300}" , $ constraint );
182
179
183
180
$ this ->assertNoViolation ();
184
181
}
@@ -353,12 +350,12 @@ public function testInvalidValuesExactDefaultCountUnitWithGraphemeInput()
353
350
{
354
351
$ constraint = new Length (min: 1 , max: 1 , exactMessage: 'myMessage ' );
355
352
356
- $ this ->validator ->validate (self :: SINGLE_GRAPHEME_WITH_FOUR_CODEPOINTS_AND_THIRTEEN_BYTES , $ constraint );
353
+ $ this ->validator ->validate (" A \u{0300}" , $ constraint );
357
354
358
355
$ this ->buildViolation ('myMessage ' )
359
- ->setParameter ('{{ value }} ' , '" ' .self :: SINGLE_GRAPHEME_WITH_FOUR_CODEPOINTS_AND_THIRTEEN_BYTES .'" ' )
356
+ ->setParameter ('{{ value }} ' , '" ' ." A \u{0300}" .'" ' )
360
357
->setParameter ('{{ limit }} ' , 1 )
361
- ->setInvalidValue (self :: SINGLE_GRAPHEME_WITH_FOUR_CODEPOINTS_AND_THIRTEEN_BYTES )
358
+ ->setInvalidValue (" A \u{0300}" )
362
359
->setPlural (1 )
363
360
->setCode (Length::NOT_EQUAL_LENGTH_ERROR )
364
361
->assertRaised ();
@@ -368,12 +365,12 @@ public function testInvalidValuesExactBytesCountUnitWithGraphemeInput()
368
365
{
369
366
$ constraint = new Length (min: 1 , max: 1 , countUnit: Length::COUNT_BYTES , exactMessage: 'myMessage ' );
370
367
371
- $ this ->validator ->validate (self :: SINGLE_GRAPHEME_WITH_FOUR_CODEPOINTS_AND_THIRTEEN_BYTES , $ constraint );
368
+ $ this ->validator ->validate (" A \u{0300}" , $ constraint );
372
369
373
370
$ this ->buildViolation ('myMessage ' )
374
- ->setParameter ('{{ value }} ' , '" ' .self :: SINGLE_GRAPHEME_WITH_FOUR_CODEPOINTS_AND_THIRTEEN_BYTES .'" ' )
371
+ ->setParameter ('{{ value }} ' , '" ' ." A \u{0300}" .'" ' )
375
372
->setParameter ('{{ limit }} ' , 1 )
376
- ->setInvalidValue (self :: SINGLE_GRAPHEME_WITH_FOUR_CODEPOINTS_AND_THIRTEEN_BYTES )
373
+ ->setInvalidValue (" A \u{0300}" )
377
374
->setPlural (1 )
378
375
->setCode (Length::NOT_EQUAL_LENGTH_ERROR )
379
376
->assertRaised ();
0 commit comments