Skip to content

Commit d83e758

Browse files
committed
Security/ValidatedSanitizedInput: updates for PHPCS 4.0
Update the expectation for three test cases as they are different between PHPCS 3.x and PHPCS 4.x (see WordPress#2665).
1 parent f29fe59 commit d83e758

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

WordPress/Tests/Security/ValidatedSanitizedInputUnitTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace WordPressCS\WordPress\Tests\Security;
1111

1212
use PHP_CodeSniffer\Tests\Standards\AbstractSniffTestCase;
13+
use PHPCSUtils\BackCompat\Helper;
1314

1415
/**
1516
* Unit test class for the ValidatedSanitizedInput sniff.
@@ -35,6 +36,9 @@ final class ValidatedSanitizedInputUnitTest extends AbstractSniffTestCase {
3536
* @return array<int, int> Key is the line number, value is the number of expected errors.
3637
*/
3738
public function getErrorList( $testFile = '' ) {
39+
$phpcs_version = Helper::getVersion();
40+
$is_phpcs_4 = version_compare( $phpcs_version, '3.99.99', '>' );
41+
3842
switch ( $testFile ) {
3943
case 'ValidatedSanitizedInputUnitTest.1.inc':
4044
return array(
@@ -122,9 +126,9 @@ public function getErrorList( $testFile = '' ) {
122126
532 => 2,
123127
533 => 2,
124128
534 => 2,
125-
549 => 1,
126-
552 => 1,
127-
555 => 1,
129+
549 => ( true === $is_phpcs_4 ) ? 2 : 1,
130+
552 => ( true === $is_phpcs_4 ) ? 2 : 1,
131+
555 => ( true === $is_phpcs_4 ) ? 2 : 1,
128132
567 => 1,
129133
570 => 1,
130134
573 => 1,

0 commit comments

Comments
 (0)