function CoderReviewSecurityTest::testSecurityFAPIMarkupValue in Coder 7.2
Same name and namespace in other branches
- 7 coder_review/tests/coder_review_security.test \CoderReviewSecurityTest::testSecurityFAPIMarkupValue()
Tests functionality to detect correct use of #value element in FAPI array.
File
- coder_review/
tests/ coder_review_security.test, line 338
Class
- CoderReviewSecurityTest
- Tests the Coder_review functionality to detect security-related rules.
Code
function testSecurityFAPIMarkupValue() {
$this
->assertCoderReviewPass(" function mymodule_function() {\n \$field = array(\n '#value' => \$value,\n );\n}");
$this
->assertCoderReviewPass(" function mymodule_form() {\n \$field = array(\n '#value' => check_plain(\$value),\n );\n}");
$this
->assertCoderReviewPass(" function mymodule_form() {\n \$field = array(\n '#value' => \$value,\n '#type' => 'textfield',\n );\n}");
$this
->assertCoderReviewPass(" function mymodule_form() {\n \$value = check_plain(\$value);\n \$field = array(\n '#value' => \$value,\n );\n}");
$this
->assertCoderReviewPass(" function mymodule_form() {\n \$field = array(\n '#value' => t('%value', array('%value' => \$value)),\n );\n}");
$this
->assertCoderReviewPass(" function mymodule_form() {\n \$value = check_plain(\$value);\n \$field = array(\n '#value' => t('!value', array('!value' => \$value)),\n );\n}");
$this
->assertCoderReviewFail(" function mymodule_form() {\n \$field = array(\n '#value' => \$value,\n );\n}");
$this
->assertCoderReviewFail(" function mymodule_form_alter() {\n \$field = array(\n '#value' => \$value,\n );\n}");
$this
->assertCoderReviewFail(" function mymodule_form() {\n \$field = array(\n '#value' => \$value,\n '#type' => 'markup',\n );\n}");
$this
->assertCoderReviewFail(" function mymodule_form() {\n \$field = array(\n '#type' => 'markup',\n '#value' => \$value,\n );\n}");
$this
->assertCoderReviewFail(" function mymodule_form() {\n \$field = array(\n '#value' => t('!value', array('!value' => \$value)),\n );\n}");
}