You are here

class HeaderTest in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/behat/mink/driver-testsuite/tests/Basic/HeaderTest.php \Behat\Mink\Tests\Driver\Basic\HeaderTest

Hierarchy

  • class \Behat\Mink\Tests\Driver\TestCase extends \Behat\Mink\Tests\Driver\PHPUnit_Framework_TestCase

Expanded class hierarchy of HeaderTest

File

vendor/behat/mink/driver-testsuite/tests/Basic/HeaderTest.php, line 7

Namespace

Behat\Mink\Tests\Driver\Basic
View source
class HeaderTest extends TestCase {

  /**
   * test referrer.
   *
   * @group issue130
   */
  public function testIssue130() {
    $this
      ->getSession()
      ->visit($this
      ->pathTo('/issue130.php?p=1'));
    $page = $this
      ->getSession()
      ->getPage();
    $page
      ->clickLink('Go to 2');
    $this
      ->assertEquals($this
      ->pathTo('/issue130.php?p=1'), $page
      ->getText());
  }
  public function testHeaders() {
    $this
      ->getSession()
      ->setRequestHeader('Accept-Language', 'fr');
    $this
      ->getSession()
      ->visit($this
      ->pathTo('/headers.php'));
    $this
      ->assertContains('[HTTP_ACCEPT_LANGUAGE] => fr', $this
      ->getSession()
      ->getPage()
      ->getContent());
  }
  public function testSetUserAgent() {
    $session = $this
      ->getSession();
    $session
      ->setRequestHeader('user-agent', 'foo bar');
    $session
      ->visit($this
      ->pathTo('/headers.php'));
    $this
      ->assertContains('[HTTP_USER_AGENT] => foo bar', $session
      ->getPage()
      ->getContent());
  }
  public function testResetHeaders() {
    $session = $this
      ->getSession();
    $session
      ->setRequestHeader('X-Mink-Test', 'test');
    $session
      ->visit($this
      ->pathTo('/headers.php'));
    $this
      ->assertContains('[HTTP_X_MINK_TEST] => test', $session
      ->getPage()
      ->getContent(), 'The custom header should be sent', true);
    $session
      ->reset();
    $session
      ->visit($this
      ->pathTo('/headers.php'));
    $this
      ->assertNotContains('[HTTP_X_MINK_TEST] => test', $session
      ->getPage()
      ->getContent(), 'The custom header should not be sent after resetting', true);
  }
  public function testResponseHeaders() {
    $this
      ->getSession()
      ->visit($this
      ->pathTo('/response_headers.php'));
    $headers = $this
      ->getSession()
      ->getResponseHeaders();
    $lowercasedHeaders = array();
    foreach ($headers as $name => $value) {
      $lowercasedHeaders[str_replace('_', '-', strtolower($name))] = $value;
    }
    $this
      ->assertArrayHasKey('x-mink-test', $lowercasedHeaders);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
HeaderTest::testHeaders public function
HeaderTest::testIssue130 public function test referrer.
HeaderTest::testResetHeaders public function
HeaderTest::testResponseHeaders public function
HeaderTest::testSetUserAgent public function
TestCase::$config private static property
TestCase::$mink private static property Mink session manager.
TestCase::checkRequirements protected function
TestCase::createDriver protected function Creates a new driver instance.
TestCase::findById protected function
TestCase::getAssertSession protected function Returns assert session.
TestCase::getConfig private static function
TestCase::getSession protected function Returns session.
TestCase::mapRemoteFilePath protected function Map remote file path.
TestCase::onNotSuccessfulTest protected function
TestCase::pathTo protected function
TestCase::safePageWait protected function Waits for a condition to be true, considering than it is successful for drivers not supporting wait().
TestCase::setUpBeforeClass public static function Initializes the test case.
TestCase::tearDown protected function