You are here

abstract class TestCase in Zircon Profile 8

Same name in this branch
  1. 8 vendor/masterminds/html5/test/HTML5/TestCase.php \Masterminds\HTML5\Tests\TestCase
  2. 8 vendor/behat/mink/driver-testsuite/tests/TestCase.php \Behat\Mink\Tests\Driver\TestCase
  3. 8 vendor/composer/installers/tests/Composer/Installers/Test/TestCase.php \Composer\Installers\Test\TestCase
Same name and namespace in other branches
  1. 8.0 vendor/behat/mink/driver-testsuite/tests/TestCase.php \Behat\Mink\Tests\Driver\TestCase

Hierarchy

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

Expanded class hierarchy of TestCase

23 files declare their use of TestCase
BasicAuthTest.php in vendor/behat/mink/driver-testsuite/tests/Basic/BasicAuthTest.php
BestPracticesTest.php in vendor/behat/mink/driver-testsuite/tests/Basic/BestPracticesTest.php
ChangeEventTest.php in vendor/behat/mink/driver-testsuite/tests/Js/ChangeEventTest.php
CheckboxTest.php in vendor/behat/mink/driver-testsuite/tests/Form/CheckboxTest.php
ContentTest.php in vendor/behat/mink/driver-testsuite/tests/Basic/ContentTest.php

... See full list

1 string reference to 'TestCase'
Util_TestDox_NamePrettifierTest::testCaterForUserDefinedSuffix in vendor/phpunit/phpunit/tests/Util/TestDox/NamePrettifierTest.php
@covers PHPUnit_Util_TestDox_NamePrettifier::prettifyTestClass

File

vendor/behat/mink/driver-testsuite/tests/TestCase.php, line 10

Namespace

Behat\Mink\Tests\Driver
View source
abstract class TestCase extends \PHPUnit_Framework_TestCase {

  /**
   * Mink session manager.
   *
   * @var Mink
   */
  private static $mink;

  /**
   * @var AbstractConfig
   */
  private static $config;

  /**
   * Initializes the test case.
   */
  public static function setUpBeforeClass() {
    if (null === self::$mink) {
      $session = new Session(self::getConfig()
        ->createDriver());
      self::$mink = new Mink(array(
        'sess' => $session,
      ));
    }
  }

  /**
   * @return AbstractConfig
   *
   * @throws \UnexpectedValueException if the global driver_config_factory returns an invalid object
   */
  private static function getConfig() {
    if (null === self::$config) {
      self::$config = call_user_func($GLOBALS['driver_config_factory']);
      if (!self::$config instanceof AbstractConfig) {
        throw new \UnexpectedValueException('The "driver_config_factory" global variable must return a \\Behat\\Mink\\Tests\\Driver\\AbstractConfig.');
      }
    }
    return self::$config;
  }
  protected function checkRequirements() {
    if (null !== ($message = self::getConfig()
      ->skipMessage(get_class($this), $this
      ->getName(false)))) {
      $this
        ->markTestSkipped($message);
    }
    parent::checkRequirements();
  }
  protected function tearDown() {
    if (null !== self::$mink) {
      self::$mink
        ->resetSessions();
    }
  }
  protected function onNotSuccessfulTest(\Exception $e) {
    if ($e instanceof UnsupportedDriverActionException) {
      $this
        ->markTestSkipped($e
        ->getMessage());
    }
    parent::onNotSuccessfulTest($e);
  }

  /**
   * Returns session.
   *
   * @return Session
   */
  protected function getSession() {
    return self::$mink
      ->getSession('sess');
  }

  /**
   * Returns assert session.
   *
   * @return WebAssert
   */
  protected function getAssertSession() {
    return self::$mink
      ->assertSession('sess');
  }

  /**
   * @param string $id
   *
   * @return \Behat\Mink\Element\NodeElement
   */
  protected function findById($id) {
    return $this
      ->getAssertSession()
      ->elementExists('named', array(
      'id',
      $id,
    ));
  }

  /**
   * Creates a new driver instance.
   *
   * This driver is not associated to a session. It is meant to be used for tests on the driver
   * implementation itself rather than test using the Mink API.
   *
   * @return \Behat\Mink\Driver\DriverInterface
   */
  protected function createDriver() {
    return self::getConfig()
      ->createDriver();
  }

  /**
   * Map remote file path.
   *
   * @param string $file File path.
   *
   * @return string
   */
  protected function mapRemoteFilePath($file) {
    $realPath = realpath($file);
    if (false !== $realPath) {
      $file = $realPath;
    }
    return self::getConfig()
      ->mapRemoteFilePath($file);
  }

  /**
   * @param string $path
   *
   * @return string
   */
  protected function pathTo($path) {
    return rtrim(self::getConfig()
      ->getWebFixturesUrl(), '/') . '/' . ltrim($path, '/');
  }

  /**
   * Waits for a condition to be true, considering than it is successful for drivers not supporting wait().
   *
   * @param int    $time
   * @param string $condition A JS condition to evaluate
   *
   * @return bool
   *
   * @see \Behat\Mink\Session::wait()
   */
  protected function safePageWait($time, $condition) {
    try {
      return $this
        ->getSession()
        ->wait($time, $condition);
    } catch (UnsupportedDriverActionException $e) {
      return true;
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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