TestCase.php in Zircon Profile 8.0
File
vendor/behat/mink/driver-testsuite/tests/TestCase.php
View source
<?php
namespace Behat\Mink\Tests\Driver;
use Behat\Mink\Exception\UnsupportedDriverActionException;
use Behat\Mink\Mink;
use Behat\Mink\Session;
use Behat\Mink\WebAssert;
abstract class TestCase extends \PHPUnit_Framework_TestCase {
private static $mink;
private static $config;
public static function setUpBeforeClass() {
if (null === self::$mink) {
$session = new Session(self::getConfig()
->createDriver());
self::$mink = new Mink(array(
'sess' => $session,
));
}
}
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);
}
protected function getSession() {
return self::$mink
->getSession('sess');
}
protected function getAssertSession() {
return self::$mink
->assertSession('sess');
}
protected function findById($id) {
return $this
->getAssertSession()
->elementExists('named', array(
'id',
$id,
));
}
protected function createDriver() {
return self::getConfig()
->createDriver();
}
protected function mapRemoteFilePath($file) {
$realPath = realpath($file);
if (false !== $realPath) {
$file = $realPath;
}
return self::getConfig()
->mapRemoteFilePath($file);
}
protected function pathTo($path) {
return rtrim(self::getConfig()
->getWebFixturesUrl(), '/') . '/' . ltrim($path, '/');
}
protected function safePageWait($time, $condition) {
try {
return $this
->getSession()
->wait($time, $condition);
} catch (UnsupportedDriverActionException $e) {
return true;
}
}
}