You are here

function CoderReviewUpgrade7xTest::testSystem7x in Coder 7.2

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

???

File

coder_review/tests/coder_review_7x.test, line 64

Class

CoderReviewUpgrade7xTest
???

Code

function testSystem7x() {

  // N/A - http://drupal.org/node/224333#variable_get_default_null
  // N/A - http://drupal.org/node/224333#hook_modules_action
  // N/A - http://drupal.org/node/224333#static_variable_api
  // N/A - http://drupal.org/node/224333#archive-tar
  // N/A - http://drupal.org/node/224333#user-1
  // N/A - http://drupal.org/node/224333#hook_module_implements_alter
  // N/A - http://drupal.org/node/224333#drupal_static_advanced
  // N/A - http://drupal.org/node/224333#hook_update_index
  // http://drupal.org/node/224333#module_implements_not_module_list
  $this
    ->assertCoderReviewFail("  foreach (module_list() as \$module) {\n  module_invoke(\$module, 'foo');\n}");
  $this
    ->assertCoderReviewPass("  foreach (module_list() as \$module) {\n  print 'foo';\n}");

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

  // http://drupal.org/node/224333#time
  $this
    ->assertCoderReviewFail('  $time = time();');
  $this
    ->assertCoderReviewFail('  $time = foo(time());');
  $this
    ->assertCoderReviewPass('  $time = foo_time();');

  // http://drupal.org/node/224333#rebuild-functions
  $this
    ->assertCoderReviewFail('  drupal_rebuild_code_registry();');

  // http://drupal.org/node/224333#drupal_uninstall_modules
  $this
    ->assertCoderReviewFail('  drupal_uninstall_module("foo");');
  $this
    ->assertCoderReviewPass('  drupal_uninstall_modules(array("foo"));');

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

  // http://drupal.org/node/224333#moved_statistics_settings
  $this
    ->assertCoderReviewFail('  $path = "admin/reports/settings";');
  $this
    ->assertCoderReviewFail("  \$path = 'admin/reports/settings';");
  $this
    ->assertCoderReviewFail('  $path = "URL is admin/reports/settings.";');

  // http://drupal.org/node/224333#system_get_module_data
  $this
    ->assertCoderReviewFail('  module_rebuild_cache();');
  $this
    ->assertCoderReviewFail('  system_theme_data();');

  // http://drupal.org/node/224333#drupal_set_html_head
  $this
    ->assertCoderReviewFail('  drupal_set_html_head($data);');

  // http://drupal.org/node/224333#php_eval
  $this
    ->assertCoderReviewFail('  drupal_eval(\'<?php print "Hello"; ?>\');');

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

  // http://drupal.org/node/224333#drupal_set_content
  $this
    ->assertCoderReviewFail("  drupal_set_content('footer', 'Adding custom text to the footer');");
  $this
    ->assertCoderReviewFail('  $content = drupal_get_content();');

  // NO TESTS - http://drupal.org/node/224333#cache_implementation
  // Can't implement tests because it's reviewed by a review callback, which
  // needs physical files.
  // http://drupal.org/node/224333#time_limit
  $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}");

  // http://drupal.org/node/224333#search-api
  $this
    ->assertCoderReviewFail("  function mymodule_search() {\n  ");
  $this
    ->assertCoderReviewPass("  function mymodule_search_info() {\n  ");

  // http://drupal.org/node/224333#drupal_alter
  // http://drupal.org/node/224333#new_hook_hook_info
  // http://drupal.org/node/224333#email-html
  // http://drupal.org/node/224333#remove-drupal-urlencode
  $this
    ->assertCoderReviewFail('  drupal_urlencode($url);');
  $this
    ->assertCoderReviewPass('  drupal_encode_path($url);');

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

  // http://drupal.org/node/224333#system_retrieve_file
}