本文整理汇总了PHP中PHPUnit_Extensions_SeleniumTestCase类的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Extensions_SeleniumTestCase类的具体用法?PHP PHPUnit_Extensions_SeleniumTestCase怎么用?PHP PHPUnit_Extensions_SeleniumTestCase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PHPUnit_Extensions_SeleniumTestCase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDriver
/**
* @param array $browser
* @return PHPUnit_Extensions_SeleniumTestCase_Driver
* @since Method available since Release 3.3.0
*/
protected function getDriver(array $browser)
{
if (!empty(self::$browsers)) {
//...
} else {
if (self::driverInitialized()) {
$this->drivers[0] = self::$driver;
self::$driver->setTestCase($this);
} else {
self::$driver = parent::getDriver($browser);
}
return self::$driver;
}
}
示例2: handlePHPUnitConfiguration
/**
* Load and processes the PHPUnit configuration
*
* @param $configuration
*
* @throws BuildException
* @return array
*/
protected function handlePHPUnitConfiguration($configuration)
{
if (!$configuration->exists()) {
throw new BuildException("Unable to find PHPUnit configuration file '" . (string) $configuration . "'");
}
$config = PHPUnit_Util_Configuration::getInstance($configuration->getAbsolutePath());
if (empty($config)) {
return;
}
$phpunit = $config->getPHPUnitConfiguration();
if (empty($phpunit)) {
return;
}
$config->handlePHPConfiguration();
if (isset($phpunit['bootstrap'])) {
$this->setBootstrap($phpunit['bootstrap']);
}
if (isset($phpunit['stopOnFailure'])) {
$this->setHaltonfailure($phpunit['stopOnFailure']);
}
if (isset($phpunit['stopOnError'])) {
$this->setHaltonerror($phpunit['stopOnError']);
}
if (isset($phpunit['stopOnSkipped'])) {
$this->setHaltonskipped($phpunit['stopOnSkipped']);
}
if (isset($phpunit['stopOnIncomplete'])) {
$this->setHaltonincomplete($phpunit['stopOnIncomplete']);
}
if (isset($phpunit['processIsolation'])) {
$this->setProcessIsolation($phpunit['processIsolation']);
}
foreach ($config->getListenerConfiguration() as $listener) {
if (!class_exists($listener['class'], false) && $listener['file'] !== '') {
require_once $listener['file'];
}
if (class_exists($listener['class'])) {
if (count($listener['arguments']) == 0) {
$listener = new $listener['class']();
} else {
$listenerClass = new ReflectionClass($listener['class']);
$listener = $listenerClass->newInstanceArgs($listener['arguments']);
}
if ($listener instanceof PHPUnit_Framework_TestListener) {
$this->addListener($listener);
}
}
}
$browsers = $config->getSeleniumBrowserConfiguration();
if (!empty($browsers) && class_exists('PHPUnit_Extensions_SeleniumTestCase')) {
PHPUnit_Extensions_SeleniumTestCase::$browsers = $browsers;
}
return $phpunit;
}
示例3: handleArguments
//.........这里部分代码省略.........
$this->arguments['test'] = $this->options[1][0];
}
if (isset($this->options[1][1])) {
$this->arguments['testFile'] = realpath($this->options[1][1]);
} else {
$this->arguments['testFile'] = '';
}
if (isset($this->arguments['test']) && is_file($this->arguments['test']) && substr($this->arguments['test'], -5, 5) != '.phpt') {
$this->arguments['testFile'] = realpath($this->arguments['test']);
$this->arguments['test'] = substr($this->arguments['test'], 0, strrpos($this->arguments['test'], '.'));
}
}
if (!isset($this->arguments['testSuffixes'])) {
$this->arguments['testSuffixes'] = array('Test.php', '.phpt');
}
if (isset($includePath)) {
ini_set('include_path', $includePath . PATH_SEPARATOR . ini_get('include_path'));
}
if ($this->arguments['loader'] !== null) {
$this->arguments['loader'] = $this->handleLoader($this->arguments['loader']);
}
if (isset($this->arguments['configuration']) && is_dir($this->arguments['configuration'])) {
$configurationFile = $this->arguments['configuration'] . '/phpunit.xml';
if (file_exists($configurationFile)) {
$this->arguments['configuration'] = realpath($configurationFile);
} elseif (file_exists($configurationFile . '.dist')) {
$this->arguments['configuration'] = realpath($configurationFile . '.dist');
}
} elseif (!isset($this->arguments['configuration']) && $this->arguments['useDefaultConfiguration']) {
if (file_exists('phpunit.xml')) {
$this->arguments['configuration'] = realpath('phpunit.xml');
} elseif (file_exists('phpunit.xml.dist')) {
$this->arguments['configuration'] = realpath('phpunit.xml.dist');
}
}
if (isset($this->arguments['configuration'])) {
try {
$configuration = PHPUnit_Util_Configuration::getInstance($this->arguments['configuration']);
} catch (Exception $e) {
print $e->getMessage() . "\n";
exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
}
$phpunit = $configuration->getPHPUnitConfiguration();
$configuration->handlePHPConfiguration();
/**
* Issue #1216
*/
if (isset($this->arguments['bootstrap'])) {
$this->handleBootstrap($this->arguments['bootstrap']);
} elseif (isset($phpunit['bootstrap'])) {
$this->handleBootstrap($phpunit['bootstrap']);
}
/**
* Issue #657
*/
if (isset($phpunit['stderr']) && !isset($this->arguments['stderr'])) {
$this->arguments['stderr'] = $phpunit['stderr'];
}
if (isset($phpunit['printerClass'])) {
if (isset($phpunit['printerFile'])) {
$file = $phpunit['printerFile'];
} else {
$file = '';
}
$this->arguments['printer'] = $this->handlePrinter($phpunit['printerClass'], $file);
}
if (isset($phpunit['testSuiteLoaderClass'])) {
if (isset($phpunit['testSuiteLoaderFile'])) {
$file = $phpunit['testSuiteLoaderFile'];
} else {
$file = '';
}
$this->arguments['loader'] = $this->handleLoader($phpunit['testSuiteLoaderClass'], $file);
}
$browsers = $configuration->getSeleniumBrowserConfiguration();
if (!empty($browsers) && class_exists('PHPUnit_Extensions_SeleniumTestCase')) {
PHPUnit_Extensions_SeleniumTestCase::$browsers = $browsers;
}
if (!isset($this->arguments['test'])) {
$testSuite = $configuration->getTestSuiteConfiguration(isset($this->arguments['testsuite']) ? $this->arguments['testsuite'] : null);
if ($testSuite !== null) {
$this->arguments['test'] = $testSuite;
}
}
} elseif (isset($this->arguments['bootstrap'])) {
$this->handleBootstrap($this->arguments['bootstrap']);
}
if (isset($this->arguments['printer']) && is_string($this->arguments['printer'])) {
$this->arguments['printer'] = $this->handlePrinter($this->arguments['printer']);
}
if (isset($this->arguments['test']) && is_string($this->arguments['test']) && substr($this->arguments['test'], -5, 5) == '.phpt') {
$test = new PHPUnit_Extensions_PhptTestCase($this->arguments['test']);
$this->arguments['test'] = new PHPUnit_Framework_TestSuite();
$this->arguments['test']->addTest($test);
}
if (!isset($this->arguments['test']) || isset($this->arguments['testDatabaseLogRevision']) && !isset($this->arguments['testDatabaseDSN'])) {
$this->showHelp();
exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
}
}
示例4: handleArguments
//.........这里部分代码省略.........
$this->arguments['testFile'] = $this->options[1][1];
} else {
$this->arguments['testFile'] = '';
}
if (isset($this->arguments['test']) && is_file($this->arguments['test']) && substr($this->arguments['test'], -5, 5) != '.phpt') {
$this->arguments['testFile'] = realpath($this->arguments['test']);
$this->arguments['test'] = substr($this->arguments['test'], 0, strrpos($this->arguments['test'], '.'));
}
}
if (isset($includePath)) {
ini_set('include_path', $includePath . PATH_SEPARATOR . ini_get('include_path'));
}
if (isset($this->arguments['bootstrap'])) {
$this->handleBootstrap($this->arguments['bootstrap']);
}
if (isset($this->arguments['printer']) && is_string($this->arguments['printer'])) {
$this->arguments['printer'] = $this->handlePrinter($this->arguments['printer']);
}
if ($this->arguments['loader'] !== NULL) {
$this->arguments['loader'] = $this->handleLoader($this->arguments['loader']);
}
if (isset($this->arguments['configuration']) && is_dir($this->arguments['configuration'])) {
$configurationFile = $this->arguments['configuration'] . '/phpunit.xml';
if (file_exists($configurationFile)) {
$this->arguments['configuration'] = realpath($configurationFile);
} else {
if (file_exists($configurationFile . '.dist')) {
$this->arguments['configuration'] = realpath($configurationFile . '.dist');
}
}
} else {
if (!isset($this->arguments['configuration']) && $this->arguments['useDefaultConfiguration']) {
if (file_exists('phpunit.xml')) {
$this->arguments['configuration'] = realpath('phpunit.xml');
} else {
if (file_exists('phpunit.xml.dist')) {
$this->arguments['configuration'] = realpath('phpunit.xml.dist');
}
}
}
}
if (isset($this->arguments['configuration'])) {
try {
$configuration = PHPUnit_Util_Configuration::getInstance($this->arguments['configuration']);
} catch (Exception $e) {
print $e->getMessage() . "\n";
exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
}
$phpunit = $configuration->getPHPUnitConfiguration();
$configuration->handlePHPConfiguration();
if (!isset($this->arguments['bootstrap']) && isset($phpunit['bootstrap'])) {
$this->handleBootstrap($phpunit['bootstrap']);
}
if (isset($phpunit['printerClass'])) {
if (isset($phpunit['printerFile'])) {
$file = $phpunit['printerFile'];
} else {
$file = '';
}
$this->arguments['printer'] = $this->handlePrinter($phpunit['printerClass'], $file);
}
if (isset($phpunit['testSuiteLoaderClass'])) {
if (isset($phpunit['testSuiteLoaderFile'])) {
$file = $phpunit['testSuiteLoaderFile'];
} else {
$file = '';
}
$this->arguments['loader'] = $this->handleLoader($phpunit['testSuiteLoaderClass'], $file);
}
$logging = $configuration->getLoggingConfiguration();
if (isset($logging['coverage-html']) || isset($logging['coverage-clover']) || isset($logging['coverage-text'])) {
if (!extension_loaded('tokenizer')) {
$this->showExtensionNotLoadedMessage('tokenizer', 'No code coverage will be generated.');
} else {
if (!extension_loaded('Xdebug')) {
$this->showExtensionNotLoadedMessage('Xdebug', 'No code coverage will be generated.');
}
}
}
$browsers = $configuration->getSeleniumBrowserConfiguration();
if (!empty($browsers) && class_exists('PHPUnit_Extensions_SeleniumTestCase')) {
PHPUnit_Extensions_SeleniumTestCase::$browsers = $browsers;
}
if (!isset($this->arguments['test'])) {
$testSuite = $configuration->getTestSuiteConfiguration();
if ($testSuite !== NULL) {
$this->arguments['test'] = $testSuite;
}
}
}
if (isset($this->arguments['test']) && is_string($this->arguments['test']) && substr($this->arguments['test'], -5, 5) == '.phpt') {
$test = new PHPUnit_Extensions_PhptTestCase($this->arguments['test']);
$this->arguments['test'] = new PHPUnit_Framework_TestSuite();
$this->arguments['test']->addTest($test);
}
if (!isset($this->arguments['test']) || isset($this->arguments['testDatabaseLogRevision']) && !isset($this->arguments['testDatabaseDSN'])) {
$this->showHelp();
exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
}
}
示例5: assertMapConditions
/**
* Assert that all elements in $this->map are present on the page
*/
protected function assertMapConditions()
{
foreach ($this->map as $field => $locator) {
$this->se->assertTrue(
$this->se->isElementPresent($locator),
'Locator field "' . $field . '" is not present.');
}
}
示例6: setUp
/**
* Setup Shop - Set base url
* @return void
*/
protected function setUp()
{
if ($this->browserUrl !== null) {
$this->setBrowserUrl($this->browserUrl);
}
parent::setUp();
}
示例7: onNotSuccessfulTest
protected function onNotSuccessfulTest(Exception $e)
{
parent::onNotSuccessfulTest($e);
$path = $this->htmlSourcePath . DIRECTORY_SEPARATOR . $this->testId . '.html';
file_put_contents($path, $this->getHtmlSource());
echo 'Source: ', $path, PHP_EOL;
}
示例8: open
/**
* overload default method call and add some more actions,
* for example resizing window to maximum available space
*
* @param string $url url, which we want to open
* $return @inheritdoc
*/
protected function open($url)
{
$this->windowMaximize();
parent::open($url);
$this->windowMaximize();
$this->checkPageError();
}
示例9: prepareTestSession
protected function prepareTestSession()
{
$this->job_id = parent::prepareTestSession();
if ($this->build) {
SauceTestCommon::ReportBuild($this->job_id, $this->build);
}
$this->postSessionSetUp();
return $this->job_id;
}
示例10: setUp
/**
* setUp
*
* @access public
* @return void
*/
public function setUp()
{
// Import controller
//s Yii::import('application.controllers.*');
$this->setBrowser("*firefox");
parent::setUp();
//session_start();
$this->setBrowserUrl('http://localhost/story/index.php/');
}
示例11: array
/**
* Constructor
*
* @param null|string $name
* @param array $data
* @param string $dataName
* @param array $browser
* @return void
*/
function __construct($name = NULL, array $data = array(), $dataName = '', array $browser = array())
{
parent::__construct($name, $data, $dataName, $browser);
if (defined('CC_SELENIUM_OPT_CaptureScreenshotOnFailure')) {
$this->captureScreenshotOnFailure = CC_SELENIUM_OPT_CaptureScreenshotOnFailure;
$this->screenshotPath = CC_SELENIUM_OPT_ScreenshotPath;
$this->screenshotUrl = CC_SELENIUM_OPT_ScreenshotUrl;
}
$this->setBrowser("*firefox");
$this->setBrowserUrl(CC_SELENIUM_OPT_URL);
}
示例12: setUp
public function setUp()
{
foreach (new DirectoryIterator(Zend_Registry::get("datadir") . '/backup') as $file) {
if (!$file->isDot() && $file->isFile() && preg_match('/.json$/', $file->getFilename()) === 1) {
copy($file->getPathname(), Zend_Registry::get("datadir") . '/' . $file->getFilename());
try {
chmod(Zend_Registry::get("datadir") . '/' . $file->getFilename(), '0438');
} catch (Exception $e) {
}
}
}
$this->setBrowserUrl($this->bootstrap->getOption('url'));
parent::setUp();
}
示例13: array
/**
* Constructor
*
* Because we are overriding the parent class constructor, we
* need to show the same arguments as exist in the constructor of
* PHPUnit_Framework_TestCase, since
* PHPUnit_Framework_TestSuite::createTest() creates a
* ReflectionClass of the Test class and checks the constructor
* of that class to decide how to set up the test.
*
* @param string $name
* @param array $data
* @param string $dataName
*/
function __construct($name = NULL, array $data = array(), $dataName = '', array $browser = array())
{
parent::__construct($name, $data, $dataName, $browser);
$this->loggedInAs = NULL;
require_once 'CiviSeleniumSettings.php';
$this->settings = new CiviSeleniumSettings();
if (property_exists($this->settings, 'serverStartupTimeOut') && $this->settings->serverStartupTimeOut) {
global $CiviSeleniumTestCase_polled;
if (!$CiviSeleniumTestCase_polled) {
$CiviSeleniumTestCase_polled = TRUE;
CRM_Utils_Network::waitForServiceStartup($this->drivers[0]->getHost(), $this->drivers[0]->getPort(), $this->settings->serverStartupTimeOut);
}
}
// autoload
require_once 'CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();
// also initialize a connection to the db
// FIXME: not necessary for most tests, consider moving into functions that need this
$config = CRM_Core_Config::singleton();
}
示例14: setUp
protected function setUp()
{
parent::setUp();
require_once "{$_SERVER['KERNEL_DIR']}/AppKernel.php";
$this->kernel = new \AppKernel('test', true);
$this->kernel->boot();
$this->router = $this->kernel->getContainer()->get('router');
$this->router->getContext()->setHost($_SERVER['HTTP_HOST']);
$this->router->getContext()->setBaseUrl($_SERVER['SCRIPT_NAME']);
$this->setBrowserUrl("http://{$_SERVER['HTTP_HOST']}");
//$this->setSleep(1);
/*
$application = new Application($this->kernel);
$application->setAutoExit(false);
$application->run(new ArrayInput(array('command' => 'doctrine:schema:drop', '--force' => true)));
$application->run(new ArrayInput(array('command' => 'doctrine:schema:create')));
$application->run(new ArrayInput(array('command' => 'doctrine:data:load', '--fixtures' => 'src/Acme/PizzaBundle/DataFixtures/ORM/')));
$this->em = $this->kernel->getContainer()->get('doctrine')->getEntityManager();
*/
}
示例15: runTest
/**
* Run this test's scenario.
*
* @return mixed
* @throws RuntimeException
*/
protected function runTest()
{
$autostop = $this->autoStop;
$this->autoStop = FALSE;
try {
$testResult = parent::runTest();
$this->scenario->run($this->world);
$this->autoStop = $autostop;
} catch (Exception $e) {
$this->autoStop = $autostop;
throw $e;
}
return $testResult;
}