/**
  * 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.');
     }
 }
示例#2
0
 /**
  * Setup Shop - Set base url
  * @return void
  */
 protected function setUp()
 {
     if ($this->browserUrl !== null) {
         $this->setBrowserUrl($this->browserUrl);
     }
     parent::setUp();
 }
 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;
 }
 /**
  * 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();
 }
示例#5
0
 protected function prepareTestSession()
 {
     $this->job_id = parent::prepareTestSession();
     if ($this->build) {
         SauceTestCommon::ReportBuild($this->job_id, $this->build);
     }
     $this->postSessionSetUp();
     return $this->job_id;
 }
示例#6
0
 /**
  * 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/');
 }
 /**
  * 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);
 }
 /**
  * @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;
     }
 }
示例#9
0
 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();
 }
 /**
  *  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();
 }
 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();
     */
 }
 /**
  * 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;
 }
示例#13
0
 /**
  * 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;
 }
示例#14
0
 /**
  * Handles the command-line arguments.
  *
  * A child class of PHPUnit_TextUI_Command can hook into the argument
  * parsing by adding the switch(es) to the $longOptions array and point to a
  * callback method that handles the switch(es) in the child class like this
  *
  * <code>
  * <?php
  * class MyCommand extends PHPUnit_TextUI_Command
  * {
  *     public function __construct()
  *     {
  *         // my-switch won't accept a value, it's an on/off
  *         $this->longOptions['my-switch'] = 'myHandler';
  *         // my-secondswitch will accept a value - note the equals sign
  *         $this->longOptions['my-secondswitch='] = 'myOtherHandler';
  *     }
  *
  *     // --my-switch  -> myHandler()
  *     protected function myHandler()
  *     {
  *     }
  *
  *     // --my-secondswitch foo -> myOtherHandler('foo')
  *     protected function myOtherHandler ($value)
  *     {
  *     }
  *
  *     // You will also need this - the static keyword in the
  *     // PHPUnit_TextUI_Command will mean that it'll be
  *     // PHPUnit_TextUI_Command that gets instantiated,
  *     // not MyCommand
  *     public static function main($exit = true)
  *     {
  *         $command = new static;
  *
  *         return $command->run($_SERVER['argv'], $exit);
  *     }
  *
  * }
  * </code>
  *
  * @param array $argv
  */
 protected function handleArguments(array $argv)
 {
     if (defined('__PHPUNIT_PHAR__')) {
         $this->longOptions['selfupdate'] = null;
         $this->longOptions['self-update'] = null;
     }
     try {
         $this->options = PHPUnit_Util_Getopt::getopt($argv, 'd:c:hv', array_keys($this->longOptions));
     } catch (PHPUnit_Framework_Exception $e) {
         $this->showError($e->getMessage());
     }
     foreach ($this->options[0] as $option) {
         switch ($option[0]) {
             case '--colors':
                 $this->arguments['colors'] = true;
                 break;
             case '--bootstrap':
                 $this->arguments['bootstrap'] = $option[1];
                 break;
             case '--columns':
                 if (is_numeric($option[1])) {
                     $this->arguments['columns'] = (int) $option[1];
                 } elseif ($option[1] == 'max') {
                     $this->arguments['columns'] = 'max';
                 }
                 break;
             case 'c':
             case '--configuration':
                 $this->arguments['configuration'] = $option[1];
                 break;
             case '--coverage-clover':
                 $this->arguments['coverageClover'] = $option[1];
                 break;
             case '--coverage-crap4j':
                 $this->arguments['coverageCrap4J'] = $option[1];
                 break;
             case '--coverage-html':
                 $this->arguments['coverageHtml'] = $option[1];
                 break;
             case '--coverage-php':
                 $this->arguments['coveragePHP'] = $option[1];
                 break;
             case '--coverage-text':
                 if ($option[1] === null) {
                     $option[1] = 'php://stdout';
                 }
                 $this->arguments['coverageText'] = $option[1];
                 $this->arguments['coverageTextShowUncoveredFiles'] = false;
                 $this->arguments['coverageTextShowOnlySummary'] = false;
                 break;
             case '--coverage-xml':
                 $this->arguments['coverageXml'] = $option[1];
                 break;
             case 'd':
                 $ini = explode('=', $option[1]);
                 if (isset($ini[0])) {
                     if (isset($ini[1])) {
                         ini_set($ini[0], $ini[1]);
                     } else {
                         ini_set($ini[0], true);
                     }
                 }
                 break;
             case '--debug':
                 $this->arguments['debug'] = true;
                 break;
             case 'h':
             case '--help':
                 $this->showHelp();
                 exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
                 break;
             case '--filter':
                 $this->arguments['filter'] = $option[1];
                 break;
             case '--testsuite':
                 $this->arguments['testsuite'] = $option[1];
                 break;
             case '--group':
                 $this->arguments['groups'] = explode(',', $option[1]);
                 break;
             case '--exclude-group':
                 $this->arguments['excludeGroups'] = explode(',', $option[1]);
                 break;
             case '--test-suffix':
                 $this->arguments['testSuffixes'] = explode(',', $option[1]);
                 break;
             case '--include-path':
                 $includePath = $option[1];
                 break;
             case '--list-groups':
                 $this->arguments['listGroups'] = true;
                 break;
             case '--printer':
                 $this->arguments['printer'] = $option[1];
                 break;
             case '--loader':
                 $this->arguments['loader'] = $option[1];
                 break;
             case '--log-json':
                 $this->arguments['jsonLogfile'] = $option[1];
                 break;
             case '--log-junit':
                 $this->arguments['junitLogfile'] = $option[1];
                 break;
             case '--log-tap':
                 $this->arguments['tapLogfile'] = $option[1];
                 break;
             case '--process-isolation':
                 $this->arguments['processIsolation'] = true;
                 break;
             case '--repeat':
                 $this->arguments['repeat'] = (int) $option[1];
                 break;
             case '--stderr':
                 $this->arguments['stderr'] = true;
                 break;
             case '--stop-on-error':
                 $this->arguments['stopOnError'] = true;
                 break;
             case '--stop-on-failure':
                 $this->arguments['stopOnFailure'] = true;
                 break;
             case '--stop-on-incomplete':
                 $this->arguments['stopOnIncomplete'] = true;
                 break;
             case '--stop-on-risky':
                 $this->arguments['stopOnRisky'] = true;
                 break;
             case '--stop-on-skipped':
                 $this->arguments['stopOnSkipped'] = true;
                 break;
             case '--tap':
                 $this->arguments['printer'] = 'PHPUnit_Util_Log_TAP';
                 break;
             case '--testdox':
                 $this->arguments['printer'] = 'PHPUnit_Util_TestDox_ResultPrinter_Text';
                 break;
             case '--testdox-html':
                 $this->arguments['testdoxHTMLFile'] = $option[1];
                 break;
             case '--testdox-text':
                 $this->arguments['testdoxTextFile'] = $option[1];
                 break;
             case '--no-configuration':
                 $this->arguments['useDefaultConfiguration'] = false;
                 break;
             case '--no-globals-backup':
                 $this->arguments['backupGlobals'] = false;
                 break;
             case '--static-backup':
                 $this->arguments['backupStaticAttributes'] = true;
                 break;
             case 'v':
             case '--verbose':
                 $this->arguments['verbose'] = true;
                 break;
             case '--version':
                 $this->printVersionString();
                 exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
                 break;
             case '--report-useless-tests':
                 $this->arguments['reportUselessTests'] = true;
                 break;
             case '--strict-coverage':
                 $this->arguments['strictCoverage'] = true;
                 break;
             case '--disallow-test-output':
                 $this->arguments['disallowTestOutput'] = true;
                 break;
             case '--enforce-time-limit':
                 $this->arguments['enforceTimeLimit'] = true;
                 break;
             case '--disallow-todo-tests':
                 $this->arguments['disallowTodoAnnotatedTests'] = true;
                 break;
             case '--strict':
                 $this->arguments['reportUselessTests'] = true;
                 $this->arguments['strictCoverage'] = true;
                 $this->arguments['disallowTestOutput'] = true;
                 $this->arguments['enforceTimeLimit'] = true;
                 $this->arguments['disallowTodoAnnotatedTests'] = true;
                 $this->arguments['deprecatedStrictModeOption'] = true;
                 break;
             case '--selfupdate':
             case '--self-update':
                 $this->handleSelfUpdate();
                 break;
             default:
                 $optionName = str_replace('--', '', $option[0]);
                 if (isset($this->longOptions[$optionName])) {
                     $handler = $this->longOptions[$optionName];
                 } elseif (isset($this->longOptions[$optionName . '='])) {
                     $handler = $this->longOptions[$optionName . '='];
                 }
                 if (isset($handler) && is_callable(array($this, $handler))) {
                     $this->{$handler}($option[1]);
                 }
         }
     }
     $this->handleCustomTestSuite();
     if (!isset($this->arguments['test'])) {
         if (isset($this->options[1][0])) {
             $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);
     }
 }
示例#15
0
 /**
  * This method implements the Selenium RC protocol.
  *
  * @param  string $command
  * @param  array  $arguments
  * @return mixed
  * @method unknown  addLocationStrategy()
  * @method unknown  addLocationStrategyAndWait()
  * @method unknown  addScript()
  * @method unknown  addScriptAndWait()
  * @method unknown  addSelection()
  * @method unknown  addSelectionAndWait()
  * @method unknown  allowNativeXpath()
  * @method unknown  allowNativeXpathAndWait()
  * @method unknown  altKeyDown()
  * @method unknown  altKeyDownAndWait()
  * @method unknown  altKeyUp()
  * @method unknown  altKeyUpAndWait()
  * @method unknown  answerOnNextPrompt()
  * @method unknown  assignId()
  * @method unknown  assignIdAndWait()
  * @method unknown  attachFile()
  * @method unknown  break()
  * @method unknown  captureEntirePageScreenshot()
  * @method unknown  captureEntirePageScreenshotAndWait()
  * @method unknown  captureEntirePageScreenshotToStringAndWait()
  * @method unknown  captureScreenshotAndWait()
  * @method unknown  captureScreenshotToStringAndWait()
  * @method unknown  check()
  * @method unknown  checkAndWait()
  * @method unknown  chooseCancelOnNextConfirmation()
  * @method unknown  chooseCancelOnNextConfirmationAndWait()
  * @method unknown  chooseOkOnNextConfirmation()
  * @method unknown  chooseOkOnNextConfirmationAndWait()
  * @method unknown  click()
  * @method unknown  clickAndWait()
  * @method unknown  clickAt()
  * @method unknown  clickAtAndWait()
  * @method unknown  close()
  * @method unknown  contextMenu()
  * @method unknown  contextMenuAndWait()
  * @method unknown  contextMenuAt()
  * @method unknown  contextMenuAtAndWait()
  * @method unknown  controlKeyDown()
  * @method unknown  controlKeyDownAndWait()
  * @method unknown  controlKeyUp()
  * @method unknown  controlKeyUpAndWait()
  * @method unknown  createCookie()
  * @method unknown  createCookieAndWait()
  * @method unknown  deleteAllVisibleCookies()
  * @method unknown  deleteAllVisibleCookiesAndWait()
  * @method unknown  deleteCookie()
  * @method unknown  deleteCookieAndWait()
  * @method unknown  deselectPopUp()
  * @method unknown  deselectPopUpAndWait()
  * @method unknown  doubleClick()
  * @method unknown  doubleClickAndWait()
  * @method unknown  doubleClickAt()
  * @method unknown  doubleClickAtAndWait()
  * @method unknown  dragAndDrop()
  * @method unknown  dragAndDropAndWait()
  * @method unknown  dragAndDropToObject()
  * @method unknown  dragAndDropToObjectAndWait()
  * @method unknown  dragDrop()
  * @method unknown  dragDropAndWait()
  * @method unknown  echo()
  * @method unknown  fireEvent()
  * @method unknown  fireEventAndWait()
  * @method unknown  focus()
  * @method unknown  focusAndWait()
  * @method string   getAlert()
  * @method array    getAllButtons()
  * @method array    getAllFields()
  * @method array    getAllLinks()
  * @method array    getAllWindowIds()
  * @method array    getAllWindowNames()
  * @method array    getAllWindowTitles()
  * @method string   getAttribute()
  * @method array    getAttributeFromAllWindows()
  * @method string   getBodyText()
  * @method string   getConfirmation()
  * @method string   getCookie()
  * @method string   getCookieByName()
  * @method integer  getCursorPosition()
  * @method integer  getElementHeight()
  * @method integer  getElementIndex()
  * @method integer  getElementPositionLeft()
  * @method integer  getElementPositionTop()
  * @method integer  getElementWidth()
  * @method string   getEval()
  * @method string   getExpression()
  * @method string   getHtmlSource()
  * @method string   getLocation()
  * @method string   getLogMessages()
  * @method integer  getMouseSpeed()
  * @method string   getPrompt()
  * @method array    getSelectOptions()
  * @method string   getSelectedId()
  * @method array    getSelectedIds()
  * @method string   getSelectedIndex()
  * @method array    getSelectedIndexes()
  * @method string   getSelectedLabel()
  * @method array    getSelectedLabels()
  * @method string   getSelectedValue()
  * @method array    getSelectedValues()
  * @method unknown  getSpeed()
  * @method unknown  getSpeedAndWait()
  * @method string   getTable()
  * @method string   getText()
  * @method string   getTitle()
  * @method string   getValue()
  * @method boolean  getWhetherThisFrameMatchFrameExpression()
  * @method boolean  getWhetherThisWindowMatchWindowExpression()
  * @method integer  getXpathCount()
  * @method unknown  goBack()
  * @method unknown  goBackAndWait()
  * @method unknown  highlight()
  * @method unknown  highlightAndWait()
  * @method unknown  ignoreAttributesWithoutValue()
  * @method unknown  ignoreAttributesWithoutValueAndWait()
  * @method boolean  isAlertPresent()
  * @method boolean  isChecked()
  * @method boolean  isConfirmationPresent()
  * @method boolean  isCookiePresent()
  * @method boolean  isEditable()
  * @method boolean  isElementPresent()
  * @method boolean  isOrdered()
  * @method boolean  isPromptPresent()
  * @method boolean  isSomethingSelected()
  * @method boolean  isTextPresent()
  * @method boolean  isVisible()
  * @method unknown  keyDown()
  * @method unknown  keyDownAndWait()
  * @method unknown  keyDownNative()
  * @method unknown  keyDownNativeAndWait()
  * @method unknown  keyPress()
  * @method unknown  keyPressAndWait()
  * @method unknown  keyPressNative()
  * @method unknown  keyPressNativeAndWait()
  * @method unknown  keyUp()
  * @method unknown  keyUpAndWait()
  * @method unknown  keyUpNative()
  * @method unknown  keyUpNativeAndWait()
  * @method unknown  metaKeyDown()
  * @method unknown  metaKeyDownAndWait()
  * @method unknown  metaKeyUp()
  * @method unknown  metaKeyUpAndWait()
  * @method unknown  mouseDown()
  * @method unknown  mouseDownAndWait()
  * @method unknown  mouseDownAt()
  * @method unknown  mouseDownAtAndWait()
  * @method unknown  mouseMove()
  * @method unknown  mouseMoveAndWait()
  * @method unknown  mouseMoveAt()
  * @method unknown  mouseMoveAtAndWait()
  * @method unknown  mouseOut()
  * @method unknown  mouseOutAndWait()
  * @method unknown  mouseOver()
  * @method unknown  mouseOverAndWait()
  * @method unknown  mouseUp()
  * @method unknown  mouseUpAndWait()
  * @method unknown  mouseUpAt()
  * @method unknown  mouseUpAtAndWait()
  * @method unknown  mouseUpRight()
  * @method unknown  mouseUpRightAndWait()
  * @method unknown  mouseUpRightAt()
  * @method unknown  mouseUpRightAtAndWait()
  * @method unknown  open()
  * @method unknown  openWindow()
  * @method unknown  openWindowAndWait()
  * @method unknown  pause()
  * @method unknown  refresh()
  * @method unknown  refreshAndWait()
  * @method unknown  removeAllSelections()
  * @method unknown  removeAllSelectionsAndWait()
  * @method unknown  removeScript()
  * @method unknown  removeScriptAndWait()
  * @method unknown  removeSelection()
  * @method unknown  removeSelectionAndWait()
  * @method unknown  retrieveLastRemoteControlLogs()
  * @method unknown  rollup()
  * @method unknown  rollupAndWait()
  * @method unknown  runScript()
  * @method unknown  runScriptAndWait()
  * @method unknown  select()
  * @method unknown  selectAndWait()
  * @method unknown  selectFrame()
  * @method unknown  selectPopUp()
  * @method unknown  selectPopUpAndWait()
  * @method unknown  selectWindow()
  * @method unknown  setBrowserLogLevel()
  * @method unknown  setBrowserLogLevelAndWait()
  * @method unknown  setContext()
  * @method unknown  setCursorPosition()
  * @method unknown  setCursorPositionAndWait()
  * @method unknown  setMouseSpeed()
  * @method unknown  setMouseSpeedAndWait()
  * @method unknown  setSpeed()
  * @method unknown  setSpeedAndWait()
  * @method unknown  shiftKeyDown()
  * @method unknown  shiftKeyDownAndWait()
  * @method unknown  shiftKeyUp()
  * @method unknown  shiftKeyUpAndWait()
  * @method unknown  shutDownSeleniumServer()
  * @method unknown  store()
  * @method unknown  submit()
  * @method unknown  submitAndWait()
  * @method unknown  type()
  * @method unknown  typeAndWait()
  * @method unknown  typeKeys()
  * @method unknown  typeKeysAndWait()
  * @method unknown  uncheck()
  * @method unknown  uncheckAndWait()
  * @method unknown  useXpathLibrary()
  * @method unknown  useXpathLibraryAndWait()
  * @method unknown  waitForCondition()
  * @method unknown  waitForPageToLoad()
  * @method unknown  waitForPopUp()
  * @method unknown  windowFocus()
  * @method unknown  windowMaximize()
  */
 public function __call($command, $arguments)
 {
     $wait = FALSE;
     if (substr($command, -7, 7) == 'AndWait') {
         $command = substr($command, 0, -7);
         $wait = TRUE;
     }
     switch ($command) {
         case 'addLocationStrategy':
         case 'addScript':
         case 'addSelection':
         case 'allowNativeXpath':
         case 'altKeyDown':
         case 'altKeyUp':
         case 'answerOnNextPrompt':
         case 'assignId':
         case 'attachFile':
         case 'break':
         case 'captureEntirePageScreenshot':
         case 'captureScreenshot':
         case 'check':
         case 'chooseCancelOnNextConfirmation':
         case 'chooseOkOnNextConfirmation':
         case 'click':
         case 'clickAt':
         case 'close':
         case 'contextMenu':
         case 'contextMenuAt':
         case 'controlKeyDown':
         case 'controlKeyUp':
         case 'createCookie':
         case 'deleteAllVisibleCookies':
         case 'deleteCookie':
         case 'deselectPopUp':
         case 'doubleClick':
         case 'doubleClickAt':
         case 'dragAndDrop':
         case 'dragAndDropToObject':
         case 'dragDrop':
         case 'echo':
         case 'fireEvent':
         case 'focus':
         case 'goBack':
         case 'highlight':
         case 'ignoreAttributesWithoutValue':
         case 'keyDown':
         case 'keyDownNative':
         case 'keyPress':
         case 'keyPressNative':
         case 'keyUp':
         case 'keyUpNative':
         case 'metaKeyDown':
         case 'metaKeyUp':
         case 'mouseDown':
         case 'mouseDownAt':
         case 'mouseMove':
         case 'mouseMoveAt':
         case 'mouseOut':
         case 'mouseOver':
         case 'mouseUp':
         case 'mouseUpAt':
         case 'mouseUpRight':
         case 'mouseUpRightAt':
         case 'open':
         case 'openWindow':
         case 'pause':
         case 'refresh':
         case 'removeAllSelections':
         case 'removeScript':
         case 'removeSelection':
         case 'retrieveLastRemoteControlLogs':
         case 'rollup':
         case 'runScript':
         case 'select':
         case 'selectFrame':
         case 'selectPopUp':
         case 'selectWindow':
         case 'setBrowserLogLevel':
         case 'setContext':
         case 'setCursorPosition':
         case 'setMouseSpeed':
         case 'setSpeed':
         case 'shiftKeyDown':
         case 'shiftKeyUp':
         case 'shutDownSeleniumServer':
         case 'store':
         case 'submit':
         case 'type':
         case 'typeKeys':
         case 'uncheck':
         case 'useXpathLibrary':
         case 'windowFocus':
         case 'windowMaximize':
         case isset(self::$autoGeneratedCommands[$command]):
             // Pre-Command Actions
             switch ($command) {
                 case 'open':
                 case 'openWindow':
                     if ($this->collectCodeCoverageInformation) {
                         $this->deleteCookie('PHPUNIT_SELENIUM_TEST_ID', 'path=/');
                         $this->createCookie('PHPUNIT_SELENIUM_TEST_ID=' . $this->testId, 'path=/');
                     }
                     break;
                 case 'store':
                     // store is a synonym of storeExpression
                     // and RC only understands storeExpression
                     $command = 'storeExpression';
                     break;
             }
             if (isset(self::$autoGeneratedCommands[$command]) && self::$autoGeneratedCommands[$command]['functionHelper']) {
                 $helperArguments = array($command, $arguments, self::$autoGeneratedCommands[$command]);
                 call_user_func_array(array($this, self::$autoGeneratedCommands[$command]['functionHelper']), $helperArguments);
             } else {
                 $this->doCommand($command, $arguments);
             }
             // Post-Command Actions
             switch ($command) {
                 case 'addLocationStrategy':
                 case 'allowNativeXpath':
                 case 'assignId':
                 case 'captureEntirePageScreenshot':
                 case 'captureScreenshot':
                     // intentionally empty
                     break;
                 default:
                     if ($wait) {
                         if ($this->useWaitForPageToLoad) {
                             $this->waitForPageToLoad($this->seleniumTimeout * 1000);
                         } else {
                             sleep($this->wait);
                         }
                     }
                     if ($this->sleep > 0) {
                         sleep($this->sleep);
                     }
                     $this->testCase->runDefaultAssertions($command);
             }
             break;
         case 'getWhetherThisFrameMatchFrameExpression':
         case 'getWhetherThisWindowMatchWindowExpression':
         case 'isAlertPresent':
         case 'isChecked':
         case 'isConfirmationPresent':
         case 'isCookiePresent':
         case 'isEditable':
         case 'isElementPresent':
         case 'isOrdered':
         case 'isPromptPresent':
         case 'isSomethingSelected':
         case 'isTextPresent':
         case 'isVisible':
             return $this->getBoolean($command, $arguments);
             break;
         case 'getCursorPosition':
         case 'getElementHeight':
         case 'getElementIndex':
         case 'getElementPositionLeft':
         case 'getElementPositionTop':
         case 'getElementWidth':
         case 'getMouseSpeed':
         case 'getSpeed':
         case 'getXpathCount':
             $result = $this->getNumber($command, $arguments);
             if ($wait) {
                 $this->waitForPageToLoad($this->seleniumTimeout * 1000);
             }
             return $result;
             break;
         case 'getAlert':
         case 'getAttribute':
         case 'getBodyText':
         case 'getConfirmation':
         case 'getCookie':
         case 'getCookieByName':
         case 'getEval':
         case 'getExpression':
         case 'getHtmlSource':
         case 'getLocation':
         case 'getLogMessages':
         case 'getPrompt':
         case 'getSelectedId':
         case 'getSelectedIndex':
         case 'getSelectedLabel':
         case 'getSelectedValue':
         case 'getTable':
         case 'getText':
         case 'getTitle':
         case 'captureEntirePageScreenshotToString':
         case 'captureScreenshotToString':
         case 'getValue':
             $result = $this->getString($command, $arguments);
             if ($wait) {
                 $this->waitForPageToLoad($this->seleniumTimeout * 1000);
             }
             return $result;
             break;
         case 'getAllButtons':
         case 'getAllFields':
         case 'getAllLinks':
         case 'getAllWindowIds':
         case 'getAllWindowNames':
         case 'getAllWindowTitles':
         case 'getAttributeFromAllWindows':
         case 'getSelectedIds':
         case 'getSelectedIndexes':
         case 'getSelectedLabels':
         case 'getSelectedValues':
         case 'getSelectOptions':
             $result = $this->getStringArray($command, $arguments);
             if ($wait) {
                 $this->waitForPageToLoad($this->seleniumTimeout * 1000);
             }
             return $result;
             break;
         case 'waitForCondition':
         case 'waitForFrameToLoad':
         case 'waitForPopUp':
             if (count($arguments) == 1) {
                 $arguments[] = $this->seleniumTimeout * 1000;
             }
             $this->doCommand($command, $arguments);
             $this->testCase->runDefaultAssertions($command);
             break;
         case 'waitForPageToLoad':
             if (empty($arguments)) {
                 $arguments[] = $this->seleniumTimeout * 1000;
             }
             $this->doCommand($command, $arguments);
             $this->testCase->runDefaultAssertions($command);
             break;
         default:
             $this->stop();
             throw new BadMethodCallException("Method {$command} not defined.");
     }
 }
 /**
  * Returns the number of nodes that match the specified xPath selector,
  * eg. "table" would give the number of tables.
  * @param string $locator xPath selector
  */
 public function getXpathCount($locator)
 {
     $pos = stripos(trim($locator), 'css=');
     if ($pos !== false && $pos == 0) {
         return $this->getCssCount($locator);
     }
     return parent::getXpathCount($locator);
 }
示例#17
0
 /**
  * Sets up the fixture before executing a test method.
  * If you override this method, make sure the parent implementation is invoked.
  * Otherwise, the database fixtures will not be managed properly.
  */
 protected function setUp()
 {
     parent::setUp();
     if (is_array($this->fixtures)) {
         $this->getFixtureManager()->load($this->fixtures);
     }
 }
示例#18
0
 public function __construct($name = NULL, array $data = array(), $dataName = '', array $browser = array()) {
   parent::__construct($name, $data, $dataName, $browser);
   $this->fixtureLoader = new OBM_FixtureLoader();
   $this->dataset = new OBM_Database_CsvDataSet(';');
 }
示例#19
0
文件: Command.php 项目: rtwo/phpunit
 /**
  * Handles the command-line arguments.
  *
  * A child class of PHPUnit_TextUI_Command can hook into the argument
  * parsing by adding the switch(es) to the $longOptions array and point to a
  * callback method that handles the switch(es) in the child class like this
  *
  * <code>
  * <?php
  * class MyCommand extends PHPUnit_TextUI_Command
  * {
  *     public function __construct()
  *     {
  *         $this->longOptions['--my-switch'] = 'myHandler';
  *     }
  *
  *     // --my-switch foo -> myHandler('foo')
  *     protected function myHandler($value)
  *     {
  *     }
  * }
  * </code>
  *
  * @param array $argv
  */
 protected function handleArguments(array $argv)
 {
     try {
         $this->options = PHPUnit_Util_Getopt::getopt($argv, 'd:c:hv', array_keys($this->longOptions));
     } catch (PHPUnit_Framework_Exception $e) {
         PHPUnit_TextUI_TestRunner::showError($e->getMessage());
     }
     foreach ($this->options[0] as $option) {
         switch ($option[0]) {
             case '--colors':
                 $this->arguments['colors'] = TRUE;
                 break;
             case '--bootstrap':
                 $this->arguments['bootstrap'] = $option[1];
                 break;
             case 'c':
             case '--configuration':
                 $this->arguments['configuration'] = $option[1];
                 break;
             case '--coverage-clover':
             case '--coverage-html':
             case '--coverage-php':
             case '--coverage-text':
                 if (!extension_loaded('tokenizer')) {
                     $this->showExtensionNotLoadedMessage('tokenizer', 'No code coverage will be generated.');
                     continue;
                 }
                 if (!extension_loaded('xdebug')) {
                     $this->showExtensionNotLoadedMessage('Xdebug', 'No code coverage will be generated.');
                     continue;
                 }
                 switch ($option[0]) {
                     case '--coverage-clover':
                         $this->arguments['coverageClover'] = $option[1];
                         break;
                     case '--coverage-html':
                         $this->arguments['reportDirectory'] = $option[1];
                         break;
                     case '--coverage-php':
                         $this->arguments['coveragePHP'] = $option[1];
                         break;
                     case '--coverage-text':
                         if ($option[1] === NULL) {
                             $option[1] = 'php://stdout';
                         }
                         $this->arguments['coverageText'] = $option[1];
                         $this->arguments['coverageTextShowUncoveredFiles'] = FALSE;
                         break;
                 }
                 break;
             case 'd':
                 $ini = explode('=', $option[1]);
                 if (isset($ini[0])) {
                     if (isset($ini[1])) {
                         ini_set($ini[0], $ini[1]);
                     } else {
                         ini_set($ini[0], TRUE);
                     }
                 }
                 break;
             case '--debug':
                 $this->arguments['debug'] = TRUE;
                 break;
             case 'h':
             case '--help':
                 $this->showHelp();
                 exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
                 break;
             case '--filter':
                 $this->arguments['filter'] = $option[1];
                 break;
             case '--group':
                 $this->arguments['groups'] = explode(',', $option[1]);
                 break;
             case '--exclude-group':
                 $this->arguments['excludeGroups'] = explode(',', $option[1]);
                 break;
             case '--include-path':
                 $includePath = $option[1];
                 break;
             case '--list-groups':
                 $this->arguments['listGroups'] = TRUE;
                 break;
             case '--printer':
                 $this->arguments['printer'] = $option[1];
                 break;
             case '--loader':
                 $this->arguments['loader'] = $option[1];
                 break;
             case '--log-json':
                 $this->arguments['jsonLogfile'] = $option[1];
                 break;
             case '--log-junit':
                 $this->arguments['junitLogfile'] = $option[1];
                 break;
             case '--log-tap':
                 $this->arguments['tapLogfile'] = $option[1];
                 break;
             case '--process-isolation':
                 $this->arguments['processIsolation'] = TRUE;
                 break;
             case '--repeat':
                 $this->arguments['repeat'] = (int) $option[1];
                 break;
             case '--stderr':
                 $this->arguments['printer'] = new PHPUnit_TextUI_ResultPrinter('php://stderr', isset($this->arguments['verbose']) ? $this->arguments['verbose'] : FALSE);
                 break;
             case '--stop-on-error':
                 $this->arguments['stopOnError'] = TRUE;
                 break;
             case '--stop-on-failure':
                 $this->arguments['stopOnFailure'] = TRUE;
                 break;
             case '--stop-on-incomplete':
                 $this->arguments['stopOnIncomplete'] = TRUE;
                 break;
             case '--stop-on-skipped':
                 $this->arguments['stopOnSkipped'] = TRUE;
                 break;
             case '--tap':
                 $this->arguments['printer'] = new PHPUnit_Util_Log_TAP();
                 break;
             case '--testdox':
                 $this->arguments['printer'] = new PHPUnit_Util_TestDox_ResultPrinter_Text();
                 break;
             case '--testdox-html':
                 $this->arguments['testdoxHTMLFile'] = $option[1];
                 break;
             case '--testdox-text':
                 $this->arguments['testdoxTextFile'] = $option[1];
                 break;
             case '--no-configuration':
                 $this->arguments['useDefaultConfiguration'] = FALSE;
                 break;
             case '--no-globals-backup':
                 $this->arguments['backupGlobals'] = FALSE;
                 break;
             case '--static-backup':
                 $this->arguments['backupStaticAttributes'] = TRUE;
                 break;
             case 'v':
             case '--verbose':
                 $this->arguments['verbose'] = TRUE;
                 break;
             case '--version':
                 PHPUnit_TextUI_TestRunner::printVersionString();
                 exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
                 break;
             case '--strict':
                 $this->arguments['strict'] = TRUE;
                 break;
             default:
                 $optionName = str_replace('--', '', $option[0]);
                 if (isset($this->longOptions[$optionName])) {
                     $handler = $this->longOptions[$optionName];
                 } else {
                     if (isset($this->longOptions[$optionName . '='])) {
                         $handler = $this->longOptions[$optionName . '='];
                     }
                 }
                 if (isset($handler) && is_callable(array($this, $handler))) {
                     $this->{$handler}($option[1]);
                 }
         }
     }
     $this->handleCustomTestSuite();
     if (!isset($this->arguments['test'])) {
         if (count($this->options[1]) > 2) {
             $this->showMessage('More than two positional arguments provided.', FALSE);
             $this->showHelp();
             exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
         }
         if (isset($this->options[1][0])) {
             $this->arguments['test'] = $this->options[1][0];
         }
         if (isset($this->options[1][1])) {
             $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);
     }
 }
