function CoderReviewSecurityTest::testSecurityFAPITitleDescription in Coder 7.2
Same name and namespace in other branches
- 7 coder_review/tests/coder_review_security.test \CoderReviewSecurityTest::testSecurityFAPITitleDescription()
Tests functionality to detect correct use of #title element in FAPI array.
@todo Break out checks for FAPI Description to its own method.
File
- coder_review/
tests/ coder_review_security.test, line 322
Class
- CoderReviewSecurityTest
- Tests the Coder_review functionality to detect security-related rules.
Code
function testSecurityFAPITitleDescription() {
$this
->assertCoderReviewPass(" function mymodule_form() {\n \$field = array(\n '#title' => t('%title', array('%title' => \$title)),\n );\n}");
$this
->assertCoderReviewPass(" function mymodule_form() {\n \$field = array(\n '#title' => 'abc',\n );\n}");
$this
->assertCoderReviewPass(" function mymodule_form() {\n \$field = array(\n '#title' => check_plain(\$title),\n );\n}");
$this
->assertCoderReviewPass(" function mymodule_form() {\n \$field = array(\n '#title' => t('%title', array('%title' => \$title)),\n );\n}");
$this
->assertCoderReviewPass(" function mymodule_form() {\n \$title = check_plain(\$title);\n \$field = array(\n '#title' => \$title,\n );\n}");
$this
->assertCoderReviewPass(" function mymodule_form() {\n \$title = check_plain(\$title);\n \$field = array(\n '#title' => t('!title', array('!title' => \$title)),\n );\n}");
$this
->assertCoderReviewFail(" function mymodule_form() {\n \$field = array(\n '#title' => \$title,\n );\n}");
$this
->assertCoderReviewFail(" function mymodule_form() {\n \$field = array(\n '#description' => \$description,\n );\n}");
$this
->assertCoderReviewFail(" function mymodule_form_alter() {\n \$field = array(\n '#title' => \$title,\n );\n}");
$this
->assertCoderReviewFail(" function mymodule_form() {\n \$field = array(\n '#title' => t('!title', array('!title' => \$title)),\n );\n}");
}