Skip to content

Commit

Permalink
Add unit test for the updated rules
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Dec 17, 2024
1 parent 9a9dc73 commit c9d0d23
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@

parse_str( 'first=value&arr[]=foo+bar&arr[]=baz' );

$encoded_value = json_encode( array( 'key' => 'value' ) );

Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public function test_run_with_errors() {
// Check for PluginCheck.CodeAnalysis.RequiredFunctionParameters.parse_str_resultMissing error on Line no 34 and column no at 1.
$this->assertSame( 'PluginCheck.CodeAnalysis.RequiredFunctionParameters.parse_str_resultMissing', $errors['load.php'][34][1][0]['code'] );

// There should not be WordPress.WP.AlternativeFunctions.json_encode_json_encode error on Line no 36 and column no at 18.
$this->assertCount( 0, wp_list_filter( $errors['load.php'][36][18], array( 'code' => 'WordPress.WP.AlternativeFunctions.json_encode_json_encode' ) ) );

// Check for WordPress.Security.ValidatedSanitizedInput warnings on Line no 15 and column no at 27.
$this->assertCount( 1, wp_list_filter( $warnings['load.php'][15][27], array( 'code' => 'WordPress.Security.ValidatedSanitizedInput.InputNotValidated' ) ) );
$this->assertCount( 1, wp_list_filter( $warnings['load.php'][15][27], array( 'code' => 'WordPress.Security.ValidatedSanitizedInput.MissingUnslash' ) ) );
Expand Down

0 comments on commit c9d0d23

Please sign in to comment.