function run(PHPUnit_Framework_TestResult $result = NULL)
 {
     /* Some functions require some kind of caching, and will end up using the db,
      * which we can't allow, as that would open a new connection for mysql.
      * Replace with a HashBag. They would not be going to persist anyway.
      */
     ObjectCache::$instances[CACHE_DB] = new HashBagOStuff();
     if ($this->needsDB()) {
         global $wgDBprefix;
         $this->useTemporaryTables = !$this->getCliArg('use-normal-tables');
         $this->reuseDB = $this->getCliArg('reuse-db');
         $this->db = wfGetDB(DB_MASTER);
         $this->checkDbIsSupported();
         $this->oldTablePrefix = $wgDBprefix;
         if (!self::$dbSetup) {
             $this->initDB();
             self::$dbSetup = true;
         }
         $this->addCoreDBData();
         $this->addDBData();
         parent::run($result);
         $this->resetDB();
     } else {
         parent::run($result);
     }
 }
Пример #2
0
 /**
  * Runs this test case. Overridden to attach to EARL report w/o need for
  * an external XML configuration file.
  *
  * @param PHPUnit_Framework_TestResult $result the test result.
  */
 public function run(PHPUnit_Framework_TestResult $result = NULL)
 {
     global $EARL;
     $EARL->attach($result);
     $this->result = $result;
     parent::run($result);
 }
Пример #3
0
 /**
  * This overide of the run method is required to run the test in isolation.
  * I have no idea why, and whilst the test runs absolutely fine when run
  * on local vm, by itself, when run as part of suite it borks
  * if not in isolation!
  */
 public function run(\PHPUnit_Framework_TestResult $result = NULL)
 {
     //mock the current incoming ip address
     $_SERVER['REMOTE_ADDR'] = '192.168.10.167';
     $this->setPreserveGlobalState(false);
     return parent::run($result);
 }
Пример #4
0
/**
* Runs the test case and collects the results in a TestResult object.
* If no TestResult object is passed a new one will be created.
* This method is run for each test method in this class
*
* @param  PHPUnit_Framework_TestResult $result
* @return PHPUnit_Framework_TestResult
* @throws InvalidArgumentException
*/
	public function run(PHPUnit_Framework_TestResult $result = NULL) {
		if (!empty($this->fixtureManager)) {
			$this->fixtureManager->load($this);
		}
		$result = parent::run($result);
		if (!empty($this->fixtureManager)) {
			$this->fixtureManager->unload($this);
		}
		return $result;
	}
Пример #5
0
 public function run(PHPUnit_Framework_TestResult $result = NULL)
 {
     if ($result === NULL) {
         $result = $this->createResult();
     }
     $this->collectCodeCoverageInformation = $result->getCollectCodeCoverageInformation();
     parent::run($result);
     if ($this->collectCodeCoverageInformation) {
         $result->getCodeCoverage()->append($this->getCodeCoverage(), $this);
     }
     return $result;
 }
Пример #6
0
 /**
  * Reimplemented to allow us to collect code coverage info from the target server.
  * Code taken from PHPUnit_Extensions_Selenium2TestCase
  *
  * @param PHPUnit_Framework_TestResult $result
  * @return PHPUnit_Framework_TestResult
  * @throws Exception
  */
 public function run(PHPUnit_Framework_TestResult $result = NULL)
 {
     $this->testId = get_class($this) . '__' . $this->getName();
     if ($result === NULL) {
         $result = $this->createResult();
     }
     $this->collectCodeCoverageInformation = $result->getCollectCodeCoverageInformation();
     parent::run($result);
     if ($this->collectCodeCoverageInformation) {
         $coverage = new PHPUnit_Extensions_SeleniumCommon_RemoteCoverage($this->coverageScriptUrl, $this->testId);
         $result->getCodeCoverage()->append($coverage->get(), $this);
     }
     // do not call this before to give the time to the Listeners to run
     //$this->getStrategy()->endOfTest($this->session);
     return $result;
 }
