You are here

function CoderReviewUpgrade7xTest::testNode7x in Coder 7

Same name and namespace in other branches
  1. 7.2 coder_review/tests/coder_review_7x.test \CoderReviewUpgrade7xTest::testNode7x()

File

coder_review/tests/coder_review_7x.test, line 556

Class

CoderReviewUpgrade7xTest

Code

function testNode7x() {

  // N/A - http://drupal.org/node/224333#delete_multiple
  // N/A - http://drupal.org/node/224333#specified_ids
  // No link - node_revisions table name changed.
  $this
    ->assertCoderReviewFail('  db_query("SELECT * FROM {node_revisions}");');

  // http://drupal.org/node/224333#node_links
  $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}");

  // http://drupal.org/node/224333#node_load_multiple
  $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);');

  // http://drupal.org/node/224333#node_type_base
  $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}");

  // http://drupal.org/node/224333#remove_op
  $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}");

  // http://drupal.org/node/224333#node_invoke_nodeapi
  $this
    ->assertCoderReviewPass('  module_invoke_all("node_" . $hook, $node);');
  $this
    ->assertCoderReviewFail('  node_invoke_nodeapi($node, $hook);');

  // N/A - http://drupal.org/node/224333#node_build_rss : covered by
  // hook_nodeapi() removal.
  // http://drupal.org/node/224333#node_type_get_functions
  $this
    ->assertCoderReviewFail('  node_get_types($op);');
  $this
    ->assertCoderReviewFail('  node_get_types(\'types\');');

  // http://drupal.org/node/224333#build_mode
  $this
    ->assertCoderReviewFail('  $build_mode = NODE_BUILD_PREVIEW;');
  $this
    ->assertCoderReviewFail('  $node->build_mode = 2;');

  // http://drupal.org/node/224333#hook_node_xxx
  $this
    ->assertCoderReviewFail("  function mymodule_nodeapi_foo(&\$node, \$teaser, \$page)");
  $this
    ->assertCoderReviewPass("  function mymodule_node_foo(&\$node, \$teaser, \$page)");
}