Commit 35ff7005 authored by webchick's avatar webchick

#600032 by c960657: Removed browser.inc. Please see...

#600032 by c960657: Removed browser.inc. Please see http://drupal.org/project/browser if you'd like to help with a more fleshed-out abstract browser for possible inclusion in D8.
parent 74722b8a
This diff is collapsed.
......@@ -15,7 +15,6 @@ files[] = tests/actions.test
files[] = tests/ajax.test
files[] = tests/batch.test
files[] = tests/bootstrap.test
files[] = tests/browser.test
files[] = tests/cache.test
files[] = tests/common.test
files[] = tests/database_test.test
......
<?php
// $Id$
/**
* @file
* Tests for the internal web browser.
*/
/**
* Test general browser functionality.
*/
class BrowserTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Browser',
'description' => 'Test general browser functionality.',
'group' => 'Browser',
);
}
public function setUp() {
parent::setUp('browser_test');
}
/**
* Test general browser functionality.
*/
public function testBrowserBackend() {
global $db_prefix;
$browser = new Browser();
$browser->setUserAgent(drupal_generate_test_ua($db_prefix));
// Check browser refresh, both meta tag and HTTP header.
$request = $browser->get(url('browser_test/refresh/meta', array('absolute' => TRUE)));
$this->assertEqual($request['content'], 'Refresh successful', 'Meta refresh successful ($request)');
$this->assertEqual($browser->getContent(), 'Refresh successful', 'Meta refresh successful ($browser)');
$request = $browser->get(url('browser_test/refresh/header', array('absolute' => TRUE)));
$this->assertEqual($request['content'], 'Refresh successful', 'Meta refresh successful ($request)');
$this->assertEqual($browser->getContent(), 'Refresh successful', 'Meta refresh successful ($browser)');
}
}
/**
* Test browser backend wrappers.
*/
class BrowserBackendTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Browser - wrapper backends',
'description' => 'Test stream and curl backends execution of GET and POST requests.',
'group' => 'Browser',
);
}
public function setUp() {
parent::setUp('browser_test');
}
/**
* Test stream and curl backends execution of GET and POST requests.
*/
public function testBrowserBackend() {
global $db_prefix;
foreach (array('stream', 'curl') as $wrapper) {
$browser = new Browser($wrapper == 'stream');
$browser->setUserAgent(drupal_generate_test_ua($db_prefix));
$string = $this->randomName();
$edit = array(
'foo' => $string,
);
// Test GET method.
$request = $browser->get(url('browser_test/print/get', array('absolute' => TRUE, 'query' => $edit)));
$this->assertEqual($string, $request['content'], t('String found during GET request ($request)'), $wrapper);
$this->assertEqual($string, $browser->getContent(), t('String found during GET request ($browser)'), $wrapper);
// Test POST method.
$request = $browser->post(url('browser_test/print/post', array('absolute' => TRUE)), $edit, t('Submit'));
$this->assertEqual($string, $request['content'], t('String found during POST request ($request)'), $wrapper);
$this->assertEqual($string, $browser->getContent(), t('String found during POST request ($browser)'), $wrapper);
}
}
}
/**
* Test browser page manipulation functionality.
*/
class BrowserPageTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Browser - page',
'description' => 'Check "BrowserPage" class functionality.',
'group' => 'Browser',
);
}
public function setUp() {
parent::setUp('browser_test');
}
/**
* Check "BrowserPage" class functionality.
*/
public function testBrowserPage() {
global $db_prefix;
$browser = new Browser();
$browser->setUserAgent(drupal_generate_test_ua($db_prefix));
$browser->get(url('browser_test/print/post', array('absolute' => TRUE)));
$page = $browser->getPage();
$input = $page->xpath('//input[@name="foo"]');
$input = $input[0];
$this->assertEqual('foo', $input['name'], t('Field "foo" found'));
}
}
; $Id$
name = Browser test
description = Provide various pages for testing the browser.
package = Testing
version = VERSION
core = 7.x
files[] = browser_test.module
hidden = TRUE
<?php
// $Id$
/**
* @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')));
$element = array(
'#tag' => 'meta',
'#attributes' => array(
'http-equiv' => 'Refresh',
'content' => '0; URL=' . $url,
),
);
drupal_add_html_head($element, 'browser_test_refresh_meta');
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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment