/[drupal]/contributions/modules/simpletest_automator/simpletest_automator.module
ViewVC logotype

Diff of /contributions/modules/simpletest_automator/simpletest_automator.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.42, Thu Aug 21 03:45:17 2008 UTC revision 1.43, Thu Aug 28 06:41:42 2008 UTC
# Line 75  function simpletest_automator_delete($sa Line 75  function simpletest_automator_delete($sa
75    db_query('DELETE FROM {simpletest_automator_actions} WHERE said = %d', $said);    db_query('DELETE FROM {simpletest_automator_actions} WHERE said = %d', $said);
76    return TRUE;    return TRUE;
77  }  }
78    db_query('DELETE FROM {simpletest_automator_actions} WHERE (1 + 1 = 2)');
79  /**  /**
80   * API function: load a simpletest automator action.   * API function: load a simpletest automator action.
81   *   *
# Line 106  function simpletest_automator_action_loa Line 106  function simpletest_automator_action_loa
106        $arguments[] = $said;        $arguments[] = $said;
107      }      }
108      if (!empty($where)) {      if (!empty($where)) {
109        $result = db_query('SELECT * FROM {simpletest_automator_actions} WHERE '. implode($where, ' AND ') .' ORDER BY weight', $arguments);        $result = db_query('SELECT * FROM {simpletest_automator_actions} WHERE '. implode($where, ' AND ') .' ORDER BY weight ASC, aid ASC', $arguments);
110      }      }
111      else {      else {
112        $said_cache[0] = array();        $said_cache[0] = array();
# Line 268  function simpletest_automator_menu() { Line 268  function simpletest_automator_menu() {
268    );    );
269    $items['admin/build/simpletest_automator/%simpletest_automator/record'] = array(    $items['admin/build/simpletest_automator/%simpletest_automator/record'] = array(
270      'title' => 'Record',      'title' => 'Record',
271      'page callback' => 'simpletest_automator_admin_record',      'page arguments' => array('simpletest_automator_admin_record', 3),
     'page arguments' => array(3),  
272      'weight' => 5,      'weight' => 5,
273      'load arguments' => array(TRUE),      'load arguments' => array(TRUE),
274      'type' => MENU_LOCAL_TASK,      'type' => MENU_LOCAL_TASK,
# Line 351  function simpletest_automator_simpletest Line 350  function simpletest_automator_simpletest
350        return array(        return array(
351          'assert_text' => t('Make sure text appears'),          'assert_text' => t('Make sure text appears'),
352          'click_link' => t('Click on a link'),          'click_link' => t('Click on a link'),
353            'drupal_get' => t('Make an HTTP GET request'),
354            'drupal_post' => t('Make an HTTP POST request'),
355        );        );
356    
357      case 'description':      case 'description':
# Line 391  function _simpletest_automator_describe_ Line 392  function _simpletest_automator_describe_
392        else {        else {
393          return t('This will look at all the text on the current page, and make sure that the text %text does <strong>not</strong> appear.', array('%text' => $action->parameters['text']));          return t('This will look at all the text on the current page, and make sure that the text %text does <strong>not</strong> appear.', array('%text' => $action->parameters['text']));
394        }        }
395    
396        case 'drupal_get':
397          return t('This will make a GET request to the %page page.', array('%page' => $action->parameters['url']));
398    
399        case 'drupal_post':
400          return t('This will submit the form at the @page page.', array('@page' => $action->parameters['url']));
401    }    }
402  }  }
403    
# Line 434  function _simpletest_automator_export_ac Line 441  function _simpletest_automator_export_ac
441          'arguments' => array($action->parameters['text']),          'arguments' => array($action->parameters['text']),
442        );        );
443        break;        break;
444    
445        case 'drupal_get':
446          $lines[] = array(
447            'value' => '$this->drupalGet(%s);',
448            'arguments' => array($action->parameters['url']),
449          );
450          break;
451    
452        case 'drupal_post':
453          $lines[] = '$edit = array();';
454          foreach ($action->parameters['post'] as $name => $value) {
455            $lines[] = array(
456              'value' => '$edit[%s] = %s;',
457              'arguments' => array($name, $value),
458            );
459          }
460          $lines[] = array(
461            'value' => '$this->drupalPost(%s, $edit, t(%s));',
462            'arguments' => array($action->parameters['url'], $action->parameters['operation']),
463          );
464          break;
465    
466    }    }
467    return $lines;    return $lines;
468  }  }
# Line 455  function _simpletest_automator_action_fo Line 484  function _simpletest_automator_action_fo
484          '#type' => 'textfield',          '#type' => 'textfield',
485          '#title' => t('Label'),          '#title' => t('Label'),
486          '#description' => t('The label of the link to click'),          '#description' => t('The label of the link to click'),
487            '#required' => TRUE,
488          '#default_value' => isset($action->parameters['label']) ? $action->parameters['label'] : '',          '#default_value' => isset($action->parameters['label']) ? $action->parameters['label'] : '',
489        );        );
490        $form['index'] = array(        $form['index'] = array(
# Line 471  function _simpletest_automator_action_fo Line 501  function _simpletest_automator_action_fo
501          '#type' => 'textarea',          '#type' => 'textarea',
502          '#title' => t('Text'),          '#title' => t('Text'),
503          '#description' => t('The text to check for. This should not contain any HTML unless the "Text is HTML" option is selected below.'),          '#description' => t('The text to check for. This should not contain any HTML unless the "Text is HTML" option is selected below.'),
504            '#required' => TRUE,
505          '#default_value' => isset($action->parameters['text']) ? $action->parameters['text'] : '',          '#default_value' => isset($action->parameters['text']) ? $action->parameters['text'] : '',
506        );        );
507    
# Line 487  function _simpletest_automator_action_fo Line 518  function _simpletest_automator_action_fo
518          '#description' => t('If checked, it will cause the code to check whether the raw HTML matches, rather than simply the visible text.'),          '#description' => t('If checked, it will cause the code to check whether the raw HTML matches, rather than simply the visible text.'),
519          '#default_value' => isset($action->parameters['should_appear']) ? $action->parameters['should_appear'] : FALSE,          '#default_value' => isset($action->parameters['should_appear']) ? $action->parameters['should_appear'] : FALSE,
520        );        );
521          break;
522    
523        case 'drupal_get':
524          $form['url'] = array(
525            '#type' => 'textfield',
526            '#title' => t('URL'),
527            '#required' => TRUE,
528            '#description' => t('Enter the URL to make a GET request to. Should be relative to the drupal install, without the ?q=.'),
529            '#default_value' => isset($action->parameters['url']) ? $action->parameters['url'] : '',
530          );
531          break;
532    
533        case 'drupal_post':
534          $form['url'] = array(
535            '#type' => 'textfield',
536            '#title' => t('URL'),
537            '#required' => TRUE,
538            '#description' => t('Enter the URL to make a POST request to. Should be relative to the drupal install, without the ?q=.'),
539            '#default_value' => isset($action->parameters['url']) ? $action->parameters['url'] : '',
540          );
541    
542          // @TODO
543          $form['post'] = array(
544            '#type' => 'value',
545            '#value' => isset($action->parameters['post']) ? $action->parameters['post'] : array(),
546          );
547    
548          $form['operation'] = array(
549            '#type' => 'textfield',
550            '#title' => t('Operation'),
551            '#required' => TRUE,
552            '#description' => t('Enter the name of the submit button to simulate being pressed.'),
553            '#default_value' => isset($action->parameters['operation']) ? $action->parameters['operation'] : '',
554          );
555          break;
556    }    }
557    return $form;    return $form;
558  }  }

Legend:
Removed from v.1.42  
changed lines
  Added in v.1.43

  ViewVC Help
Powered by ViewVC 1.1.2