class CoderSQLTest in Coder 6.2
Same name and namespace in other branches
- 6 tests/coder_sql.test \CoderSQLTest
Hierarchy
- class \CoderTestCase extends \DrupalTestCase
- class \CoderSQLTest
Expanded class hierarchy of CoderSQLTest
File
- tests/
coder_sql.test, line 10
View source
class CoderSQLTest extends CoderTestCase {
function __construct($id = NULL) {
parent::__construct('sql', $id);
}
public static function getInfo() {
return array(
'name' => t('Coder SQL Tests'),
'description' => t('Tests for the coder SQL review.'),
'group' => t('Coder'),
);
}
function testSQLLowerCaseKeywords() {
$this
->assertCoderFail(' $sql = "select * from {node}";');
$this
->assertCoderFail(' $sql = "insert into {node} (changed) VALUES (%d)";');
$this
->assertCoderFail(' $sql = "delete from {node}";');
$this
->assertCoderFail(' $sql = "update {node} set changed = now()";');
$this
->assertCoderFail(' $var = t("select something from this");');
$this
->assertCoderPass(' $var = t("update something");');
$this
->assertCoderPass(' $var = t("insert something");');
$this
->assertCoderPass(' $var = t("delete something");');
}
function testSQLBracketNode() {
$this
->assertCoderFail(' $sql = "INSERT INTO node (changed) VALUES (1)";');
$this
->assertCoderPass(' $sql = "INSERT INTO {node} (changed) VALUES (1)";');
}
function testSQLLimit() {
$this
->assertCoderFail(' $sql = "SELECT * FROM {node} LIMIT 10";');
}
function testSQLBackTick() {
$this
->assertCoderFail(' $sql = "SELECT * FROM {node} WHERE title=`abc`";');
$this
->assertCoderFail(' $sql = "INSERT INTO {foo} (nid, title) VALUES (\'1\', `abc`)";');
$this
->assertCoderFail(' $sql = "INSERT INTO {foo} VALUES (\'1\', `abc`)";');
$this
->assertCoderFail(' $sql = "UPDATE {foo} SET nid=\'1\', title=`abc`";');
$this
->assertCoderFail(' $sql = "DELETE FROM {foo} WHERE nid=\'1\' AND title=`abc`";');
}
function testSQLNotEquals() {
$this
->assertCoderFail(' $sql = "SELECT * FROM {node} WHERE nid != 10";');
$this
->assertCoderPass(' $sql = "SELECT * FROM {node} WHERE nid = 10";');
$this
->assertCoderPass(' $sql = "SELECT * FROM {node} WHERE nid <> 10";');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CoderSQLTest:: |
public static | function | ||
CoderSQLTest:: |
function | |||
CoderSQLTest:: |
function | |||
CoderSQLTest:: |
function | |||
CoderSQLTest:: |
function | |||
CoderSQLTest:: |
function | |||
CoderSQLTest:: |
function | |||
CoderTestCase:: |
function |