Skip to content

Commit

Permalink
Update test for discouraged function
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Sep 17, 2024
1 parent d916d8f commit bd419dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 28 deletions.
3 changes: 0 additions & 3 deletions phpcs-rulesets/plugin-review.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,4 @@
<!-- Check for usage of deprecated parameter values in WP functions and provide alternative based on the parameter passed. -->
<rule ref="WordPress.WP.DeprecatedParameterValues"/>




</ruleset>
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ public function test_run_with_errors() {

$plugin_review_phpcs_check->run( $check_result );

$errors = $check_result->get_errors();
$errors = $check_result->get_errors();
$warnings = $check_result->get_warnings();

$this->assertNotEmpty( $errors );
$this->assertArrayHasKey( 'load.php', $errors );
$this->assertEquals( 9, $check_result->get_error_count() );
$this->assertNotEmpty( $warnings );
$this->assertArrayHasKey( 'load.php', $warnings );

// Check for Generic.PHP.DisallowShortOpenTag.Found error on Line no 6 and column no at 1.
$this->assertArrayHasKey( 6, $errors['load.php'] );
Expand All @@ -42,29 +44,17 @@ public function test_run_with_errors() {
$this->assertArrayHasKey( 'code', $errors['load.php'][15][27][0] );
$this->assertEquals( 'WordPress.Security.ValidatedSanitizedInput.InputNotValidated', $errors['load.php'][15][27][0]['code'] );

// Check for WordPress.Security.Generic.PHP.ForbiddenFunctions.Found error on Line no 17 and column no at 1.
$this->assertArrayHasKey( 17, $errors['load.php'] );
$this->assertArrayHasKey( 1, $errors['load.php'][17] );
$this->assertArrayHasKey( 'code', $errors['load.php'][17][1][0] );
$this->assertEquals( 'Generic.PHP.ForbiddenFunctions.Found', $errors['load.php'][17][1][0]['code'] );

// Check for WordPress.Security.Generic.PHP.ForbiddenFunctions.Found error on Line no 18 and column no at 1.
$this->assertArrayHasKey( 18, $errors['load.php'] );
$this->assertArrayHasKey( 1, $errors['load.php'][18] );
$this->assertArrayHasKey( 'code', $errors['load.php'][18][1][0] );
$this->assertEquals( 'Generic.PHP.ForbiddenFunctions.Found', $errors['load.php'][18][1][0]['code'] );

// Check for WordPress.Security.Generic.PHP.ForbiddenFunctions.Found error on Line no 19 and column no at 1.
$this->assertArrayHasKey( 19, $errors['load.php'] );
$this->assertArrayHasKey( 1, $errors['load.php'][19] );
$this->assertArrayHasKey( 'code', $errors['load.php'][19][1][0] );
$this->assertEquals( 'Generic.PHP.ForbiddenFunctions.Found', $errors['load.php'][19][1][0]['code'] );

// Check for WordPress.Security.Generic.PHP.ForbiddenFunctions.Found error on Line no 20 and column no at 1.
$this->assertArrayHasKey( 20, $errors['load.php'] );
$this->assertArrayHasKey( 1, $errors['load.php'][20] );
$this->assertArrayHasKey( 'code', $errors['load.php'][20][1][0] );
$this->assertEquals( 'Generic.PHP.ForbiddenFunctions.Found', $errors['load.php'][20][1][0]['code'] );
// Check for Squiz.PHP.DiscouragedFunctions.Discouraged warning on Line no 17 and column no at 1.
$this->assertSame( 'Squiz.PHP.DiscouragedFunctions.Discouraged', $warnings['load.php'][17][1][0]['code'] );

// Check for Squiz.PHP.DiscouragedFunctions.Discouraged warning on Line no 18 and column no at 1.
$this->assertSame( 'Squiz.PHP.DiscouragedFunctions.Discouraged', $warnings['load.php'][18][1][0]['code'] );

// Check for Squiz.PHP.DiscouragedFunctions.Discouraged warning on Line no 19 and column no at 1.
$this->assertSame( 'Squiz.PHP.DiscouragedFunctions.Discouraged', $warnings['load.php'][19][1][0]['code'] );

// Check for Squiz.PHP.DiscouragedFunctions.Discouraged warning on Line no 20 and column no at 1.
$this->assertSame( 'Squiz.PHP.DiscouragedFunctions.Discouraged', $warnings['load.php'][20][1][0]['code'] );
}

public function test_run_without_errors() {
Expand Down

0 comments on commit bd419dd

Please sign in to comment.