Пример #7
0
 public function run(PHPUnit_Framework_TestResult $result = null)
 {
     /* Some functions require some kind of caching, and will end up using the db,
      * which we can't allow, as that would open a new connection for mysql.
      * Replace with a HashBag. They would not be going to persist anyway.
      */
     ObjectCache::$instances[CACHE_DB] = new HashBagOStuff();
     // Sandbox APC by replacing with in-process hash instead.
     // Ensures values are removed between tests.
     ObjectCache::$instances['apc'] = ObjectCache::$instances['xcache'] = ObjectCache::$instances['wincache'] = new HashBagOStuff();
     $needsResetDB = false;
     if ($this->needsDB()) {
         // set up a DB connection for this test to use
         self::$useTemporaryTables = !$this->getCliArg('use-normal-tables');
         self::$reuseDB = $this->getCliArg('reuse-db');
         $this->db = wfGetDB(DB_MASTER);
         $this->checkDbIsSupported();
         if (!self::$dbSetup) {
             // switch to a temporary clone of the database
             self::setupTestDB($this->db, $this->dbPrefix());
             if (($this->db->getType() == 'oracle' || !self::$useTemporaryTables) && self::$reuseDB) {
                 $this->resetDB();
             }
         }
         $this->addCoreDBData();
         $this->addDBData();
         $needsResetDB = true;
     }
     parent::run($result);
     if ($needsResetDB) {
         $this->resetDB();
     }
 }
Пример #8
0
 /**
  * Runs the test case and collects the results in a TestResult object.
  *
  * If no TestResult object is passed a new one will be created.
  *
  * @param \PHPUnit_Framework_TestResult $result Test result.
  *
  * @return \PHPUnit_Framework_TestResult
  * @throws \PHPUnit_Framework_Exception When exception was thrown during a test.
  */
 public function run(\PHPUnit_Framework_TestResult $result = null)
 {
     if ($result === null) {
         $result = $this->createResult();
     }
     parent::run($result);
     if ($result->getCollectCodeCoverageInformation()) {
         $result->getCodeCoverage()->append($this->getRemoteCodeCoverageInformation(), $this);
     }
     /*$this->setTestResultObject($result);*/
     // Do not call this before to give the time to the Listeners to run.
     $this->_eventDispatcher->dispatch(self::TEST_ENDED_EVENT, new TestEndedEvent($this, $result, $this->_session));
     /*$this->setTestResultObject(null);*/
     return $result;
 }
 /**
  * It is assumed that each test that makes use of the TestCase is requesting
  * a "real" DB connection
  *
  * By default, the database tables are being re-used but it is possible to
  * request a trear down so that the next test can rebuild the tables from
  * scratch
  */
 public function run(\PHPUnit_Framework_TestResult $result = null)
 {
     $this->getStore()->clear();
     $this->mwDatabaseTableBuilder = MwDatabaseTableBuilder::getInstance($this->getStore());
     $this->mwDatabaseTableBuilder->removeAvailableDatabaseType($this->databaseToBeExcluded);
     $this->destroyDatabaseTables($this->destroyDatabaseTablesBeforeRun);
     try {
         $this->mwDatabaseTableBuilder->doBuild();
     } catch (RuntimeException $e) {
         $this->isUsableUnitTestDatabase = false;
     }
     parent::run($result);
     $this->destroyDatabaseTables($this->destroyDatabaseTablesAfterRun);
 }
 /**
  * (non-PHPdoc)
  * @see PHPUnit_Framework_TestCase::run()
  */
 public function run(PHPUnit_Framework_TestResult $result = null)
 {
     $name = $this->getName(true);
     KalturaLog::debug("In KalturaTestCaseBase::run for test [{$name}]\n");
     //print("In KalturaTestCaseBase::run for test [$name]\n");
     if ($name != KalturaTestCaseBase::TEST_NOTHING_TEST_NAME) {
         //we init the framework for all tests but hte test nothing test
         $this->initFramework($result);
     }
     $result = parent::run($result);
     return $result;
 }
 public function run(PHPUnit_Framework_TestResult $result = null)
 {
     /* Some functions require some kind of caching, and will end up using the db,
      * which we can't allow, as that would open a new connection for mysql.
      * Replace with a HashBag. They would not be going to persist anyway.
      */
     ObjectCache::$instances[CACHE_DB] = new HashBagOStuff();
     $needsResetDB = false;
     $logName = get_class($this) . '::' . $this->getName(false);
     if ($this->needsDB()) {
         // set up a DB connection for this test to use
         self::$useTemporaryTables = !$this->getCliArg('use-normal-tables');
         self::$reuseDB = $this->getCliArg('reuse-db');
         $this->db = wfGetDB(DB_MASTER);
         $this->checkDbIsSupported();
         if (!self::$dbSetup) {
             wfProfileIn($logName . ' (clone-db)');
             // switch to a temporary clone of the database
             self::setupTestDB($this->db, $this->dbPrefix());
             if (($this->db->getType() == 'oracle' || !self::$useTemporaryTables) && self::$reuseDB) {
                 $this->resetDB();
             }
             wfProfileOut($logName . ' (clone-db)');
         }
         wfProfileIn($logName . ' (prepare-db)');
         $this->addCoreDBData();
         $this->addDBData();
         wfProfileOut($logName . ' (prepare-db)');
         $needsResetDB = true;
     }
     wfProfileIn($logName);
     parent::run($result);
     wfProfileOut($logName);
     if ($needsResetDB) {
         wfProfileIn($logName . ' (reset-db)');
         $this->resetDB();
         wfProfileOut($logName . ' (reset-db)');
     }
 }
 public function run(PHPUnit_Framework_TestResult $result = null)
 {
     if (!self::$_aInitialDbChecksum) {
         self::initializeDbChecksum();
     }
     $result = parent::run($result);
     oxTestModules::cleanUp();
     return $result;
 }
