-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #16 Unit test cases for plugin #19
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phpcs scanning turned up:
❗ 2 warnings
hashes-api-scanning skipped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phpcs scanning turned up:
🚫 2 errors
hashes-api-scanning skipped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phpcs scanning turned up:
❗ 7 warnings
hashes-api-scanning skipped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phpcs scanning turned up:
❗ 2 warnings
hashes-api-scanning skipped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phpcs scanning turned up:
🚫 1 error
❗ 2 warnings
hashes-api-scanning skipped
Signed-off-by: Riddhesh Sanghvi <riddhesh237@gmail.com>
Signed-off-by: Riddhesh Sanghvi <riddhesh237@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phpcs scanning turned up:
🚫 21 errors
hashes-api-scanning skipped
Posting will continue in further review(s)
|
||
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
|
||
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
parent::setUp(); | ||
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
*/ | ||
class Test_Plugin extends \WP_UnitTestCase { | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
$this->assertEquals( $_ENV['custom_key'], Helper::filter_input( INPUT_ENV, 'custom_key' ) ); | ||
$this->assertEquals( $_SERVER['HTTP_HOST'], Helper::filter_input( INPUT_SERVER, 'HTTP_HOST' ) ); | ||
|
||
unset( $_GET['custom_key'], $_POST['custom_key'], $_COOKIE['custom_key'], $_ENV['custom_key'] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->assertEquals( $_ENV['custom_key'], Helper::filter_input( INPUT_ENV, 'custom_key' ) ); | ||
$this->assertEquals( $_SERVER['HTTP_HOST'], Helper::filter_input( INPUT_SERVER, 'HTTP_HOST' ) ); | ||
|
||
unset( $_GET['custom_key'], $_POST['custom_key'], $_COOKIE['custom_key'], $_ENV['custom_key'] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->assertEquals( $_POST['custom_key'], Helper::filter_input( INPUT_POST, 'custom_key' ) ); | ||
$this->assertEquals( $_COOKIE['custom_key'], Helper::filter_input( INPUT_COOKIE, 'custom_key' ) ); | ||
$this->assertEquals( $_ENV['custom_key'], Helper::filter_input( INPUT_ENV, 'custom_key' ) ); | ||
$this->assertEquals( $_SERVER['HTTP_HOST'], Helper::filter_input( INPUT_SERVER, 'HTTP_HOST' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Error: Detected usage of a non-sanitized input variable: $_SERVER['HTTP_HOST'] (WordPress.Security.ValidatedSanitizedInput.InputNotSanitized).
$this->assertEquals( $_POST['custom_key'], Helper::filter_input( INPUT_POST, 'custom_key' ) ); | ||
$this->assertEquals( $_COOKIE['custom_key'], Helper::filter_input( INPUT_COOKIE, 'custom_key' ) ); | ||
$this->assertEquals( $_ENV['custom_key'], Helper::filter_input( INPUT_ENV, 'custom_key' ) ); | ||
$this->assertEquals( $_SERVER['HTTP_HOST'], Helper::filter_input( INPUT_SERVER, 'HTTP_HOST' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Error: Detected usage of a possibly undefined superglobal array index: $_SERVER['HTTP_HOST']. Use isset() or empty() to check the index exists before using it (WordPress.Security.ValidatedSanitizedInput.InputNotValidated).
|
||
$this->assertEquals( $_GET['custom_key'], Helper::filter_input( INPUT_GET, 'custom_key' ) ); | ||
$this->assertEquals( $_POST['custom_key'], Helper::filter_input( INPUT_POST, 'custom_key' ) ); | ||
$this->assertEquals( $_COOKIE['custom_key'], Helper::filter_input( INPUT_COOKIE, 'custom_key' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Error: Detected usage of a non-sanitized input variable: $_COOKIE['custom_key'] (WordPress.Security.ValidatedSanitizedInput.InputNotSanitized).
|
||
$this->assertEquals( $_GET['custom_key'], Helper::filter_input( INPUT_GET, 'custom_key' ) ); | ||
$this->assertEquals( $_POST['custom_key'], Helper::filter_input( INPUT_POST, 'custom_key' ) ); | ||
$this->assertEquals( $_COOKIE['custom_key'], Helper::filter_input( INPUT_COOKIE, 'custom_key' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Error: Detected usage of a possibly undefined superglobal array index: $_COOKIE['custom_key']. Use isset() or empty() to check the index exists before using it (WordPress.Security.ValidatedSanitizedInput.InputNotValidated).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous scan continued.
|
||
$this->assertEquals( $_GET['custom_key'], Helper::filter_input( INPUT_GET, 'custom_key' ) ); | ||
$this->assertEquals( $_POST['custom_key'], Helper::filter_input( INPUT_POST, 'custom_key' ) ); | ||
$this->assertEquals( $_COOKIE['custom_key'], Helper::filter_input( INPUT_COOKIE, 'custom_key' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$_ENV['custom_key'] = 'Values on ENV variable.'; | ||
|
||
$this->assertEquals( $_GET['custom_key'], Helper::filter_input( INPUT_GET, 'custom_key' ) ); | ||
$this->assertEquals( $_POST['custom_key'], Helper::filter_input( INPUT_POST, 'custom_key' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Error: Detected usage of a non-sanitized input variable: $_POST['custom_key'] (WordPress.Security.ValidatedSanitizedInput.InputNotSanitized).
$_ENV['custom_key'] = 'Values on ENV variable.'; | ||
|
||
$this->assertEquals( $_GET['custom_key'], Helper::filter_input( INPUT_GET, 'custom_key' ) ); | ||
$this->assertEquals( $_POST['custom_key'], Helper::filter_input( INPUT_POST, 'custom_key' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Error: Detected usage of a possibly undefined superglobal array index: $_POST['custom_key']. Use isset() or empty() to check the index exists before using it (WordPress.Security.ValidatedSanitizedInput.InputNotValidated).
$_ENV['custom_key'] = 'Values on ENV variable.'; | ||
|
||
$this->assertEquals( $_GET['custom_key'], Helper::filter_input( INPUT_GET, 'custom_key' ) ); | ||
$this->assertEquals( $_POST['custom_key'], Helper::filter_input( INPUT_POST, 'custom_key' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Error: Processing form data without nonce verification (WordPress.Security.NonceVerification.Missing).
$_COOKIE['custom_key'] = 'Values on COOKIE variable.'; | ||
$_ENV['custom_key'] = 'Values on ENV variable.'; | ||
|
||
$this->assertEquals( $_GET['custom_key'], Helper::filter_input( INPUT_GET, 'custom_key' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Error: Detected usage of a non-sanitized input variable: $_GET['custom_key'] (WordPress.Security.ValidatedSanitizedInput.InputNotSanitized).
$_COOKIE['custom_key'] = 'Values on COOKIE variable.'; | ||
$_ENV['custom_key'] = 'Values on ENV variable.'; | ||
|
||
$this->assertEquals( $_GET['custom_key'], Helper::filter_input( INPUT_GET, 'custom_key' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Error: Detected usage of a possibly undefined superglobal array index: $_GET['custom_key']. Use isset() or empty() to check the index exists before using it (WordPress.Security.ValidatedSanitizedInput.InputNotValidated).
$_COOKIE['custom_key'] = 'Values on COOKIE variable.'; | ||
$_ENV['custom_key'] = 'Values on ENV variable.'; | ||
|
||
$this->assertEquals( $_GET['custom_key'], Helper::filter_input( INPUT_GET, 'custom_key' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*/ | ||
$_GET['custom_key'] = 'Values on GET variable.'; | ||
$_POST['custom_key'] = 'Values on POST variable.'; | ||
$_COOKIE['custom_key'] = 'Values on COOKIE variable.'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->assertEquals( '', $output ); | ||
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
*/ | ||
class Test_Helper extends \WP_UnitTestCase { | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous scan continued.
|
||
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
|
||
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
if ( empty( $_redirect_to ) ) { | ||
$this->assertEquals( $state[0], admin_url() ); | ||
} else { | ||
$this->assertEquals( $state[0], $_redirect_to ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$state = $client_config['state']; | ||
$state = explode( '|', urldecode_deep( $state ) ); | ||
|
||
if ( empty( $_redirect_to ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); | ||
|
||
// Start up the WP testing environment. | ||
require_once $_tests_dir . '/includes/bootstrap.php'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$_tests_dir
). Probably needs manual inspection (WordPressVIPMinimum.Files.IncludingFile.UsingVariable).
} | ||
|
||
// Give access to tests_add_filter() function. | ||
require_once $_tests_dir . '/includes/functions.php'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$_tests_dir
). Probably needs manual inspection (WordPressVIPMinimum.Files.IncludingFile.UsingVariable).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous scan continued.
Signed-off-by: Riddhesh Sanghvi <riddhesh237@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phpcs scanning turned up:
hashes-api-scanning skipped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phpcs scanning turned up:
🚫 5 errors
hashes-api-scanning skipped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phpcs scanning turned up:
🚫 1 error
hashes-api-scanning skipped
Fixes #16