View source
<?php
require_once dirname(__FILE__) . '/coder_review_test_case.tinc';
class CoderReviewUpgrade7xTest extends CoderReviewTestCase {
function __construct($id = NULL) {
parent::__construct('upgrade7x', $id);
}
public static function getInfo() {
return array(
'name' => 'Coder Review 7.x Upgrade Tests',
'description' => 'Tests for the coder upgrade7x review.',
'group' => 'CoderReview',
);
}
function testTestModule7x() {
$this
->runTestModuleTest();
}
function testModule7x() {
$this
->assertCoderReviewFail(' $ret = update_sql("UPDATE {node} SET status = 1");');
}
function testSystem7x() {
$this
->assertCoderReviewFail(" foreach (module_list() as \$module) {\n module_invoke(\$module, 'foo');\n}");
$this
->assertCoderReviewPass(" foreach (module_list() as \$module) {\n print 'foo';\n}");
$this
->assertCoderReviewFail(" require variable_get('cache_inc', './includes/cache.inc');");
$this
->assertCoderReviewFail(" require_once variable_get('cache_inc', './includes/cache.inc');");
$this
->assertCoderReviewFail(" include variable_get('cache_inc', './includes/cache.inc');");
$this
->assertCoderReviewFail(" include_once variable_get('cache_inc', './includes/cache.inc');");
$this
->assertCoderReviewPass(" require DRUPAL_ROOT . '/' . variable_get('cache_inc', 'includes/cache.inc');");
$this
->assertCoderReviewPass(" require_once DRUPAL_ROOT . '/' . variable_get('cache_inc', 'includes/cache.inc');");
$this
->assertCoderReviewPass(" include DRUPAL_ROOT . '/' . variable_get('cache_inc', 'includes/cache.inc');");
$this
->assertCoderReviewPass(" include_once DRUPAL_ROOT . '/' . variable_get('cache_inc', 'includes/cache.inc');");
$this
->assertCoderReviewFail(' $time = time();');
$this
->assertCoderReviewFail(' $time = foo(time());');
$this
->assertCoderReviewPass(' $time = foo_time();');
$this
->assertCoderReviewFail(' drupal_rebuild_code_registry();');
$this
->assertCoderReviewFail(' drupal_uninstall_module("foo");');
$this
->assertCoderReviewPass(' drupal_uninstall_modules(array("foo"));');
$this
->assertCoderReviewPass(' drupal_http_request($url, $options);');
$this
->assertCoderReviewPass(' drupal_http_request($url, array());');
$this
->assertCoderReviewFail(' drupal_http_request($url, $headers, $method, $data, $retry);');
$this
->assertCoderReviewFail(' drupal_http_request($url, $headers, $method, $data);');
$this
->assertCoderReviewFail(' drupal_http_request($url, $headers, $method);');
$this
->assertCoderReviewFail(' drupal_http_request($url, array(), $method, $data, $retry);');
$this
->assertCoderReviewFail(' drupal_http_request($url, $headers, "GET", $data, $retry);');
$this
->assertCoderReviewFail(' drupal_http_request($url, $headers, "GET", NULL, $retry);');
$this
->assertCoderReviewFail(' drupal_http_request($url, $headers, "GET", "foo", $retry);');
$this
->assertCoderReviewFail(' drupal_http_request($url, $headers, "GET");');
$this
->assertCoderReviewFail(' $path = "admin/reports/settings";');
$this
->assertCoderReviewFail(" \$path = 'admin/reports/settings';");
$this
->assertCoderReviewFail(' $path = "URL is admin/reports/settings.";');
$this
->assertCoderReviewFail(' module_rebuild_cache();');
$this
->assertCoderReviewFail(' system_theme_data();');
$this
->assertCoderReviewFail(' drupal_set_html_head($data);');
$this
->assertCoderReviewFail(' drupal_eval(\'<?php print "Hello"; ?>\');');
$this
->assertCoderReviewPass(" drupal_add_http_header('Content-Type', 'text/plain');");
$this
->assertCoderReviewFail(" drupal_set_header('Content-Type: text/plain');");
$this
->assertCoderReviewPass(" drupal_add_http_header('Status', '500 Internal server error');");
$this
->assertCoderReviewFail(" drupal_set_header(\$_SERVER['SERVER_PROTOCOL'] . ' 500 Internal server error');");
$this
->assertCoderReviewPass(" drupal_get_http_header();");
$this
->assertCoderReviewFail(" drupal_get_headers();");
$this
->assertCoderReviewFail(" drupal_set_content('footer', 'Adding custom text to the footer');");
$this
->assertCoderReviewFail(' $content = drupal_get_content();');
$this
->assertCoderReviewFail(" function foo () {\n set_time_limit(100);\n}");
$this
->assertCoderReviewPass(" function drupal_set_time_limit () {\n set_time_limit(100);\n}");
$this
->assertCoderReviewPass(" function foo () {\n drupal_set_time_limit(100);\n}");
$this
->assertCoderReviewFail(" function mymodule_search() {\n ");
$this
->assertCoderReviewPass(" function mymodule_search_info() {\n ");
$this
->assertCoderReviewFail(' drupal_urlencode($url);');
$this
->assertCoderReviewPass(' drupal_encode_path($url);');
$this
->assertCoderReviewFail(" watchdog('test', 'my message', array(), WATCHDOG_EMERG);");
$this
->assertCoderReviewFail(" watchdog('test', 'my message', array(),WATCHDOG_EMERG);");
$this
->assertCoderReviewPass(" watchdog('test', 'my message', array(), WATCHDOG_EMERGENCY);");
}
function testPermissions7x() {
$this
->assertCoderReviewFail(" function mymodule_permission() {\n return array('administer mymodule');\n }");
$this
->assertCoderReviewFail(" function mymodule_permission() {\n return array('administer mymodule', 'access foo');\n }");
$this
->assertCoderReviewPass(" function mymodule_permission() {\n return array('administer mymodule' => array('title' => t('Administer mymodule'), 'description' => t('foo')));\n }");
$this
->assertCoderReviewPass(' db_query("SELECT * FROM {role_permission}");');
$this
->assertCoderReviewFail(' db_query("SELECT * FROM {permission}");');
$this
->assertCoderReviewFail(' db_query("DELETE FROM {permission}");');
$this
->assertCoderReviewFail(" function mymodule_perm() {\n}");
$this
->assertCoderReviewPass(" function mymodule_permission() {\n}");
$this
->assertCoderReviewFail(" \$permission = 'use PHP for block visibility';");
$this
->assertCoderReviewFail(' $permission = "use PHP for block visibility";');
$this
->assertCoderReviewFail(" return array('use PHP for block visibility');");
$this
->assertCoderReviewFail(" function mymodule_access() {\n}");
$this
->assertCoderReviewPass(" function mymodule_node_access() {\n}");
}
function testDatabase7x() {
$this
->assertCoderReviewFail(" function mymodule_schema() {\n \$schema['table'] = array(\n 'description' => t('My table description.'));\n}");
$this
->assertCoderReviewFail(" function mymodule_schema() {\n \$schema['table'] = array(\n 'description' => st('My table description.'));\n}");
$this
->assertCoderReviewFail(" function mymodule_schema() {\n \$schema['table'] = array(\n 'fields' => array('nid' => array('description' => t('My field description.'))));\n}");
$this
->assertCoderReviewFail(" function mymodule_schema() {\n \$schema['table'] = array(\n 'fields' => array('nid' => array('description' => st('My field description.'))));\n}");
$this
->assertCoderReviewPass(" function mymodule_schema() {\n \$schema['table'] = array(\n 'description' => 'My table description.');\n}");
$this
->assertCoderReviewPass(" function mymodule_schema() {\n \$schema['table'] = array(\n 'fields' => array('nid' => array('description' => 'My field description.')));\n}");
$this
->assertCoderReviewFail(" function mymodule_update_123() {\n \$schema['table'] = array(\n 'description' => st('My table description.'));\n}");
$this
->assertCoderReviewFail(" function mymodule_update_123() {\n \$schema['table'] = array(\n 'fields' => array('nid' => array('description' => t('My field description.'))));\n}");
$this
->assertCoderReviewFail(' $sql = db_rewrite_sql("SELECT n.nid FROM {node}");');
$this
->assertCoderReviewFail(" function mymodule_schema() {\n \$schema['table'] = array(\n 'description' => 'My table <a href=\"foo.html\">foo</a> description.');\n}");
$this
->assertCoderReviewFail(" function mymodule_schema() {\n \$schema['table'] = array(\n 'fields' => array('nid' => array('description' => 'My field <a href=\"foo.html\">foo</a> description.')));\n}");
$this
->assertCoderReviewPass(" function mymodule_schema() {\n \$schema['table'] = array(\n 'description' => 'My table <a href=\"foo.html\">foo</a> description.');\n}");
$this
->assertCoderReviewPass(" function mymodule_schema() {\n \$schema['table'] = array(\n 'fields' => array('nid' => array('description' => 'My field <a href=\"foo.html\">foo</a> description.')));\n}");
$this
->assertCoderReviewFail(" function mymodule_update_123() {\n \$schema['table'] = array(\n 'description' => 'My table <a href=\"foo.html\">foo</a> description.');\n}");
$this
->assertCoderReviewFail(" function mymodule_update_123() {\n \$schema['table'] = array(\n 'fields' => array('nid' => array('description' => 'My field <a href=\"foo.html\">foo</a> description.')));\n}");
$this
->assertCoderReviewFail(" db_query( 'SELECT COUNT (*) FROM {users}')");
}
function testMenu7x() {
$this
->assertCoderReviewFail(' function mymodule_menu_link_alter(&$item, $menu)');
$this
->assertCoderReviewPass(' function mymodule_menu_link_alter(&$item)');
}
function testBlock7x() {
$this
->assertCoderReviewFail(" function mymodule_block(\$op, \$delta, \$edit) {\n}");
$this
->assertCoderReviewFail(" function mymodule_block(\$op, \$delta, \$edit) {\n if (\$op == 'list') {\n }\n}");
$this
->assertCoderReviewFail(" function mymodule_block(\$op, \$delta, \$edit) {\n switch (\$op) {\n case 'list':\n }\n}");
}
function testComments7x() {
$this
->assertCoderReviewFail(' $comment = _comment_load($cid);');
$this
->assertCoderReviewFail(' if (_comment_load($cid))');
$this
->assertCoderReviewPass(' $comment = comment_load($cid);');
$this
->assertCoderReviewPass(' if (comment_load($cid))');
$this
->assertCoderReviewFail(" function mymodule_menu() {\n\$items['foo/%_comment'] = array();\n}");
$this
->assertCoderReviewFail(" function mymodule_menu_alter() {\n\$items['foo/%_comment'] = array();\n}");
$this
->assertCoderReviewPass(" function mymodule_menu() {\n\$items['foo/%comment'] = array();\n}");
$this
->assertCoderReviewPass(" function mymodule_menu_alter() {\n\$items['foo/%comment'] = array();\n}");
$this
->assertCoderReviewPass(" \$foo = 'foo/%_comment';");
$this
->assertCoderReviewFail(' db_query(\'SELECT cid FROM {comments} WHERE status = 0\');');
$this
->assertCoderReviewFail(' db_query(\'SELECT cid FROM {comments} WHERE status != 0\');');
$this
->assertCoderReviewFail(' db_query(\'SELECT cid FROM {comments} WHERE status <> 0\');');
$this
->assertCoderReviewPass(' db_query(\'SELECT cid FROM {comments} WHERE status = :status\', array(\':status\' => COMMENT_NOT_PUBLISHED));');
$this
->assertCoderReviewPass(' db_query(\'SELECT cid FROM {my_comments} WHERE status = 0\');');
$this
->assertCoderReviewFail(' comment_validate();');
$this
->assertCoderReviewFail(' if (comment_validate())');
$this
->assertCoderReviewFail(' comment_node_url();');
$this
->assertCoderReviewFail(' if (comment_node_url())');
}
function testInput7x() {
$this
->assertCoderReviewFail(' check_markup($body, $format, $check);');
$this
->assertCoderReviewFail(' check_markup($body, $format, FALSE);');
$this
->assertCoderReviewFail(' check_markup($body, $format, TRUE);');
$this
->assertCoderReviewPass(' check_markup($body, $format, $langcode);');
$this
->assertCoderReviewPass(' check_markup($body, $format, "en");');
$this
->assertCoderReviewPass(' check_markup($body, $format, $langcode, FALSE);');
$this
->assertCoderReviewPass(' check_markup($body, $format);');
$this
->assertCoderReviewFail(' drupal_set_title(check_plain($text));');
$this
->assertCoderReviewPass(' drupal_set_title($text);');
$this
->assertCoderReviewFail(' drupal_set_title(t("%test"));');
$this
->assertCoderReviewFail(' drupal_set_title(t("@test"));');
$this
->assertCoderReviewFail(' drupal_set_title(t("foo %test"));');
$this
->assertCoderReviewFail(' drupal_set_title(t("foo @test"));');
$this
->assertCoderReviewPass(' drupal_set_title(t("test @ 10"));');
$this
->assertCoderReviewPass(' drupal_set_title(t("test 10% foo"));');
$this
->assertCoderReviewPass(' drupal_set_title(t("%test"), PASS_THROUGH);');
$this
->assertCoderReviewPass(' drupal_set_title(t("@test"), PASS_THROUGH);');
$this
->assertCoderReviewPass(' drupal_set_title(t("test"));');
$this
->assertCoderReviewFail(' function mymodule_filter($op, $delta = 0, $format = -1, $text = \'\')');
$this
->assertCoderReviewFail(' function mymodule_filter_tips($delta, $format, $long = FALSE)');
$this
->assertCoderReviewPass(' function mymodule_filter_info()');
$this
->assertCoderReviewFail(' $form[\'format\'] = filter_form($edit[\'format\']);');
$this
->assertCoderReviewFail(' $form[\'comment\'][\'filter\'] = filter_form(FILTER_FORMAT_DEFAULT);');
$this
->assertCoderReviewPass(' $format = filter_form();');
$this
->assertCoderReviewFail(' $url = url("admin/settings/filters");');
$this
->assertCoderReviewFail(' $url = url("admin/settings/filters/add");');
$this
->assertCoderReviewPass(' $url = url("admin/settings/filter");');
$this
->assertCoderReviewPass(' $url = url("admin/settings/filter/add");');
}
function testTaxonomy7x() {
$this
->assertCoderReviewFail(' $tree = taxonomy_get_tree($vid, $parent, $depth);');
$this
->assertCoderReviewFail(' $tree = taxonomy_get_tree($vid, $parent, $depth, $max_depth);');
$this
->assertCoderReviewFail(' $tree = taxonomy_get_tree($vid, $parent, -1);');
$this
->assertCoderReviewFail(' $tree = taxonomy_get_tree($vid, $parent, -1, $max_depth);');
$this
->assertCoderReviewPass(' $tree = taxonomy_get_tree($vid, $parent, $max_depth);');
$this
->assertCoderReviewFail(' db_query("SELECT * FROM {term_data}")');
$this
->assertCoderReviewFail(' db_query("SELECT * FROM {term_hierarchy}")');
$this
->assertCoderReviewFail(' db_query("SELECT * FROM {term_node}")');
$this
->assertCoderReviewFail(' db_query("SELECT * FROM {term_relation}")');
$this
->assertCoderReviewFail(' db_query("SELECT * FROM {term_synonym}")');
$this
->assertCoderReviewFail(' db_query("SELECT * FROM {vocabulary}")');
$this
->assertCoderReviewFail(' db_query("SELECT * FROM {vocabulary_node_types}")');
$this
->assertCoderReviewFail(' taxonomy_get_term($tid);');
$this
->assertCoderReviewPass(' mytaxonomy_get_term($tid);');
$this
->assertCoderReviewFail(' taxonomy_save_term($term);');
$this
->assertCoderReviewPass(' mytaxonomy_save_term($term);');
$this
->assertCoderReviewFail(' taxonomy_term_save(array(\'tid\' => 123));');
$this
->assertCoderReviewFail(' taxonomy_del_term($tid);');
$this
->assertCoderReviewPass(' mytaxonomy_del_term($tid);');
$this
->assertCoderReviewFail(' taxonomy_save_vocabulary($vocab);');
$this
->assertCoderReviewPass(' mytaxonomy_save_vocabulary($vocab);');
$this
->assertCoderReviewFail(' taxonomy_vocabulary_save(array(\'tid\' => 123));');
$this
->assertCoderReviewFail(' taxonomy_del_vocabulary($vocab);');
$this
->assertCoderReviewPass(' mytaxonomy_del_vocabulary($vocab);');
$this
->assertCoderReviewPass(' $url = url("taxonomy/term/123");');
$this
->assertCoderReviewFail(' $url = url("taxonomy/term/1+2+3");');
$this
->assertCoderReviewFail(' $url = url("taxonomy/term/1,2,3");');
$this
->assertCoderReviewFail(' $url = url("taxonomy/term/123/0");');
$this
->assertCoderReviewFail(' $url = url("taxonomy/term/1+2+3/0");');
$this
->assertCoderReviewFail(' $url = url("taxonomy/term/1,2,3/0");');
$this
->assertCoderReviewFail(' $related = taxonomy_get_related($tid);');
}
function testJavascript7x() {
$this
->assertCoderReviewFail(" drupal_add_js(\$data, 'module');");
$this
->assertCoderReviewPass(" drupal_add_js(\$data, 'file');");
$this
->assertCoderReviewFail(" drupal_add_js(\$data, 'file', 'header');");
$this
->assertCoderReviewFail(" drupal_add_js(\$data, 'file', \$header, \$defer);");
$this
->assertCoderReviewPass(" drupal_add_js(\$jquery_plugin, array('weight' => JS_LIBRARY));");
$this
->assertCoderReviewPass(" function mytheme_preprocess_page(&\$variables) {\n \$scripts = \$variables['myscripts'];\n}");
$this
->assertCoderReviewFail(" function mytheme_preprocess_page(&\$variables) {\n \$scripts = \$variables['scripts'];\n}");
$this
->assertCoderReviewPass(' drupal_add_html_head("foo");');
$this
->assertCoderReviewFail(' drupal_add_html_head(\'<script type="text/javascript" src="foo.js"/>\');');
$this
->assertCoderReviewFail(' drupal_add_html_head(\'<script src="foo.js">\');');
$this
->assertCoderReviewFail(' drupal_add_html_head(\'<script src="http://example.com/foo.js">\');');
$this
->assertCoderReviewFail(' drupal_add_html_head(\'<script src="/files/foo.js">\');');
$this
->assertCoderReviewFail(' drupal_add_html_head(\'<script src="http://example123-ab_c.com.js">\');');
}
function testCss7x() {
$this
->assertCoderReviewPass(" drupal_add_css(\$data, 'module');");
$this
->assertCoderReviewFail(" drupal_add_css(\$data, 'module', 'all');");
$this
->assertCoderReviewFail(" drupal_add_css(\$data, 'module', \$media);");
}
function testTheming7x() {
$this
->assertCoderReviewFail(' drupal_rebuild_theme_registry();');
$this
->assertCoderReviewFail(" return theme('page');");
$this
->assertCoderReviewFail(' function mymodule_footer()');
$this
->assertCoderReviewFail(' function mymodule_footer($main = 0)');
$this
->assertCoderReviewFail(' function mymodule_footer()');
$this
->assertCoderReviewFail(' function mytheme_closure()');
$this
->assertCoderReviewFail(' function mytheme_closure($main = 0)');
$this
->assertCoderReviewFail(" return theme('closure');");
}
function testForm7x() {
$this
->assertCoderReviewFail(" function mymodule_form_alter(&\$form, &\$form_state, \$form_id) {\n if (isset(\$form['type']) && isset(\$form['#node']) && \$form['type']['#value'] .'_node_form' == \$form_id)");
$this
->assertCoderReviewFail(" function mymodule_form_alter(&\$form, &\$form_state, \$form_id) {\n if (\$form['type']['#value'] .'_node_form' == \$form_id)");
$this
->assertCoderReviewFail(" function mymodule_form_alter(&\$form, \$form_state, \$form_id)");
$this
->assertCoderReviewPass(" function mymodule_form_alter(&\$form, &\$form_state, \$form_id)");
$this
->assertCoderReviewFail(' $form = array("#process" => "expand_password_confirm");');
$this
->assertCoderReviewFail(' $form["#process"] = "expand_password_confirm";');
$this
->assertCoderReviewFail(' $form["#process"] = "expand_date";');
$this
->assertCoderReviewFail(' $form["#process"] = "expand_radios";');
$this
->assertCoderReviewFail(' $form["#process"] = "form_expand_ahah";');
$this
->assertCoderReviewFail(' $form["#process"] = "expand_checkboxes";');
$this
->assertCoderReviewFail(' $form["#process"] = "process_weight";');
$this
->assertCoderReviewFail(' drupal_execute();');
$this
->assertCoderReviewFail(' if (drupal_execute())');
$this
->assertCoderReviewFail(' $form["#ahah"] = "foo";');
$this
->assertCoderReviewFail(" \$form['#ahah'] = 'foo';");
}
function testFile7x() {
$this
->assertCoderReviewPass(' file_scan_directory($dir, $mask);');
$this
->assertCoderReviewPass(' file_scan_directory($dir, $mask, $options, $depth);');
$this
->assertCoderReviewFail(' file_scan_directory($dir, $mask, $options, $callback, $recurse, $key, $min_depth, $depth);');
$this
->assertCoderReviewFail(' file_scan_directory($dir, $mask, $nomask);');
$this
->assertCoderReviewFail(" file_scan_directory(\$dir, \$mask, array('.', '..', 'CVS'));");
$this
->assertCoderReviewFail(" file_scan_directory(\$dir, \$mask, array('nomask' => array('.', '..', 'CVS')));");
$this
->assertCoderReviewFail(' file_set_status($file, FILE_STATUS_PERMANENT);');
$this
->assertCoderReviewPass(' myfile_set_status($file, FILE_STATUS_PERMANENT);');
$this
->assertCoderReviewFail(' $file->status = FILE_STATUS_TEMPORARY;');
$this
->assertCoderReviewPass(" file_scan_directory(\$dir, '/\\.module\$/');");
$this
->assertCoderReviewFail(" file_scan_directory(\$dir, '\\.module\$');");
$this
->assertCoderReviewPass(" \$files = drupal_system_listing('/\\.module\$/', 'modules', 'name', 0);");
$this
->assertCoderReviewFail(" \$files = drupal_system_listing('\\.module\$', 'modules', 'name', 0);");
}
function testUser7x() {
$this
->assertCoderReviewFail(' user_delete($edit, $uid);');
$this
->assertCoderReviewPass(' foo_user_delete($edit, $uid);');
$this
->assertCoderReviewPass(' function foo_user_delete($edit, $uid)');
$this
->assertCoderReviewFail(" function mymodule_user(\$op");
$this
->assertCoderReviewFail(" function mymodule_user(\$type, \$edit\\, &\$account");
$this
->assertCoderReviewFail(" function mymodule_comment(&\$ai, \$op)");
$this
->assertCoderReviewFail(' drupal_goto(\'logout\');');
$this
->assertCoderReviewPass(" drupal_goto('user/logout');");
$this
->assertCoderReviewFail(' $form_state[\'redirect\'] = \'logout\';');
$this
->assertCoderReviewFail(' l(\'my text\', \'logout\');');
$this
->assertCoderReviewFail(' l(t(\'my text\'), \'logout\');');
$this
->assertCoderReviewFail(' l($text, \'logout\');');
$this
->assertCoderReviewPass(" \$form_state['redirect'] = 'user/logout';");
$this
->assertCoderReviewPass(" l('my text', 'user/logout');");
$this
->assertCoderReviewPass(" l(t('my text'), 'user/logout');");
$this
->assertCoderReviewPass(" l(\$text, 'user/logout');");
$this
->assertCoderReviewPass(' user_load($uid);');
$this
->assertCoderReviewFail(' $user = user_load((array) $uid);');
$this
->assertCoderReviewFail(' $user = user_load(array(123));');
$this
->assertCoderReviewPass(' user_authenticate($username, $password);');
$this
->assertCoderReviewFail(' user_authenticate(&$form_state);');
$this
->assertCoderReviewFail(' function mymodule_profile_alter(');
}
function testNode7x() {
$this
->assertCoderReviewFail(' db_query("SELECT * FROM {node_revisions}");');
$this
->assertCoderReviewFail(" function mymodule_link('node', \$node, \$teaser) {\n}");
$this
->assertCoderReviewFail(" function mymodule_link('taxonomy terms', \$node, \$teaser) {\n}");
$this
->assertCoderReviewFail(" function mymodule_link(\$type, \$node, \$teaser) {\n}");
$this
->assertCoderReviewPass(" function mymodule_link(\$type, \$comment, \$teaser) {\n}");
$this
->assertCoderReviewPass(" function mymodule_link('comment', \$comment, \$teaser) {\n}");
$this
->assertCoderReviewFail(' node_load($param);');
$this
->assertCoderReviewFail(' node_load($param, $vid);');
$this
->assertCoderReviewFail(' node_load(array("nid" => 1), $vid);');
$this
->assertCoderReviewPass(' node_load($nid);');
$this
->assertCoderReviewPass(' node_load($nid, $vid);');
$this
->assertCoderReviewPass(' node_load($nid, $vid, TRUE);');
$this
->assertCoderReviewPass(' node_load(123);');
$this
->assertCoderReviewFail(" function mymodule_node_info() {\n return array('blog' => array('name' => t('Blog entry'), 'module' => 'blog'));\n}");
$this
->assertCoderReviewPass(" function mymodule_node_info() {\n return array('blog' => array('name' => t('Blog entry'), 'base' => 'blog'));\n}");
$this
->assertCoderReviewPass(" function mymodule_node_info() {\n return array('blog' => array('name' => t('Blog entry, module'), 'base' => 'blog'));\n}");
$this
->assertCoderReviewFail(" function mymodule_node_info() {\n return array('blog' => array('name' => t('Blog entry'), 'base' => 'node'));\n}");
$this
->assertCoderReviewPass(" function mymodule_node_info() {\n return array('blog' => array('name' => t('Blog entry'), 'base' => 'node_content'));\n}");
$this
->assertCoderReviewFail(" function mymodule_nodeapi(&\$node, \$op, \$teaser, \$page) {\n}");
$this
->assertCoderReviewFail(" function mymodule_nodeapi(&\$node, \$teaser, \$page) {\n if (\$op == 'list') {\n }\n}");
$this
->assertCoderReviewFail(" function mymodule_nodeapi(&\$node, \$teaser, \$page) {\n switch (\$op) {\n case 'list':\n }\n}");
$this
->assertCoderReviewPass(' module_invoke_all("node_" . $hook, $node);');
$this
->assertCoderReviewFail(' node_invoke_nodeapi($node, $hook);');
$this
->assertCoderReviewFail(' node_get_types($op);');
$this
->assertCoderReviewFail(' node_get_types(\'types\');');
$this
->assertCoderReviewFail(' $build_mode = NODE_BUILD_PREVIEW;');
$this
->assertCoderReviewFail(' $node->build_mode = 2;');
$this
->assertCoderReviewFail(" function mymodule_nodeapi_foo(&\$node, \$teaser, \$page)");
$this
->assertCoderReviewPass(" function mymodule_node_foo(&\$node, \$teaser, \$page)");
}
function testMultilingual7x() {
$this
->assertCoderReviewFail(" t('Welcome to our site', array(), 'de');");
$this
->assertCoderReviewFail(' t("Welcome to our site", array(), "de");');
$this
->assertCoderReviewFail(" t('Welcome to our site', array('!code' => \$code, '!foo' => \$foo), 'de');");
$this
->assertCoderReviewPass(" t('Welcome to our site');");
$this
->assertCoderReviewPass(" t('Welcome to our site', array());");
$this
->assertCoderReviewPass(" t('Welcome to our site', array('!code' => \$code, '!foo' => \$foo));");
$this
->assertCoderReviewPass(" t('Welcome to our site', array(), array('langcode' => 'de'));");
$this
->assertCoderReviewPass(" t('Welcome to our site', array('!code' => \$code, '!foo' => \$foo), array('langcode' => 'de'));");
$this
->assertCoderReviewPass(" t('!user, welcome to our site', array('!user' => theme('username', \$user)), array('langcode' => 'de'));");
$this
->assertCoderReviewFail(" format_plural(\$count, '1 comment', '@count comments', array(), 'de');");
$this
->assertCoderReviewPass(" format_plural(\$count, '1 comment', '@count comments', array(), array('langcode' => 'de'));");
}
function testMisc7x() {
$this
->assertCoderReviewFail(' $toc = book_toc($bid, array(), 9);');
$this
->assertCoderReviewFail(' $toc = book_toc($bid, array());');
$this
->assertCoderReviewFail(' $toc = book_toc($bid, $foo, 9);');
$this
->assertCoderReviewPass(' $toc = book_toc($bid, 9);');
$this
->assertCoderReviewPass(' $toc = book_toc($bid, 9, array());');
$this
->assertCoderReviewPass(' $toc = book_toc($bid, 9, $foo);');
$this
->assertCoderReviewFail(' $referer = referer_uri();');
$this
->assertCoderReviewFail(' if (referer_uri())');
$this
->assertCoderReviewPass(' $referer = foo_referer_uri();');
$this
->assertCoderReviewFail(' $clone = drupal_clone($node);');
$this
->assertCoderReviewFail(' if (drupal_clone($node))');
$this
->assertCoderReviewPass(' $clone = clone $node;');
$this
->assertCoderReviewPass(' $clone = foo_drupal_clone($node);');
$this
->assertCoderReviewFail(' node_invoke_nodeapi($node, $hook);');
$this
->assertCoderReviewFail(' actions_synchronize($actions_in_code);');
$this
->assertCoderReviewFail(' actions_synchronize($foo, $delete_orphans);');
$this
->assertCoderReviewPass(' actions_synchronize($delete_orphans);');
}
}