Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeherve committed Nov 15, 2023
1 parent 3b7b7de commit fce9617
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
14 | ERROR | [ ] Unicode codepoint escape sequences are not supported in PHP 5.6 or earlier. Found: \u{0061}
| | (PHPCompatibility.TextStrings.NewUnicodeEscapeSequence.Found)
17 | ERROR | [x] Mismatched text domain. Expected 'domain' but got 'wrongdomain'. (Jetpack.Functions.I18n.TextDomainMismatch)
18 | ERROR | [x] Mismatched text domain. Expected 'domain' but got 'wrongdomain'. (Jetpack.Functions.I18n.TextDomainMismatch)
21 | ERROR | [x] Missing domain arg. (Jetpack.Functions.I18n.MissingDomain)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class JetpackCompatTest extends TestCase {

const SRC1 = <<<'EOF'
<?php
function bad_in_56( bool $b ) {}
try {} catch ( Bad | In70 $e ) {}
function bad_in_71( object $o ) {}
bad_in_72( $a, $b, );
Expand Down Expand Up @@ -74,7 +73,7 @@ public function test_phpcs( $standard, $src, $expect ) {
'VariableAnalysis.CodeAnalysis.VariableAnalysis',
'WordPress.WhiteSpace.ControlStructureSpacing',
);
Config::setConfigData( 'testVersion', '5.6-' );
Config::setConfigData( 'testVersion', '7.0-' );

$ruleset = new Ruleset( $config );
$dummy = new DummyFile( $src, $ruleset, $config );
Expand Down Expand Up @@ -102,24 +101,22 @@ public function test_phpcs( $standard, $src, $expect ) {
*/
public function provide_standards() {
$lines1 = array(
' 2 | ERROR | \'bool\' type declaration is not present in PHP version 5.6 or earlier (PHPCompatibility.FunctionDeclarations.NewParamTypeDeclarations.boolFound)',
' 3 | ERROR | Catching multiple exceptions within one statement is not supported in PHP 7.0 or earlier. (PHPCompatibility.ControlStructures.NewMultiCatch.Found)',
' 4 | ERROR | \'object\' type declaration is not present in PHP version 7.1 or earlier (PHPCompatibility.FunctionDeclarations.NewParamTypeDeclarations.objectFound)',
' 5 | ERROR | Trailing comma\'s are not allowed in function calls in PHP 7.2 or earlier (PHPCompatibility.Syntax.NewFunctionCallTrailingComma.FoundInFunctionCall)',
' 6 | ERROR | null coalesce equal operator (??=) is not present in PHP version 7.3 or earlier (PHPCompatibility.Operators.NewOperators.t_coalesce_equalFound)',
' 2 | ERROR | Catching multiple exceptions within one statement is not supported in PHP 7.0 or earlier. (PHPCompatibility.ControlStructures.NewMultiCatch.Found)',
' 3 | ERROR | \'object\' type declaration is not present in PHP version 7.1 or earlier (PHPCompatibility.FunctionDeclarations.NewParamTypeDeclarations.objectFound)',
' 4 | ERROR | Trailing comma\'s are not allowed in function calls in PHP 7.2 or earlier (PHPCompatibility.Syntax.NewFunctionCallTrailingComma.FoundInFunctionCall)',
' 5 | ERROR | null coalesce equal operator (??=) is not present in PHP version 7.3 or earlier (PHPCompatibility.Operators.NewOperators.t_coalesce_equalFound)',
);

yield array( 'Jetpack', self::SRC1, $lines1 );
yield array( 'Jetpack-Compat-71', self::SRC1, array_slice( $lines1, 2 ) );
yield array( 'Jetpack-Compat-72', self::SRC1, array_slice( $lines1, 3 ) );
yield array( 'Jetpack-Compat-73', self::SRC1, array_slice( $lines1, 4 ) );
yield array( 'Jetpack-Compat-74', self::SRC1, array_slice( $lines1, 5 ) );
yield array( 'Jetpack-Compat-80', self::SRC1, array_slice( $lines1, 6 ) );
yield array( 'Jetpack-Compat-81', self::SRC1, array_slice( $lines1, 7 ) );
yield array( 'Jetpack-Compat-82', self::SRC1, array_slice( $lines1, 8 ) );
yield array( 'Jetpack-Compat-71', self::SRC1, array_slice( $lines1, 1 ) );
yield array( 'Jetpack-Compat-72', self::SRC1, array_slice( $lines1, 2 ) );
yield array( 'Jetpack-Compat-73', self::SRC1, array_slice( $lines1, 3 ) );
yield array( 'Jetpack-Compat-74', self::SRC1, array_slice( $lines1, 4 ) );
yield array( 'Jetpack-Compat-80', self::SRC1, array_slice( $lines1, 5 ) );
yield array( 'Jetpack-Compat-81', self::SRC1, array_slice( $lines1, 6 ) );
yield array( 'Jetpack-Compat-82', self::SRC1, array_slice( $lines1, 7 ) );

$lines2 = array(
' 2 | WARNING | INI directive \'assert.exception\' is not present in PHP version 5.6 or earlier (PHPCompatibility.IniDirectives.NewIniDirectives.assert_exceptionFound)',
' 3 | WARNING | INI directive \'hard_timeout\' is not present in PHP version 7.0 or earlier (PHPCompatibility.IniDirectives.NewIniDirectives.hard_timeoutFound)',
' 4 | WARNING | INI directive \'imap.enable_insecure_rsh\' is not present in PHP version 7.1.24 or earlier (PHPCompatibility.IniDirectives.NewIniDirectives.imap_enable_insecure_rshFound)',
' 5 | WARNING | INI directive \'session.cookie_samesite\' is not present in PHP version 7.2 or earlier (PHPCompatibility.IniDirectives.NewIniDirectives.session_cookie_samesiteFound)',
Expand All @@ -128,12 +125,12 @@ public function provide_standards() {
);

yield array( 'Jetpack', self::SRC2, $lines2 );
yield array( 'Jetpack-Compat-71', self::SRC2, array_slice( $lines2, 2 ) );
yield array( 'Jetpack-Compat-72', self::SRC2, array_slice( $lines2, 3 ) );
yield array( 'Jetpack-Compat-73', self::SRC2, array_slice( $lines2, 4 ) );
yield array( 'Jetpack-Compat-74', self::SRC2, array_slice( $lines2, 5 ) );
yield array( 'Jetpack-Compat-80', self::SRC2, array_slice( $lines2, 6 ) );
yield array( 'Jetpack-Compat-81', self::SRC2, array_slice( $lines2, 7 ) );
yield array( 'Jetpack-Compat-82', self::SRC2, array_slice( $lines2, 8 ) );
yield array( 'Jetpack-Compat-71', self::SRC2, array_slice( $lines2, 1 ) );
yield array( 'Jetpack-Compat-72', self::SRC2, array_slice( $lines2, 2 ) );
yield array( 'Jetpack-Compat-73', self::SRC2, array_slice( $lines2, 3 ) );
yield array( 'Jetpack-Compat-74', self::SRC2, array_slice( $lines2, 4 ) );
yield array( 'Jetpack-Compat-80', self::SRC2, array_slice( $lines2, 5 ) );
yield array( 'Jetpack-Compat-81', self::SRC2, array_slice( $lines2, 6 ) );
yield array( 'Jetpack-Compat-82', self::SRC2, array_slice( $lines2, 7 ) );
}
}

0 comments on commit fce9617

Please sign in to comment.