function CoderReviewSecurityTest::testSecurityTriggerError in Coder 7.2
Same name and namespace in other branches
- 7 coder_review/tests/coder_review_security.test \CoderReviewSecurityTest::testSecurityTriggerError()
Tests functionality to detect correct use of trigger_error() function.
File
- coder_review/
tests/ coder_review_security.test, line 105
Class
- CoderReviewSecurityTest
- Tests the Coder_review functionality to detect security-related rules.
Code
function testSecurityTriggerError() {
$this
->assertCoderReviewPass(' trigger_error(t("Here is some safe_data"));');
$this
->assertCoderReviewPass(' trigger_error(t("Here is some @safe_data", array("@safe_data" => $tainted_data));');
$this
->assertCoderReviewPass(' trigger_error(t("Here is some %safe_data", array("%safe_data" => $tainted_data));');
$this
->assertCoderReviewPass(' trigger_error(t("Here is some @safe_data", $safe_data_array));');
$this
->assertCoderReviewPass(' trigger_error(check_plain($tainted_data));');
$this
->assertCoderReviewPass(' trigger_error(filter_xss_admin($tainted_data));');
$this
->assertCoderReviewPass(' trigger_error(format_plural($tainted_count, "1 item", "@count items"));');
$this
->assertCoderReviewPass(' trigger_error(check_markup($tainted_data));');
$this
->assertCoderReviewPass(" function abc() {\n \$tainted_data = check_plain('mystring');\n trigger_error(\$tainted_data);\n}");
$this
->assertCoderReviewFail(" function abc() {\n trigger_error(\$tainted_data);\n}");
$this
->assertCoderReviewFail(' trigger_error(t($tainted_data));');
$this
->assertCoderReviewFail(' trigger_error("Here is some ". $tainted_data);');
$this
->assertCoderReviewFail(' trigger_error("Here is some $tainted_data");');
$this
->assertCoderReviewFail(' trigger_error(t("Here is some ". $tainted_data));');
$this
->assertCoderReviewFail(' trigger_error(t("Here is some !tainted_data", array("!tainted_data" => $tainted_data));');
}