You are here

function CoderReviewSecurityTest::testSecurityFormSetError in Coder 7

Same name and namespace in other branches
  1. 7.2 coder_review/tests/coder_review_security.test \CoderReviewSecurityTest::testSecurityFormSetError()

File

coder_review/tests/coder_review_security.test, line 136

Class

CoderReviewSecurityTest

Code

function testSecurityFormSetError() {
  $this
    ->assertCoderReviewPass('  form_set_error("name", t("Here is some safe_data"));');
  $this
    ->assertCoderReviewPass('  form_set_error($name, t("Here is some safe_data"));');
  $this
    ->assertCoderReviewPass('  form_set_error($name, t("Here is some @safe_data", array("@safe_data" => $tainted_data));');
  $this
    ->assertCoderReviewPass('  form_set_error($name, t("Here is some %safe_data", array("%safe_data" => $tainted_data));');
  $this
    ->assertCoderReviewPass('  form_set_error($name, t("Here is some @safe_data", $safe_data_array));');
  $this
    ->assertCoderReviewPass('  form_set_error($name, check_plain($tainted_data));');
  $this
    ->assertCoderReviewPass('  form_set_error($name, filter_xss_admin($tainted_data));');
  $this
    ->assertCoderReviewPass('  form_set_error($name, format_plural($tainted_count, "1 item", "@count items"));');
  $this
    ->assertCoderReviewPass('  form_set_error($name, check_markup($tainted_data));');
  $this
    ->assertCoderReviewPass("  function abc() {\n \$tainted_data = check_plain('mystring');\n  form_set_error(\$name, \$tainted_data);\n}");
  $this
    ->assertCoderReviewFail("  function abc() {\n form_set_error(\$name, \$tainted_data);\n}");
  $this
    ->assertCoderReviewFail('  form_set_error($name, t($tainted_data));');
  $this
    ->assertCoderReviewFail('  form_set_error($name, "Here is some ". $tainted_data);');
  $this
    ->assertCoderReviewFail('  form_set_error($name, "Here is some $tainted_data");');
  $this
    ->assertCoderReviewFail('  form_set_error($name, t("Here is some ". $tainted_data));');
  $this
    ->assertCoderReviewFail('  form_set_error($name, t("Here is some !tainted_data", array("!tainted_data" => $tainted_data));');
}