示例#20
0
 /**
  * Constructor
  *
  * @param   string  $name 
  * @param   array   $data 
  * @param   string  $dataName 
  */
 public function __construct($name = NULL, array $data = array(), $dataName = '')
 {
     parent::__construct($name, $data, $dataName);
     $this->CI =& get_instance();
     log_message('debug', get_class($this) . ' WetbTest initialized');
 }
示例#21
0
 public function selectWindow($windowName)
 {
     parent::selectWindow($windowName);
 }
示例#22
0
文件: Command.php 项目: cjmi/miniblog
 /**
  */
 protected static function handleArguments()
 {
     $arguments = array('listGroups' => FALSE, 'syntaxCheck' => TRUE);
     $longOptions = array('ansi', 'colors', 'bootstrap=', 'configuration=', 'coverage-html=', 'coverage-clover=', 'coverage-source=', 'coverage-xml=', 'debug', 'exclude-group=', 'filter=', 'group=', 'help', 'list-groups', 'loader=', 'log-graphviz=', 'log-json=', 'log-metrics=', 'log-pmd=', 'log-tap=', 'log-xml=', 'repeat=', 'report=', 'skeleton', 'skeleton-class', 'skeleton-test', 'stop-on-failure', 'story', 'story-html=', 'story-text=', 'tap', 'test-db-dsn=', 'test-db-log-rev=', 'test-db-log-prefix=', 'test-db-log-info=', 'testdox', 'testdox-html=', 'testdox-text=', 'no-syntax-check', 'verbose', 'version', 'wait');
     try {
         $options = PHPUnit_Util_Getopt::getopt($_SERVER['argv'], 'd:', $longOptions);
     } catch (RuntimeException $e) {
         PHPUnit_TextUI_TestRunner::showError($e->getMessage());
     }
     if (isset($options[1][0])) {
         $arguments['test'] = $options[1][0];
     }
     if (isset($options[1][1])) {
         $arguments['testFile'] = $options[1][1];
     } else {
         $arguments['testFile'] = '';
     }
     if (isset($arguments['test']) && is_file($arguments['test'])) {
         $arguments['testFile'] = realpath($arguments['test']);
         $arguments['test'] = substr($arguments['test'], 0, strrpos($arguments['test'], '.'));
     }
     foreach ($options[0] as $option) {
         switch ($option[0]) {
             case '--ansi':
             case '--colors':
                 $arguments['colors'] = TRUE;
                 break;
             case '--bootstrap':
                 $arguments['bootstrap'] = $option[1];
                 PHPUnit_Util_Fileloader::load($arguments['bootstrap']);
                 break;
             case '--configuration':
                 $arguments['configuration'] = $option[1];
                 break;
             case '--coverage-clover':
             case '--coverage-xml':
                 if (extension_loaded('tokenizer') && extension_loaded('xdebug')) {
                     $arguments['coverageClover'] = $option[1];
                 } else {
                     if (!extension_loaded('tokenizer')) {
                         self::showMissingDependency('The tokenizer extension is not loaded.');
                     } else {
                         self::showMissingDependency('The Xdebug extension is not loaded.');
                     }
                 }
                 break;
             case '--coverage-source':
                 if (extension_loaded('tokenizer') && extension_loaded('xdebug')) {
                     $arguments['coverageSource'] = $option[1];
                 } else {
                     if (!extension_loaded('tokenizer')) {
                         self::showMissingDependency('The tokenizer extension is not loaded.');
                     } else {
                         self::showMissingDependency('The Xdebug extension is not loaded.');
                     }
                 }
                 break;
             case '--coverage-html':
             case '--report':
                 if (extension_loaded('tokenizer') && extension_loaded('xdebug')) {
                     $arguments['reportDirectory'] = $option[1];
                 } else {
                     if (!extension_loaded('tokenizer')) {
                         self::showMissingDependency('The tokenizer extension is not loaded.');
                     } else {
                         self::showMissingDependency('The Xdebug extension is not loaded.');
                     }
                 }
                 break;
             case 'd':
                 $ini = explode('=', $option[1]);
                 if (isset($ini[0])) {
                     if (isset($ini[1])) {
                         ini_set($ini[0], $ini[1]);
                     } else {
                         ini_set($ini[0], TRUE);
                     }
                 }
                 break;
             case '--debug':
                 $arguments['debug'] = TRUE;
                 break;
             case '--help':
                 self::showHelp();
                 exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
                 break;
             case '--filter':
                 $arguments['filter'] = $option[1];
                 break;
             case '--group':
                 $arguments['groups'] = explode(',', $option[1]);
                 break;
             case '--exclude-group':
                 $arguments['excludeGroups'] = explode(',', $option[1]);
                 break;
             case '--list-groups':
                 $arguments['listGroups'] = TRUE;
                 break;
             case '--loader':
                 self::handleLoader($option[1]);
                 break;
             case '--log-json':
                 $arguments['jsonLogfile'] = $option[1];
                 break;
             case '--log-graphviz':
                 if (PHPUnit_Util_Filesystem::fileExistsInIncludePath('Image/GraphViz.php')) {
                     $arguments['graphvizLogfile'] = $option[1];
                 } else {
                     self::showMissingDependency('The Image_GraphViz package is not installed.');
                 }
                 break;
             case '--log-tap':
                 $arguments['tapLogfile'] = $option[1];
                 break;
             case '--log-xml':
                 $arguments['xmlLogfile'] = $option[1];
                 break;
             case '--log-pmd':
                 if (extension_loaded('tokenizer') && extension_loaded('xdebug')) {
                     $arguments['pmdXML'] = $option[1];
                 } else {
                     if (!extension_loaded('tokenizer')) {
                         self::showMissingDependency('The tokenizer extension is not loaded.');
                     } else {
                         self::showMissingDependency('The Xdebug extension is not loaded.');
                     }
                 }
                 break;
             case '--log-metrics':
                 if (extension_loaded('tokenizer') && extension_loaded('xdebug')) {
                     $arguments['metricsXML'] = $option[1];
                 } else {
                     if (!extension_loaded('tokenizer')) {
                         self::showMissingDependency('The tokenizer extension is not loaded.');
                     } else {
                         self::showMissingDependency('The Xdebug extension is not loaded.');
                     }
                 }
                 break;
             case '--repeat':
                 $arguments['repeat'] = (int) $option[1];
                 break;
             case '--stop-on-failure':
                 $arguments['stopOnFailure'] = TRUE;
                 break;
             case '--test-db-dsn':
                 if (extension_loaded('pdo')) {
                     $arguments['testDatabaseDSN'] = $option[1];
                 } else {
                     self::showMissingDependency('The PDO extension is not loaded.');
                 }
                 break;
             case '--test-db-log-rev':
                 if (extension_loaded('pdo')) {
                     $arguments['testDatabaseLogRevision'] = $option[1];
                 } else {
                     self::showMissingDependency('The PDO extension is not loaded.');
                 }
                 break;
             case '--test-db-prefix':
                 if (extension_loaded('pdo')) {
                     $arguments['testDatabasePrefix'] = $option[1];
                 } else {
                     self::showMissingDependency('The PDO extension is not loaded.');
                 }
                 break;
             case '--test-db-log-info':
                 if (extension_loaded('pdo')) {
                     $arguments['testDatabaseLogInfo'] = $option[1];
                 } else {
                     self::showMissingDependency('The PDO extension is not loaded.');
                 }
                 break;
             case '--skeleton':
             case '--skeleton-class':
             case '--skeleton-test':
                 if (isset($arguments['test']) && $arguments['test'] !== FALSE) {
                     PHPUnit_TextUI_TestRunner::printVersionString();
                     if ($option[0] == '--skeleton-class') {
                         require_once 'PHPUnit/Util/Skeleton/Class.php';
                         $class = 'PHPUnit_Util_Skeleton_Class';
                     } else {
                         require_once 'PHPUnit/Util/Skeleton/Test.php';
                         $class = 'PHPUnit_Util_Skeleton_Test';
                     }
                     try {
                         $skeleton = new $class($arguments['test'], $arguments['testFile']);
                         $skeleton->write();
                     } catch (Exception $e) {
                         print $e->getMessage() . "\n";
                         printf('Could not skeleton for "%s" to "%s".' . "\n", $skeleton->getOutClassName(), $skeleton->getOutSourceFile());
                         exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
                     }
                     printf('Wrote skeleton for "%s" to "%s".' . "\n", $skeleton->getOutClassName(), $skeleton->getOutSourceFile());
                     exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
                 } else {
                     self::showHelp();
                     exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
                 }
                 break;
             case '--tap':
                 require_once 'PHPUnit/Util/Log/TAP.php';
                 $arguments['printer'] = new PHPUnit_Util_Log_TAP();
                 break;
             case '--story':
                 require_once 'PHPUnit/Extensions/Story/ResultPrinter/Text.php';
                 $arguments['printer'] = new PHPUnit_Extensions_Story_ResultPrinter_Text();
                 break;
             case '--story-html':
                 $arguments['storyHTMLFile'] = $option[1];
                 break;
             case '--story-text':
                 $arguments['storyTextFile'] = $option[1];
                 break;
             case '--testdox':
                 require_once 'PHPUnit/Util/TestDox/ResultPrinter/Text.php';
                 $arguments['printer'] = new PHPUnit_Util_TestDox_ResultPrinter_Text();
                 break;
             case '--testdox-html':
                 $arguments['testdoxHTMLFile'] = $option[1];
                 break;
             case '--testdox-text':
                 $arguments['testdoxTextFile'] = $option[1];
                 break;
             case '--no-syntax-check':
                 $arguments['syntaxCheck'] = FALSE;
                 break;
             case '--verbose':
                 $arguments['verbose'] = TRUE;
                 break;
             case '--version':
                 PHPUnit_TextUI_TestRunner::printVersionString();
                 exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
                 break;
             case '--wait':
                 $arguments['wait'] = TRUE;
                 break;
         }
     }
     if (!isset($arguments['configuration']) && file_exists('phpunit.xml')) {
         $arguments['configuration'] = realpath('phpunit.xml');
     }
     if (isset($arguments['configuration'])) {
         $configuration = new PHPUnit_Util_Configuration($arguments['configuration']);
         $browsers = $configuration->getSeleniumBrowserConfiguration();
         if (!empty($browsers)) {
             require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
             PHPUnit_Extensions_SeleniumTestCase::$browsers = $browsers;
         }
         if (!isset($arguments['test'])) {
             $configuration->handlePHPConfiguration();
             if (!isset($arguments['bootstrap'])) {
                 $phpunitConfiguration = $configuration->getPHPUnitConfiguration();
                 if (isset($phpunitConfiguration['bootstrap'])) {
                     PHPUnit_Util_Fileloader::load($phpunitConfiguration['bootstrap']);
                 }
             }
             $testSuite = $configuration->getTestSuiteConfiguration();
             if ($testSuite !== NULL) {
                 $arguments['test'] = $testSuite;
             }
         }
     }
     if (isset($arguments['test']) && is_string($arguments['test']) && substr($arguments['test'], -5, 5) == '.phpt') {
         require_once 'PHPUnit/Extensions/PhptTestCase.php';
         $test = new PHPUnit_Extensions_PhptTestCase($arguments['test']);
         $arguments['test'] = new PHPUnit_Framework_TestSuite();
         $arguments['test']->addTest($test);
     }
     if (!isset($arguments['test']) || isset($arguments['testDatabaseLogRevision']) && !isset($arguments['testDatabaseDSN'])) {
         self::showHelp();
         exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
     }
     return $arguments;
 }