Пример #13
0
 /**
  * @param PHPUnit_Framework_TestResult $result
  *
  * @return PHPUnit_Framework_TestResult
  */
 public function run(PHPUnit_Framework_TestResult $result = null)
 {
     $result = parent::run($result);
     oxTestModules::cleanUp();
     return $result;
 }
Пример #14
0
 public function run(PHPUnit_Framework_TestResult $result = null)
 {
     // Reset all caches between tests.
     $this->doLightweightServiceReset();
     $needsResetDB = false;
     if (!self::$dbSetup || $this->needsDB()) {
         // set up a DB connection for this test to use
         self::$useTemporaryTables = !$this->getCliArg('use-normal-tables');
         self::$reuseDB = $this->getCliArg('reuse-db');
         $this->db = wfGetDB(DB_MASTER);
         $this->checkDbIsSupported();
         if (!self::$dbSetup) {
             $this->setupAllTestDBs();
             $this->addCoreDBData();
             if (($this->db->getType() == 'oracle' || !self::$useTemporaryTables) && self::$reuseDB) {
                 $this->resetDB($this->db, $this->tablesUsed);
             }
         }
         // TODO: the DB setup should be done in setUpBeforeClass(), so the test DB
         // is available in subclass's setUpBeforeClass() and setUp() methods.
         // This would also remove the need for the HACK that is oncePerClass().
         if ($this->oncePerClass()) {
             $this->addDBDataOnce();
         }
         $this->addDBData();
         $needsResetDB = true;
     }
     parent::run($result);
     if ($needsResetDB) {
         $this->resetDB($this->db, $this->tablesUsed);
     }
 }
Пример #15
0
 /**
  * Overload the running of this test in case we only want to run
  * specific data sets
  *
  * Usage from command-line:
  *
  *    TEST="someTest" phpunit suiteTest.php
  *
  *    TEST="1|2|3" phpunit threeDataProviderTest.php
  * 
  * @param PHPUnit_Framework_TestResult $result
  * @throws InvalidArgumentException
  */
 public function run(PHPUnit_Framework_TestResult $result = null)
 {
     set_time_limit(0);
     // Limit our data sets
     $env = getenv('TEST');
     if (is_string($env) && strlen($env) > 0) {
         $env = explode('|', $env);
         $dataProviderElement = $this->getDataTestCasePrivate('dataName');
         if (empty($dataProviderElement)) {
             $dataProviderElement = 0;
         }
         if (!in_array($dataProviderElement, $env)) {
             return $result;
         }
     }
     return parent::run($result);
 }
Пример #16
0
 public function run(PHPUnit_Framework_TestResult $result = NULL)
 {
     $this->setExpectedLogsFromAnnotations();
     $this->logStream = NULL;
     if (class_exists('Plop', TRUE)) {
         $logging = Plop::getInstance();
         $this->logStream = fopen('php://temp', 'a+');
         $handlers = new Plop_HandlersCollection();
         $handler = new Plop_Handler_Stream($this->logStream);
         $handler->setFormatter(new Plop_Formatter('%(levelname)s:%(message)s'));
         $handlers[] = $handler;
         $logging->getLogger()->setHandlers($handlers);
     }
     return parent::run($result);
 }
