1 simpletest.test SimpleTestFunctionalTest::testInternalBrowser()

Test the internal browsers functionality.


core/modules/simpletest/tests/simpletest.test, line 37
Tests for simpletest.module.




function testInternalBrowser() {
  if (!$this->inCURL()) {
    $this->assertTrue($this->backdropGetHeader('Date'), 'An HTTP header was received.');
    $this->assertTitle(t('Welcome to @site-name | @site-name', array('@site-name' => config_get('system.core', 'site_name'))), 'Site title matches.');
    $this->assertNoTitle('Foo', 'Site title does not match.');
    // Make sure that we are locked out of the installer when prefixing
    // using the user-agent header. This is an important security check.
    global $base_url;

    $this->backdropGet($base_url . '/core/install.php', array('external' => TRUE));
    $this->assertResponse(403, 'Cannot access install.php with a "simpletest" user-agent header.');

    $user = $this->backdropCreateUser();
    $headers = $this->backdropGetHeaders(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->backdropGetHeader('Location'), 'Headers from intermediate request were reset.');
    $this->assertResponse(200, 'Response code from intermediate request was reset.');

    // Add login block to the default layout. Needed for the redirect loop.
    $layout = layout_load('default');
    $layout->addBlock('user', 'login', 'sidebar');

    // Test the maximum redirection option.
    $edit = array(
      'name' => $user->name,
      'pass' => $user->pass_raw
    $this->maximumRedirects = 1;
    $this->backdropPost('user?destination=user/logout', $edit, t('Log in'));
    $headers = $this->backdropGetHeaders(TRUE);
    $this->assertEqual(count($headers), 2, 'Simpletest stopped following redirects after the first one.');