示例#23
0
 /**
  * @copydoc PHPUnit_Framework_TestCase::tearDown()
  */
 protected function tearDown()
 {
     parent::tearDown();
     if (Config::getVar('general', 'installed')) {
         $affectedTables = $this->getAffectedTables();
         if (is_array($affectedTables)) {
             PKPTestHelper::restoreTables($this->getAffectedTables(), $this);
         } elseif ($affectedTables === PKP_TEST_ENTIRE_DB) {
             PKPTestHelper::restoreDB($this);
         }
     }
 }
示例#24
0
 /**
  * @return void
  */
 protected function setUp()
 {
     parent::setUp();
     $fixtureImporter = new Tx_PtExtbase_Testing_Selenium_FixtureFramework_FixtureImporter();
     $fixtureImporter->import($this->getFixtures());
 }
示例#25
0
    /**
     * This function is cut&paste from PHPUnit_TextUI_Command::handleArguments
     * Removed the need for a required unnamed command option ( 'test')
     **/
    protected function handleArguments(array $argv)
    {
        try {
            $this->options = PHPUnit_Util_Getopt::getopt(
              $argv,
              'd:c:',
              array_keys($this->longOptions)
            );
        }

        catch (RuntimeException $e) {
            PHPUnit_TextUI_TestRunner::showError($e->getMessage());
        }

        $skeletonClass = FALSE;
        $skeletonTest  = FALSE;

        foreach ($this->options[0] as $option) {
            switch ($option[0]) {
                case '--colors': {
                    $this->arguments['colors'] = TRUE;
                }
                break;

                case '--bootstrap': {
                    $this->arguments['bootstrap'] = $option[1];
                }
                break;

                case 'c':
                case '--configuration': {
                    $this->arguments['configuration'] = $option[1];
                }
                break;

                case '--coverage-clover': {
                    if (extension_loaded('tokenizer') &&
                        extension_loaded('xdebug')) {
                        $this->arguments['coverageClover'] = $option[1];
                    } else {
                        if (!extension_loaded('tokenizer')) {
                            $this->showMessage(
                              'The tokenizer extension is not loaded.'
                            );
                        } else {
                            $this->showMessage(
                              'The Xdebug extension is not loaded.'
                            );
                        }
                    }
                }
                break;

                case '--coverage-html': {
                    if (extension_loaded('tokenizer') &&
                        extension_loaded('xdebug')) {
                        $this->arguments['reportDirectory'] = $option[1];
                    } else {
                        if (!extension_loaded('tokenizer')) {
                            $this->showMessage(
                              'The tokenizer extension is not loaded.'
                            );
                        } else {
                            $this->showMessage(
                              'The Xdebug extension is not loaded.'
                            );
                        }
                    }
                }
                break;

                case 'd': {
                    $ini = explode('=', $option[1]);

                    if (isset($ini[0])) {
                        if (isset($ini[1])) {
                            ini_set($ini[0], $ini[1]);
                        } else {
                            ini_set($ini[0], TRUE);
                        }
                    }
                }
                break;

                case '--debug': {
                    $this->arguments['debug'] = TRUE;
                }
                break;

                case '--help': {
                    $this->showHelp();
                    exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
                }
                break;

                case '--filter': {
                    $this->arguments['filter'] = $option[1];
                }
                break;

                case '--group': {
                    $this->arguments['groups'] = explode(',', $option[1]);
                }
                break;

                case '--exclude-group': {
                    $this->arguments['excludeGroups'] = explode(
                      ',', $option[1]
                    );
                }
                break;

                case '--include-path': {
                    $includePath = $option[1];
                }
                break;

                case '--list-groups': {
                    $this->arguments['listGroups'] = TRUE;
                }
                break;

                case '--loader': {
                    $this->arguments['loader'] = $option[1];
                }
                break;

                case '--log-dbus': {
                    $this->arguments['logDbus'] = TRUE;
                }
                break;

                case '--log-json': {
                    $this->arguments['jsonLogfile'] = $option[1];
                }
                break;

                case '--log-junit': {
                    $this->arguments['junitLogfile'] = $option[1];
                }
                break;

                case '--log-tap': {
                    $this->arguments['tapLogfile'] = $option[1];
                }
                break;

                case '--process-isolation': {
                    $this->arguments['processIsolation'] = TRUE;
                    $this->arguments['syntaxCheck']      = FALSE;
                }
                break;

                case '--repeat': {
                    $this->arguments['repeat'] = (int)$option[1];
                }
                break;

                case '--stderr': {
                    $this->arguments['printer'] = new PHPUnit_TextUI_ResultPrinter(
                      'php://stderr',
                      isset($this->arguments['verbose']) ? $this->arguments['verbose'] : FALSE
                    );
                }
                break;

                case '--stop-on-error': {
                    $this->arguments['stopOnError'] = TRUE;
                }
                break;

                case '--stop-on-failure': {
                    $this->arguments['stopOnFailure'] = TRUE;
                }
                break;

                case '--stop-on-incomplete': {
                    $this->arguments['stopOnIncomplete'] = TRUE;
                }
                break;

                case '--stop-on-skipped': {
                    $this->arguments['stopOnSkipped'] = TRUE;
                }
                break;

                case '--skeleton-test': {
                    $skeletonTest  = TRUE;
                    $skeletonClass = FALSE;
                }
                break;

                case '--skeleton-class': {
                    $skeletonClass = TRUE;
                    $skeletonTest  = FALSE;
                }
                break;

                case '--tap': {
                    $this->arguments['printer'] = new PHPUnit_Util_Log_TAP;
                }
                break;

                case '--story': {
                    $this->showMessage(
                      'The --story functionality is deprecated and ' .
                      'will be removed in the future.',
                      FALSE
                    );

                    $this->arguments['printer'] = new PHPUnit_Extensions_Story_ResultPrinter_Text;
                }
                break;

                case '--story-html': {
                    $this->showMessage(
                      'The --story-html functionality is deprecated and ' .
                      'will be removed in the future.',
                      FALSE
                    );

                    $this->arguments['storyHTMLFile'] = $option[1];
                }
                break;

                case '--story-text': {
                    $this->showMessage(
                      'The --story-text functionality is deprecated and ' .
                      'will be removed in the future.',
                      FALSE
                    );

                    $this->arguments['storyTextFile'] = $option[1];
                }
                break;

                case '--syntax-check': {
                    $this->arguments['syntaxCheck'] = TRUE;
                }
                break;

                case '--testdox': {
                    $this->arguments['printer'] = new PHPUnit_Util_TestDox_ResultPrinter_Text;
                }
                break;

                case '--testdox-html': {
                    $this->arguments['testdoxHTMLFile'] = $option[1];
                }
                break;

                case '--testdox-text': {
                    $this->arguments['testdoxTextFile'] = $option[1];
                }
                break;

                case '--no-configuration': {
                    $this->arguments['useDefaultConfiguration'] = FALSE;
                }
                break;

                case '--no-globals-backup': {
                    $this->arguments['backupGlobals'] = FALSE;
                }
                break;

                case '--static-backup': {
                    $this->arguments['backupStaticAttributes'] = TRUE;
                }
                break;

                case '--verbose': {
                    $this->arguments['verbose'] = TRUE;
                }
                break;

                case '--version': {
                    PHPUnit_TextUI_TestRunner::printVersionString();
                    exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
                }
                break;

                case '--wait': {
                    $this->arguments['wait'] = TRUE;
                }
                break;

                case '--strict': {
                    $this->arguments['strict'] = TRUE;
                }
                break;
                
                default: {
                    $optionName = str_replace('--', '', $option[0]);

                    if (isset($this->longOptions[$optionName])) {
                        $handler = $this->longOptions[$optionName];
                    }

                    else if (isset($this->longOptions[$optionName . '='])) {
                        $handler = $this->longOptions[$optionName . '='];
                    }

                    if (isset($handler) && is_callable(array($this, $handler))) {
                        $this->$handler($option[1]);
                    }
                }
            }
        }

        if (isset($this->arguments['printer']) &&
            $this->arguments['printer'] instanceof PHPUnit_Extensions_Story_ResultPrinter_Text &&
            isset($this->arguments['processIsolation']) &&
            $this->arguments['processIsolation']) {
            $this->showMessage(
              'The story result printer cannot be used in process isolation.'
            );
        }

        $this->handleCustomTestSuite();

        if (!isset($this->arguments['test'])) {
            if (isset($this->options[1][0])) {
                $this->arguments['test'] = $this->options[1][0];
            }

            if (isset($this->options[1][1])) {
                $this->arguments['testFile'] = $this->options[1][1];
            } else {
                $this->arguments['testFile'] = '';
            }

            if (isset($this->arguments['test']) && is_file($this->arguments['test'])) {
                $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'], $this->arguments['syntaxCheck']);
        }

        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();

            if (isset($phpunit['syntaxCheck'])) {
                $this->arguments['syntaxCheck'] = $phpunit['syntaxCheck'];
            }

            if (isset($phpunit['testSuiteLoaderClass'])) {
                if (isset($phpunit['testSuiteLoaderFile'])) {
                    $file = $phpunit['testSuiteLoaderFile'];
                } else {
                    $file = '';
                }

                $this->arguments['loader'] = $this->handleLoader(
                  $phpunit['testSuiteLoaderClass'], $file
                );
            }

            $configuration->handlePHPConfiguration();

            if (!isset($this->arguments['bootstrap'])) {
                $phpunitConfiguration = $configuration->getPHPUnitConfiguration();

                if (isset($phpunitConfiguration['bootstrap'])) {
                    $this->handleBootstrap($phpunitConfiguration['bootstrap'], $this->arguments['syntaxCheck']);
                }
            }

            $browsers = $configuration->getSeleniumBrowserConfiguration();

            if (!empty($browsers)) {
                PHPUnit_Extensions_SeleniumTestCase::$browsers = $browsers;
            }

            if (!isset($this->arguments['test'])) {
                $testSuite = $configuration->getTestSuiteConfiguration(
                  $this->arguments['syntaxCheck']
                );

                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);
        }

        // *** BEGIN ezp custom code BEGIN ***
        // Commented out this stuff
/*        if (!isset($this->arguments['test']) ||
            (isset($this->arguments['testDatabaseLogRevision']) && !isset($this->arguments['testDatabaseDSN']))) {
            $this->showHelp();
            exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
        }*/
        // *** END ezp custom code END ***

        if (!isset($this->arguments['syntaxCheck'])) {
            $this->arguments['syntaxCheck'] = FALSE;
        }

        if ($skeletonClass || $skeletonTest) {
            if (isset($this->arguments['test']) && $this->arguments['test'] !== FALSE) {
                PHPUnit_TextUI_TestRunner::printVersionString();

                if ($skeletonClass) {
                    $class = 'PHPUnit_Util_Skeleton_Class';
                } else {
                    $class = 'PHPUnit_Util_Skeleton_Test';
                }

                try {
                    $args      = array();
                    $reflector = new ReflectionClass($class);

                    for ($i = 0; $i <= 3; $i++) {
                        if (isset($this->options[1][$i])) {
                            $args[] = $this->options[1][$i];
                        }
                    }

                    $skeleton = $reflector->newInstanceArgs($args);
                    $skeleton->write();
                }

                catch (Exception $e) {
                    print $e->getMessage() . "\n";
                    exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
                }

                printf(
                  'Wrote skeleton for "%s" to "%s".' . "\n",
                  $skeleton->getOutClassName(),
                  $skeleton->getOutSourceFile()
                );

                exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
            } else {
                $this->showHelp();
                exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
            }
        }
    }
