Test the internal browsers functionality.
function testInternalBrowser() {
global $conf;
if (!$this
->inCURL()) {
// Retrieve the test page and check its title and headers.
$this
->drupalGet('test-page');
$this
->assertTrue($this
->drupalGetHeader('Date'), 'An HTTP header was received.');
$this
->assertTitle(t('Test page | @site-name', array(
'@site-name' => config('system.site')
->get('name'),
)));
$this
->assertNoTitle('Foo');
global $base_url;
$this
->drupalGet(url($base_url . '/core/install.php', array(
'external' => TRUE,
'absolute' => TRUE,
)));
$this
->assertResponse(403, 'Cannot access install.php.');
$user = $this
->drupalCreateUser();
$this
->drupalLogin($user);
$headers = $this
->drupalGetHeaders(TRUE);
$this
->assertEqual(count($headers), 2, 'There was one intermediate request.');
$this
->assertTrue(strpos($headers[0][':status'], '302') !== FALSE, 'Intermediate response code was 302.');
$this
->assertFalse(empty($headers[0]['location']), 'Intermediate request contained a Location header.');
$this
->assertEqual($this
->getUrl(), $headers[0]['location'], 'HTTP redirect was followed');
$this
->assertFalse($this
->drupalGetHeader('Location'), 'Headers from intermediate request were reset.');
$this
->assertResponse(200, 'Response code from intermediate request was reset.');
// Test the maximum redirection option.
$this
->drupalLogout();
$edit = array(
'name' => $user->name,
'pass' => $user->pass_raw,
);
$this->maximumRedirects = 1;
$this
->drupalPost('user', $edit, t('Log in'), array(
'query' => array(
'destination' => 'user/logout',
),
));
$headers = $this
->drupalGetHeaders(TRUE);
$this
->assertEqual(count($headers), 2, 'Simpletest stopped following redirects after the first one.');
}
}