You are here

browser_test.module in SimpleTest 7

Provide various pages for testing the internal browser.

File

tests/browser_test.module
View source
<?php

/**
 * @file
 * Provide various pages for testing the internal browser.
 */

/**
 * Implement hook_menu().
 */
function browser_test_menu() {
  $items['browser_test/print/get'] = array(
    'page callback' => 'browser_test_print_get',
    'access arguments' => array(
      'access content',
    ),
  );
  $items['browser_test/print/post'] = array(
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'browser_test_print_post_form',
    ),
    'access arguments' => array(
      'access content',
    ),
  );
  $items['browser_test/refresh/meta'] = array(
    'page callback' => 'browser_test_refresh_meta',
    'access arguments' => array(
      'access content',
    ),
  );
  $items['browser_test/refresh/header'] = array(
    'page callback' => 'browser_test_refresh_header',
    'access arguments' => array(
      'access content',
    ),
  );
  return $items;
}
function browser_test_print_get() {
  echo $_GET['foo'];
  exit;
}
function browser_test_print_post_form($form, &$form_state) {
  $form['foo'] = array(
    '#type' => 'textfield',
  );
  $form['op'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}
function browser_test_print_post_form_submit($form, &$form_state) {
  echo $form_state['values']['foo'];
  exit;
}
function browser_test_refresh_meta() {
  if (!isset($_GET['refresh'])) {
    $url = url('browser_test/refresh/meta', array(
      'absolute' => TRUE,
      'query' => array(
        'refresh' => 'true',
      ),
    ));
    drupal_add_html_head('<meta http-equiv="Refresh" content="0; URL=' . $url . '">');
    return '';
  }
  echo 'Refresh successful';
  exit;
}
function browser_test_refresh_header() {
  if (!isset($_GET['refresh'])) {
    $url = url('browser_test/refresh/header', array(
      'absolute' => TRUE,
      'query' => array(
        'refresh' => 'true',
      ),
    ));
    drupal_add_http_header('Location', $url);
    return '';
  }
  echo 'Refresh successful';
  exit;
}