示例#26
0
 /**
  * @param  array $arguments
  * @since  Method available since Release 3.2.1
  */
 protected function handleConfiguration(array &$arguments)
 {
     if (isset($arguments['configuration'])) {
         $arguments['configuration'] = new PHPUnit_Util_Configuration($arguments['configuration']);
         $arguments['pmd'] = $arguments['configuration']->getPMDConfiguration();
     } else {
         $arguments['pmd'] = array();
     }
     $arguments['filter'] = isset($arguments['filter']) ? $arguments['filter'] : FALSE;
     $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
     $arguments['repeat'] = isset($arguments['repeat']) ? $arguments['repeat'] : FALSE;
     $arguments['testDatabasePrefix'] = isset($arguments['testDatabasePrefix']) ? $arguments['testDatabasePrefix'] : '';
     $arguments['verbose'] = isset($arguments['verbose']) ? $arguments['verbose'] : FALSE;
     $arguments['wait'] = isset($arguments['wait']) ? $arguments['wait'] : FALSE;
     if (isset($arguments['configuration'])) {
         $arguments['configuration']->handlePHPConfiguration();
         $filterConfiguration = $arguments['configuration']->getFilterConfiguration();
         PHPUnit_Util_Filter::$addUncoveredFilesFromWhitelist = $filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist'];
         foreach ($filterConfiguration['blacklist']['include']['directory'] as $dir) {
             PHPUnit_Util_Filter::addDirectoryToFilter($dir['path'], $dir['suffix']);
         }
         foreach ($filterConfiguration['blacklist']['include']['file'] as $file) {
             PHPUnit_Util_Filter::addFileToFilter($file);
         }
         foreach ($filterConfiguration['blacklist']['exclude']['directory'] as $dir) {
             PHPUnit_Util_Filter::removeDirectoryFromFilter($dir['path'], $dir['suffix']);
         }
         foreach ($filterConfiguration['blacklist']['exclude']['file'] as $file) {
             PHPUnit_Util_Filter::removeFileFromFilter($file);
         }
         foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) {
             PHPUnit_Util_Filter::addDirectoryToWhitelist($dir['path'], $dir['suffix']);
         }
         foreach ($filterConfiguration['whitelist']['include']['file'] as $file) {
             PHPUnit_Util_Filter::addFileToWhitelist($file);
         }
         foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) {
             PHPUnit_Util_Filter::removeDirectoryFromWhitelist($dir['path'], $dir['suffix']);
         }
         foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) {
             PHPUnit_Util_Filter::removeFileFromWhitelist($file);
         }
         $phpunitConfiguration = $arguments['configuration']->getPHPUnitConfiguration();
         if (isset($phpunitConfiguration['ansi']) && !isset($arguments['ansi'])) {
             $arguments['ansi'] = $phpunitConfiguration['ansi'];
         }
         if (isset($phpunitConfiguration['convertErrorsToExceptions']) && !isset($arguments['convertErrorsToExceptions'])) {
             $arguments['convertErrorsToExceptions'] = $phpunitConfiguration['convertErrorsToExceptions'];
         }
         if (isset($phpunitConfiguration['convertNoticesToExceptions']) && !isset($arguments['convertNoticesToExceptions'])) {
             $arguments['convertNoticesToExceptions'] = $phpunitConfiguration['convertNoticesToExceptions'];
         }
         if (isset($phpunitConfiguration['convertWarningsToExceptions']) && !isset($arguments['convertWarningsToExceptions'])) {
             $arguments['convertWarningsToExceptions'] = $phpunitConfiguration['convertWarningsToExceptions'];
         }
         if (isset($phpunitConfiguration['stopOnFailure']) && !isset($arguments['stopOnFailure'])) {
             $arguments['stopOnFailure'] = $phpunitConfiguration['stopOnFailure'];
         }
         $groupConfiguration = $arguments['configuration']->getGroupConfiguration();
         if (!empty($groupConfiguration['include']) && !isset($arguments['groups'])) {
             $arguments['groups'] = $groupConfiguration['include'];
         }
         if (!empty($groupConfiguration['exclude']) && !isset($arguments['excludeGroups'])) {
             $arguments['excludeGroups'] = $groupConfiguration['exclude'];
         }
         $loggingConfiguration = $arguments['configuration']->getLoggingConfiguration();
         if (isset($loggingConfiguration['coverage-html']) && !isset($arguments['reportDirectory'])) {
             if (isset($loggingConfiguration['charset']) && !isset($arguments['reportCharset'])) {
                 $arguments['reportCharset'] = $loggingConfiguration['charset'];
             }
             if (isset($loggingConfiguration['yui']) && !isset($arguments['reportYUI'])) {
                 $arguments['reportYUI'] = $loggingConfiguration['yui'];
             }
             if (isset($loggingConfiguration['highlight']) && !isset($arguments['reportHighlight'])) {
                 $arguments['reportHighlight'] = $loggingConfiguration['highlight'];
             }
             if (isset($loggingConfiguration['lowUpperBound']) && !isset($arguments['reportLowUpperBound'])) {
                 $arguments['reportLowUpperBound'] = $loggingConfiguration['lowUpperBound'];
             }
             if (isset($loggingConfiguration['highLowerBound']) && !isset($arguments['reportHighLowerBound'])) {
                 $arguments['reportHighLowerBound'] = $loggingConfiguration['highLowerBound'];
             }
             $arguments['reportDirectory'] = $loggingConfiguration['coverage-html'];
         }
         if (isset($loggingConfiguration['coverage-clover']) && !isset($arguments['coverageClover'])) {
             $arguments['coverageClover'] = $loggingConfiguration['coverage-clover'];
         }
         if (isset($loggingConfiguration['coverage-xml']) && !isset($arguments['coverageClover'])) {
             $arguments['coverageClover'] = $loggingConfiguration['coverage-xml'];
         }
         if (isset($loggingConfiguration['coverage-source']) && !isset($arguments['coverageSource'])) {
             $arguments['coverageSource'] = $loggingConfiguration['coverage-source'];
         }
         if (isset($loggingConfiguration['graphviz']) && !isset($arguments['graphvizLogfile'])) {
             $arguments['graphvizLogfile'] = $loggingConfiguration['graphviz'];
         }
         if (isset($loggingConfiguration['json']) && !isset($arguments['jsonLogfile'])) {
             $arguments['jsonLogfile'] = $loggingConfiguration['json'];
         }
         if (isset($loggingConfiguration['metrics-xml']) && !isset($arguments['metricsXML'])) {
             $arguments['metricsXML'] = $loggingConfiguration['metrics-xml'];
         }
         if (isset($loggingConfiguration['plain'])) {
             $arguments['listeners'][] = new PHPUnit_TextUI_ResultPrinter($loggingConfiguration['plain'], TRUE);
         }
         if (isset($loggingConfiguration['pmd-xml']) && !isset($arguments['pmdXML'])) {
             if (isset($loggingConfiguration['cpdMinLines']) && !isset($arguments['cpdMinLines'])) {
                 $arguments['cpdMinLines'] = $loggingConfiguration['cpdMinLines'];
             }
             if (isset($loggingConfiguration['cpdMinMatches']) && !isset($arguments['cpdMinMatches'])) {
                 $arguments['cpdMinMatches'] = $loggingConfiguration['cpdMinMatches'];
             }
             $arguments['pmdXML'] = $loggingConfiguration['pmd-xml'];
         }
         if (isset($loggingConfiguration['tap']) && !isset($arguments['tapLogfile'])) {
             $arguments['tapLogfile'] = $loggingConfiguration['tap'];
         }
         if (isset($loggingConfiguration['test-xml']) && !isset($arguments['xmlLogfile'])) {
             $arguments['xmlLogfile'] = $loggingConfiguration['test-xml'];
             if (isset($loggingConfiguration['logIncompleteSkipped']) && !isset($arguments['logIncompleteSkipped'])) {
                 $arguments['logIncompleteSkipped'] = $loggingConfiguration['logIncompleteSkipped'];
             }
         }
         if (isset($loggingConfiguration['story-html']) && !isset($arguments['storyHTMLFile'])) {
             $arguments['storyHTMLFile'] = $loggingConfiguration['story-html'];
         }
         if (isset($loggingConfiguration['story-text']) && !isset($arguments['storyTextFile'])) {
             $arguments['storsTextFile'] = $loggingConfiguration['story-text'];
         }
         if (isset($loggingConfiguration['testdox-html']) && !isset($arguments['testdoxHTMLFile'])) {
             $arguments['testdoxHTMLFile'] = $loggingConfiguration['testdox-html'];
         }
         if (isset($loggingConfiguration['testdox-text']) && !isset($arguments['testdoxTextFile'])) {
             $arguments['testdoxTextFile'] = $loggingConfiguration['testdox-text'];
         }
         $browsers = $arguments['configuration']->getSeleniumBrowserConfiguration();
         if (!empty($browsers)) {
             require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
             PHPUnit_Extensions_SeleniumTestCase::$browsers = $browsers;
         }
     }
     $arguments['cpdMinLines'] = isset($arguments['cpdMinLines']) ? $arguments['cpdMinLines'] : 5;
     $arguments['cpdMinMatches'] = isset($arguments['cpdMinMatches']) ? $arguments['cpdMinMatches'] : 70;
     $arguments['ansi'] = isset($arguments['ansi']) ? $arguments['ansi'] : FALSE;
     $arguments['convertErrorsToExceptions'] = isset($arguments['convertErrorsToExceptions']) ? $arguments['convertErrorsToExceptions'] : TRUE;
     $arguments['convertNoticesToExceptions'] = isset($arguments['convertNoticesToExceptions']) ? $arguments['convertNoticesToExceptions'] : TRUE;
     $arguments['convertWarningsToExceptions'] = isset($arguments['convertWarningsToExceptions']) ? $arguments['convertWarningsToExceptions'] : TRUE;
     $arguments['excludeGroups'] = isset($arguments['excludeGroups']) ? $arguments['excludeGroups'] : array();
     $arguments['groups'] = isset($arguments['groups']) ? $arguments['groups'] : array();
     $arguments['logIncompleteSkipped'] = isset($arguments['logIncompleteSkipped']) ? $arguments['logIncompleteSkipped'] : FALSE;
     $arguments['reportCharset'] = isset($arguments['reportCharset']) ? $arguments['reportCharset'] : 'ISO-8859-1';
     $arguments['reportHighlight'] = isset($arguments['reportHighlight']) ? $arguments['reportHighlight'] : FALSE;
     $arguments['reportHighLowerBound'] = isset($arguments['reportHighLowerBound']) ? $arguments['reportHighLowerBound'] : 70;
     $arguments['reportLowUpperBound'] = isset($arguments['reportLowUpperBound']) ? $arguments['reportLowUpperBound'] : 35;
     $arguments['reportYUI'] = isset($arguments['reportYUI']) ? $arguments['reportYUI'] : TRUE;
     $arguments['stopOnFailure'] = isset($arguments['stopOnFailure']) ? $arguments['stopOnFailure'] : FALSE;
 }
