You are here

function CoderUpgrade6xTest::testUpgrade6x in Coder 6

Same name and namespace in other branches
  1. 6.2 tests/coder_6x.test \CoderUpgrade6xTest::testUpgrade6x()

File

tests/coder_6x.test, line 17

Class

CoderUpgrade6xTest

Code

function testUpgrade6x() {
  $this
    ->assertCoderFail('  function my_module_forms($args) {');
  $this
    ->assertCoderPass('  function my_module_forms($form_id, $args) {');
  $this
    ->assertCoderPass('  drupal_retrieve_form(\'testform\', $form_state);');
  $this
    ->assertCoderFail('  drupal_retrieve_form(\'testform\');');
  $this
    ->assertCoderPass('  drupal_retrieve_form($form_id, $form_state);');
  $this
    ->assertCoderFail('  drupal_retrieve_form($form_id);');
  $this
    ->assertCoderPass('  form_set_value($element, \'value\', $form_state);');
  $this
    ->assertCoderFail('  form_set_value($element, \'value\');');
  $this
    ->assertCoderFail('  function myform_prerender($form_id, $form) {');
  $this
    ->assertCoderPass('  function myform_prerender($form) {');
  $this
    ->assertCoderFail('  function myform_validate($form_id, $form_values) {');
  $this
    ->assertCoderFail('  function myform_validate($form, $form_state) {');
  $this
    ->assertCoderPass('  function myform_validate($form, &$form_state) {');
  $this
    ->assertCoderFail('  function myform_submit($form_id, $form_values) {');
  $this
    ->assertCoderFail('  function myform_submit($form, $form_state) {');
  $this
    ->assertCoderPass('  function myform_submit($form, &$form_state) {');
  $this
    ->assertCoderFail("  function myform_submit(\$form, &\$form_state) {\n  return \$foo;\n}");
  $this
    ->assertCoderFail("  function myform_submit(\$form, &\$form_state) {\n  return 'my/path';\n}");
  $this
    ->assertCoderFail("  function myform_submit(\$form, &\$form_state) {\n \$form['#submit']['newsubmit'] = array();\n}");
  $this
    ->assertCoderPass("  function myform_submit(\$form, &\$form_state) {\n \$form['#submit'][] = 'newsubmit';\n}");
  $this
    ->assertCoderFail('  function mymodule_form_alter($form_id, &$form) {');
  $this
    ->assertCoderPass('  function mymodule_form_alter(&$form, $form_state, $form_id) {');
  $this
    ->assertCoderFail('  $op = $form_values[\'op\'];');
  $this
    ->assertCoderFail('  $op = $form[\'op\'];');
  $this
    ->assertCoderFail("  function myform_submit() {\n  \$a = \$form_values['foo'];\n}");
  $this
    ->assertCoderFail("  function myform_submit() {\n  \$a = \$form['foo'];\n}");
  $this
    ->assertCoderFail("  function myform_validate() {\n  \$a = \$form_values['foo'];\n}");
  $this
    ->assertCoderFail("  function myform_validate() {\n  \$a = \$form['foo'];\n}");
}