Пример #17
0
 /**
  * Run with Process Manager
  *
  * @param \PHPUnit_Framework_TestResult $result
  * @return \PHPUnit_Framework_TestResult
  * @throws \Exception
  */
 public function run(\PHPUnit_Framework_TestResult $result = null)
 {
     if ($this->isParallelRun) {
         $params = ['name' => $this->getName(false), 'data' => $this->data, 'dataName' => $this->dataName];
         $this->processManager->run($this, $result, $params);
     } else {
         try {
             parent::run($result);
             if ($this->getStatus() == \PHPUnit_Runner_BaseTestRunner::STATUS_ERROR) {
                 $this->eventManager->dispatchEvent(['exception'], [$this->getStatusMessage()]);
             }
             /** @var \PHPUnit_Framework_TestFailure $failure */
             foreach ($result->failures() as $failure) {
                 $this->eventManager->dispatchEvent(['failure'], [$failure->exceptionMessage()]);
             }
         } catch (\PHPUnit_Framework_Exception $phpUnitException) {
             $this->eventManager->dispatchEvent(['exception'], [$phpUnitException->getMessage()]);
             throw $phpUnitException;
         } catch (\Exception $exception) {
             $this->eventManager->dispatchEvent(['exception'], [$exception->getMessage()]);
             $this->fail($exception);
         }
     }
     return $result;
 }
Пример #18
0
 public function run(PHPUnit_Framework_TestResult $result = NULL)
 {
     NimbleRecord::start_transaction();
     parent::run($result);
     NimbleRecord::rollback_transaction();
 }
 protected function verifySuccess(PHPUnit_Framework_TestCase $test)
 {
     $result = $test->run();
     $this->assertEquals(0, $result->errorCount());
     $this->assertEquals(0, $result->failureCount());
     $this->assertEquals(1, count($result));
 }
Пример #20
0
 public function run(PHPUnit_Framework_TestResult $result = null)
 {
     $this->epubCheckJar = $this->epubCheckJar();
     $this->testResult = $result;
     parent::run($result);
 }
Пример #21
0
 public function run(\PHPUnit_Framework_TestResult $result = NULL)
 {
     $this->setPreserveGlobalState(false);
     return parent::run($result);
 }
 public function run(PHPUnit_Framework_TestResult $result = NULL)
 {
     if (is_array($this->theDependencies) && count($this->theDependencies)) {
         $className = get_class($this);
         $passed = $result->passed();
         $passedKeys = array_keys($passed);
         foreach ($this->theDependencies as $dependency) {
             $dependency = $className . '::' . $dependency;
             if (in_array($dependency, $passedKeys)) {
                 $this->theDependencyInput[] = $passed[$dependency];
             }
         }
     }
     $ret = parent::run($result);
     $testConfig = $this->config->get('config');
     if ($testConfig->reportPath) {
         $xml = new SimpleXMLElement('<test/>');
         $xml->addAttribute('name', $this->getName());
         $xml->addAttribute('status', $this->getStatus());
         $xml->addAttribute('numAssertions', $this->getNumAssertions());
         $xml->addAttribute('statusMessage', $this->getStatusMessage());
         $resultElement = $xml->addChild('result');
         $resultElement->addAttribute('returnedType', get_class($this->getResult()));
         if ($result instanceof PHPUnit_Framework_TestResult) {
             if ($result->errorCount()) {
                 $errorsElemnt = $resultElement->addChild('errors');
                 $errors = $result->errors();
                 foreach ($errors as $error) {
                     /* @var $error PHPUnit_Framework_TestFailure */
                     $errorElemnt = $errorsElemnt->addChild('error', $error->exceptionMessage());
                 }
             }
             if ($result->skippedCount()) {
                 $skippedsElemnt = $resultElement->addChild('skippeds');
                 $skippeds = $result->skipped();
                 foreach ($skippeds as $skipped) {
                     /* @var $skipped PHPUnit_Framework_TestFailure */
                     $skippedElemnt = $skippedsElemnt->addChild('skipped', $skipped->exceptionMessage());
                 }
             }
             if ($result->failureCount()) {
                 $failuresElemnt = $resultElement->addChild('failures');
                 $failures = $result->failures();
                 foreach ($failures as $failure) {
                     /* @var $failure PHPUnit_Framework_TestFailure */
                     $failureElemnt = $failuresElemnt->addChild('failure', $failure->exceptionMessage());
                 }
             }
         }
         $fileName = $testConfig->reportPath . DIRECTORY_SEPARATOR . get_class($this) . '.' . $this->getName() . '.xml';
         $xml->asXML($fileName);
     }
     return $ret;
 }