You are here

class BasicAuthTest in Zircon Profile 8

Same name in this branch
  1. 8 vendor/behat/mink/driver-testsuite/tests/Basic/BasicAuthTest.php \Behat\Mink\Tests\Driver\Basic\BasicAuthTest
  2. 8 core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php \Drupal\basic_auth\Tests\Authentication\BasicAuthTest
Same name and namespace in other branches
  1. 8.0 vendor/behat/mink/driver-testsuite/tests/Basic/BasicAuthTest.php \Behat\Mink\Tests\Driver\Basic\BasicAuthTest

Hierarchy

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

Expanded class hierarchy of BasicAuthTest

File

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

Namespace

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

  /**
   * @dataProvider setBasicAuthDataProvider
   */
  public function testSetBasicAuth($user, $pass, $pageText) {
    $session = $this
      ->getSession();
    $session
      ->setBasicAuth($user, $pass);
    $session
      ->visit($this
      ->pathTo('/basic_auth.php'));
    $this
      ->assertContains($pageText, $session
      ->getPage()
      ->getContent());
  }
  public function setBasicAuthDataProvider() {
    return array(
      array(
        'mink-user',
        'mink-password',
        'is authenticated',
      ),
      array(
        '',
        '',
        'is not authenticated',
      ),
    );
  }
  public function testResetBasicAuth() {
    $session = $this
      ->getSession();
    $session
      ->setBasicAuth('mink-user', 'mink-password');
    $session
      ->visit($this
      ->pathTo('/basic_auth.php'));
    $this
      ->assertContains('is authenticated', $session
      ->getPage()
      ->getContent());
    $session
      ->setBasicAuth(false);
    $session
      ->visit($this
      ->pathTo('/headers.php'));
    $this
      ->assertNotContains('PHP_AUTH_USER', $session
      ->getPage()
      ->getContent());
  }
  public function testResetWithBasicAuth() {
    $session = $this
      ->getSession();
    $session
      ->setBasicAuth('mink-user', 'mink-password');
    $session
      ->visit($this
      ->pathTo('/basic_auth.php'));
    $this
      ->assertContains('is authenticated', $session
      ->getPage()
      ->getContent());
    $session
      ->reset();
    $session
      ->visit($this
      ->pathTo('/headers.php'));
    $this
      ->assertNotContains('PHP_AUTH_USER', $session
      ->getPage()
      ->getContent());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BasicAuthTest::setBasicAuthDataProvider public function
BasicAuthTest::testResetBasicAuth public function
BasicAuthTest::testResetWithBasicAuth public function
BasicAuthTest::testSetBasicAuth public function @dataProvider setBasicAuthDataProvider
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