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";'); } }