示例#27
0
 public function tearDown()
 {
     //		$this->stop();
     parent::tearDown();
     $this->config->tearDown();
 }
 /**
  * @return string
  */
 protected function prepareTestSession()
 {
     $result = parent::prepareTestSession();
     // Set any cookies required by local installation
     // Note: considered doing this in setUp(), but the Selenium session wasn't yet initialized.
     if (property_exists($this->settings, 'cookies')) {
         // We don't really care about this page, but it seems we need
         // to open a page before setting a cookie.
         $this->open($this->sboxPath);
         $this->waitForPageToLoad($this->getTimeoutMsec());
         $this->setCookies($this->settings->cookies);
     }
     return $result;
 }
示例#29
0
 /**
  * Handles the command-line arguments.
  *
  * A child class of PHPUnit_TextUI_Command can hook into the argument
  * parsing by adding the switch(es) to the $longOptions array and point to a
  * callback method that handles the switch(es) in the child class like this
  *
  * <code>
  * <?php
  * class MyCommand extends PHPUnit_TextUI_Command
  * {
  *     public function __construct()
  *     {
  *         $this->longOptions['--my-switch'] = 'myHandler';
  *     }
  *
  *     // --my-switch foo -> myHandler('foo')
  *     protected function myHandler($value)
  *     {
  *     }
  * }
  * </code>
  *
  * @param array $argv
  */
 protected function handleArguments(array $argv)
 {
     try {
         $this->options = PHPUnit_Util_Getopt::getopt($argv, 'd:', array_keys($this->longOptions));
     } catch (RuntimeException $e) {
         PHPUnit_TextUI_TestRunner::showError($e->getMessage());
     }
     $skeletonClass = FALSE;
     $skeletonTest = FALSE;
     foreach ($this->options[0] as $option) {
         switch ($option[0]) {
             case '--ansi':
                 $this->showMessage('The --ansi option is deprecated, please use --colors ' . 'instead.', FALSE);
             case '--colors':
                 $this->arguments['colors'] = TRUE;
                 break;
             case '--bootstrap':
                 $this->arguments['bootstrap'] = $option[1];
                 break;
             case '--configuration':
                 $this->arguments['configuration'] = $option[1];
                 break;
             case '--coverage-xml':
                 $this->showMessage('The --coverage-xml option is deprecated, please use ' . '--coverage-clover instead.', FALSE);
             case '--coverage-clover':
                 if (extension_loaded('tokenizer') && extension_loaded('xdebug')) {
                     $this->arguments['coverageClover'] = $option[1];
                 } else {
                     if (!extension_loaded('tokenizer')) {
                         $this->showMessage('The tokenizer extension is not loaded.');
                     } else {
                         $this->showMessage('The Xdebug extension is not loaded.');
                     }
                 }
                 break;
             case '--coverage-source':
                 if (extension_loaded('tokenizer') && extension_loaded('xdebug')) {
                     $this->arguments['coverageSource'] = $option[1];
                 } else {
                     if (!extension_loaded('tokenizer')) {
                         $this->showMessage('The tokenizer extension is not loaded.');
                     } else {
                         $this->showMessage('The Xdebug extension is not loaded.');
                     }
                 }
                 break;
             case '--report':
                 $this->showMessage('The --report option is deprecated, please use ' . '--coverage-html instead.', FALSE);
             case '--coverage-html':
                 if (extension_loaded('tokenizer') && extension_loaded('xdebug')) {
                     $this->arguments['reportDirectory'] = $option[1];
                 } else {
                     if (!extension_loaded('tokenizer')) {
                         $this->showMessage('The tokenizer extension is not loaded.');
                     } else {
                         $this->showMessage('The Xdebug extension is not loaded.');
                     }
                 }
                 break;
             case 'd':
                 $ini = explode('=', $option[1]);
                 if (isset($ini[0])) {
                     if (isset($ini[1])) {
                         ini_set($ini[0], $ini[1]);
                     } else {
                         ini_set($ini[0], TRUE);
                     }
                 }
                 break;
             case '--debug':
                 $this->arguments['debug'] = TRUE;
                 break;
             case '--help':
                 $this->showHelp();
                 exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
                 break;
             case '--filter':
                 $this->arguments['filter'] = $option[1];
                 break;
             case '--group':
                 $this->arguments['groups'] = explode(',', $option[1]);
                 break;
             case '--exclude-group':
                 $this->arguments['excludeGroups'] = explode(',', $option[1]);
                 break;
             case '--include-path':
                 $includePath = $option[1];
                 break;
             case '--list-groups':
                 $this->arguments['listGroups'] = TRUE;
                 break;
             case '--loader':
                 $this->arguments['loader'] = $option[1];
                 break;
             case '--log-json':
                 $this->arguments['jsonLogfile'] = $option[1];
                 break;
             case '--log-xml':
                 $this->showMessage('The --log-xml option is deprecated, please use ' . '--log-junit instead.', FALSE);
             case '--log-junit':
                 $this->arguments['junitLogfile'] = $option[1];
                 break;
             case '--log-graphviz':
                 $this->showMessage('The --log-graphviz functionality is deprecated and ' . 'will be removed in the future.', FALSE);
                 if (PHPUnit_Util_Filesystem::fileExistsInIncludePath('Image/GraphViz.php')) {
                     $this->arguments['graphvizLogfile'] = $option[1];
                 } else {
                     $this->showMessage('The Image_GraphViz package is not installed.');
                 }
                 break;
             case '--log-tap':
                 $this->arguments['tapLogfile'] = $option[1];
                 break;
             case '--log-pmd':
                 $this->showMessage('The --log-pmd functionality is deprecated and will be ' . 'removed in the future.', FALSE);
                 if (extension_loaded('tokenizer') && extension_loaded('xdebug')) {
                     $this->arguments['pmdXML'] = $option[1];
                 } else {
                     if (!extension_loaded('tokenizer')) {
                         $this->showMessage('The tokenizer extension is not loaded.');
                     } else {
                         $this->showMessage('The Xdebug extension is not loaded.');
                     }
                 }
                 break;
             case '--log-metrics':
                 $this->showMessage('The --log-metrics functionality is deprecated and ' . 'will be removed in the future.', FALSE);
                 if (extension_loaded('tokenizer') && extension_loaded('xdebug')) {
                     $this->arguments['metricsXML'] = $option[1];
                 } else {
                     if (!extension_loaded('tokenizer')) {
                         $this->showMessage('The tokenizer extension is not loaded.');
                     } else {
                         $this->showMessage('The Xdebug extension is not loaded.');
                     }
                 }
                 break;
             case '--process-isolation':
                 $this->arguments['processIsolation'] = TRUE;
                 $this->arguments['syntaxCheck'] = FALSE;
                 break;
             case '--repeat':
                 $this->showMessage('The --repeat functionality is deprecated and will be ' . 'removed in the future.', FALSE);
                 $this->arguments['repeat'] = (int) $option[1];
                 break;
             case '--stderr':
                 $this->arguments['printer'] = new PHPUnit_TextUI_ResultPrinter('php://stderr', isset($this->arguments['verbose']) ? $this->arguments['verbose'] : FALSE);
                 break;
             case '--stop-on-failure':
                 $this->arguments['stopOnFailure'] = TRUE;
                 break;
             case '--test-db-dsn':
                 $this->showMessage('The test database functionality is deprecated and ' . 'will be removed in the future.', FALSE);
                 if (extension_loaded('pdo')) {
                     $this->arguments['testDatabaseDSN'] = $option[1];
                 } else {
                     $this->showMessage('The PDO extension is not loaded.');
                 }
                 break;
             case '--test-db-log-rev':
                 if (extension_loaded('pdo')) {
                     $this->arguments['testDatabaseLogRevision'] = $option[1];
                 } else {
                     $this->showMessage('The PDO extension is not loaded.');
                 }
                 break;
             case '--test-db-prefix':
                 if (extension_loaded('pdo')) {
                     $this->arguments['testDatabasePrefix'] = $option[1];
                 } else {
                     $this->showMessage('The PDO extension is not loaded.');
                 }
                 break;
             case '--test-db-log-info':
                 if (extension_loaded('pdo')) {
                     $this->arguments['testDatabaseLogInfo'] = $option[1];
                 } else {
                     $this->showMessage('The PDO extension is not loaded.');
                 }
                 break;
             case '--skeleton':
                 $this->showMessage('The --skeleton option is deprecated, please use ' . '--skeleton-test instead.', FALSE);
             case '--skeleton-test':
                 $skeletonTest = TRUE;
                 $skeletonClass = FALSE;
                 break;
             case '--skeleton-class':
                 $skeletonClass = TRUE;
                 $skeletonTest = FALSE;
                 break;
             case '--tap':
                 require_once PATH_TO_ROOT . '/test/PHPUnit/Util/Log/TAP.php';
                 $this->arguments['printer'] = new PHPUnit_Util_Log_TAP();
                 break;
             case '--story':
                 require_once PATH_TO_ROOT . '/test/PHPUnit/Extensions/Story/ResultPrinter/Text.php';
                 $this->arguments['printer'] = new PHPUnit_Extensions_Story_ResultPrinter_Text();
                 break;
             case '--story-html':
                 $this->arguments['storyHTMLFile'] = $option[1];
                 break;
             case '--story-text':
                 $this->arguments['storyTextFile'] = $option[1];
                 break;
             case '--syntax-check':
                 $this->arguments['syntaxCheck'] = TRUE;
                 break;
             case '--testdox':
                 require_once PATH_TO_ROOT . '/test/PHPUnit/Util/TestDox/ResultPrinter/Text.php';
                 $this->arguments['printer'] = new PHPUnit_Util_TestDox_ResultPrinter_Text();
                 break;
             case '--testdox-html':
                 $this->arguments['testdoxHTMLFile'] = $option[1];
                 break;
             case '--testdox-text':
                 $this->arguments['testdoxTextFile'] = $option[1];
                 break;
             case '--no-configuration':
                 $this->arguments['useDefaultConfiguration'] = FALSE;
                 break;
             case '--no-globals-backup':
                 $this->arguments['backupGlobals'] = FALSE;
                 break;
             case '--static-backup':
                 $this->arguments['backupStaticAttributes'] = TRUE;
                 break;
             case '--verbose':
                 $this->arguments['verbose'] = TRUE;
                 break;
             case '--version':
                 PHPUnit_TextUI_TestRunner::printVersionString();
                 exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
                 break;
             case '--wait':
                 $this->arguments['wait'] = TRUE;
                 break;
             default:
                 $optionName = str_replace('--', '', $option[0]);
                 if (isset($this->longOptions[$optionName])) {
                     $handler = $this->longOptions[$optionName];
                 } else {
                     if (isset($this->longOptions[$optionName . '='])) {
                         $handler = $this->longOptions[$optionName . '='];
                     }
                 }
                 if (isset($handler) && is_callable(array($this, $handler))) {
                     $this->{$handler}($option[1]);
                 }
         }
     }
     if (isset($this->arguments['printer']) && $this->arguments['printer'] instanceof PHPUnit_Extensions_Story_ResultPrinter_Text && isset($this->arguments['processIsolation']) && $this->arguments['processIsolation']) {
         $this->showMessage('The story result printer cannot be used in process isolation.');
     }
     $this->handleCustomTestSuite();
     if (!isset($this->arguments['test'])) {
         if (isset($this->options[1][0])) {
             $this->arguments['test'] = $this->options[1][0];
         }
         if (isset($this->options[1][1])) {
             $this->arguments['testFile'] = $this->options[1][1];
         } else {
             $this->arguments['testFile'] = '';
         }
         if (isset($this->arguments['test']) && is_file($this->arguments['test'])) {
             $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'])) {
         PHPUnit_Util_Fileloader::load($this->arguments['bootstrap']);
     }
     if ($this->arguments['loader'] !== NULL) {
         $this->arguments['loader'] = $this->handleLoader($this->arguments['loader']);
     }
     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'])) {
         $configuration = PHPUnit_Util_Configuration::getInstance($this->arguments['configuration']);
         $phpunit = $configuration->getPHPUnitConfiguration();
         if (isset($phpunit['syntaxCheck'])) {
             $this->arguments['syntaxCheck'] = $phpunit['syntaxCheck'];
         }
         if (isset($phpunit['testSuiteLoaderClass'])) {
             if (isset($phpunit['testSuiteLoaderFile'])) {
                 $file = $phpunit['testSuiteLoaderFile'];
             } else {
                 $file = '';
             }
             $this->arguments['loader'] = $this->handleLoader($phpunit['testSuiteLoaderClass'], $file);
         }
         $configuration->handlePHPConfiguration();
         if (!isset($this->arguments['bootstrap'])) {
             $phpunitConfiguration = $configuration->getPHPUnitConfiguration();
             if (isset($phpunitConfiguration['bootstrap'])) {
                 PHPUnit_Util_Fileloader::load($phpunitConfiguration['bootstrap']);
             }
         }
         $browsers = $configuration->getSeleniumBrowserConfiguration();
         if (!empty($browsers)) {
             require_once PATH_TO_ROOT . '/test/PHPUnit/Extensions/SeleniumTestCase.php';
             PHPUnit_Extensions_SeleniumTestCase::$browsers = $browsers;
         }
         if (!isset($this->arguments['test'])) {
             $testSuite = $configuration->getTestSuiteConfiguration($this->arguments['syntaxCheck']);
             if ($testSuite !== NULL) {
                 $this->arguments['test'] = $testSuite;
             }
         }
     }
     if (isset($this->arguments['test']) && is_string($this->arguments['test']) && substr($this->arguments['test'], -5, 5) == '.phpt') {
         require_once PATH_TO_ROOT . '/test/PHPUnit/Extensions/PhptTestCase.php';
         $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);
     }
     if (!isset($this->arguments['syntaxCheck'])) {
         $this->arguments['syntaxCheck'] = FALSE;
     }
     if ($skeletonClass || $skeletonTest) {
         if (isset($this->arguments['test']) && $this->arguments['test'] !== FALSE) {
             PHPUnit_TextUI_TestRunner::printVersionString();
             if ($skeletonClass) {
                 require_once PATH_TO_ROOT . '/test/PHPUnit/Util/Skeleton/Class.php';
                 $class = 'PHPUnit_Util_Skeleton_Class';
             } else {
                 require_once PATH_TO_ROOT . '/test/PHPUnit/Util/Skeleton/Test.php';
                 $class = 'PHPUnit_Util_Skeleton_Test';
             }
             try {
                 $args = array();
                 $reflector = new ReflectionClass($class);
                 for ($i = 0; $i <= 3; $i++) {
                     if (isset($this->options[1][$i])) {
                         $args[] = $this->options[1][$i];
                     }
                 }
                 $skeleton = $reflector->newInstanceArgs($args);
                 $skeleton->write();
             } catch (Exception $e) {
                 print $e->getMessage() . "\n";
                 exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
             }
             printf('Wrote skeleton for "%s" to "%s".' . "\n", $skeleton->getOutClassName(), $skeleton->getOutSourceFile());
             exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
         } else {
             $this->showHelp();
             exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
         }
     }
 }
示例#30
0
 /**
  * @param  array $browser
  * @return PHPUnit_Extensions_SeleniumTestCase_Driver
  * @since  Method available since Release 1.0.0
  */
 protected function getDriver(array $browser)
 {
     if ($browser['host'] == 'localhost' && isset($_SERVER['REMOTE_ADDR'])) {
         $browser['host'] = $_SERVER['REMOTE_ADDR'];
     }
     return parent::getDriver($browser);
 }