/** * Run the test (wrapper around phpunit function) */ public function runBare() { if (file_exists(__DIR__ . '/../../phpunit_config.php')) { require_once __DIR__ . '/../../phpunit_config.php'; } if (!empty($DB)) { $DB2 = clone $DB; } $DB = $this->construct_driver(); $this->DB = $DB; $this->initialize_database(); try { parent::runBare(); } catch (\Exception $e) { $this->clean_database(); if (!empty($DB2)) { $DB = clone $DB2; } throw $e; } $this->clean_database(); if (!empty($DB2)) { $DB = clone $DB2; } }
/** * Runs the bare test sequence. * @return void */ public final function runBare() { global $DB; if (phpunit_util::$lastdbwrites != $DB->perf_get_writes()) { // this happens when previous test does not reset, we can not use transactions $this->testdbtransaction = null; } else { if ($DB->get_dbfamily() === 'postgres' or $DB->get_dbfamily() === 'mssql') { // database must allow rollback of DDL, so no mysql here $this->testdbtransaction = $DB->start_delegated_transaction(); } } try { parent::runBare(); // set DB reference in case somebody mocked it in test $DB = phpunit_util::get_global_backup('DB'); } catch (Exception $e) { // cleanup after failed expectation phpunit_util::reset_all_data(); throw $e; } if (!$this->testdbtransaction or $this->testdbtransaction->is_disposed()) { $this->testdbtransaction = null; } if ($this->resetAfterTest === true) { if ($this->testdbtransaction) { $DB->force_transaction_rollback(); phpunit_util::reset_all_database_sequences(); phpunit_util::$lastdbwrites = $DB->perf_get_writes(); // no db reset necessary } phpunit_util::reset_all_data(); } else { if ($this->resetAfterTest === false) { if ($this->testdbtransaction) { $this->testdbtransaction->allow_commit(); } // keep all data untouched for other tests } else { // reset but log what changed if ($this->testdbtransaction) { try { $this->testdbtransaction->allow_commit(); } catch (dml_transaction_exception $e) { phpunit_util::reset_all_data(); throw new coding_exception('Invalid transaction state detected in test ' . $this->getName()); } } phpunit_util::reset_all_data(true); } } // make sure test did not forget to close transaction if ($DB->is_transaction_started()) { phpunit_util::reset_all_data(); if ($this->getStatus() == PHPUnit_Runner_BaseTestRunner::STATUS_PASSED or $this->getStatus() == PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED or $this->getStatus() == PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE) { throw new coding_exception('Test ' . $this->getName() . ' did not close database transaction'); } } }
public function runBare() { try { return parent::runBare(); } catch (\atk4\core\Exception $e) { throw new \atk4\data\tests\AgileExceptionWrapper($e->getMessage(), 0, $e); } }
public function runBare() { try { return parent::runBare(); } catch (Exception $e) { throw new PHPUnit_AgileExceptionWrapper($e->getMessage(), 0, $e); } }
/** * Injects an untainted clone of the object manager and all its referencing * objects for every test. * * @return void * @author Robert Lemke <*****@*****.**> */ public function runBare() { \PHPUnit_Framework_Error_Warning::$enabled = FALSE; if (class_exists('F3\\Testing\\AbstractTestRunner', FALSE)) { $this->objectManager = clone \F3\Testing\AbstractTestRunner::$objectManagerForTesting; $this->objectFactory = $this->objectManager->getObjectFactory(); } parent::runBare(); }
public function runBare() { if (!isset(CM_Config::get()->CM_Site_Abstract->class)) { $siteDefault = $this->getMockSite(null, null, array('url' => 'http://www.default.dev', 'urlCdn' => 'http://cdn.default.dev', 'name' => 'Default', 'emailAddress' => '*****@*****.**')); CM_Config::get()->CM_Site_Abstract->class = get_class($siteDefault); } $this->setServiceManager(CMTest_TH::getServiceManager()); parent::runBare(); }
public function runBare() { try { return parent::runBare(); } catch (\Exception $e) { if (!$e instanceof \PHPUnit_Framework_AssertionFailedError) { \Nella\Diagnostics\ConsoleDebug::_exceptionHandler($e); } throw $e; } }
/** * Adds Hamcrest assertion counts to PHPUnit */ public function runBare() { $e = null; ha::resetCount(); try { parent::runBare(); } catch (\Exception $e) { } $this->addToAssertionCount(ha::getCount()); if ($e !== null) { throw $e; } }
/** * Runs the bare test sequence and log any changes in global state or database. * @return void */ public final function runBare() { global $DB; try { parent::runBare(); } catch (Exception $e) { // cleanup after failed expectation phpunit_util::reset_all_data(); throw $e; } if ($DB->is_transaction_started()) { phpunit_util::reset_all_data(); throw new coding_exception('basic_testcase ' . $this->getName() . ' is not supposed to use database transactions!'); } phpunit_util::reset_all_data(true); }
/** * @return void */ public function runBare() { \PHPUnit_Framework_Error_Warning::$enabled = FALSE; parent::runBare(); }
/** * {@inheritdoc} */ public function runBare() { parent::runBare(); $this->prophet = null; }
/** * Overwrite runBare * * PHPUnit instantiates the test classes before * running them individually. So right before a test * runs we set our instance. Normally this step would * happen in setUp, but someone is bound to forget to * call the parent method and debugging this is no fun. */ public function runBare() { self::$ci_test_instance = $this; parent::runBare(); }
/** * Runs the bare test sequence. * @return void */ public function runBare() { try { parent::runBare(); } catch (Exception $e) { if ($this->tdb->is_transaction_started()) { $this->tdb->force_transaction_rollback(); } $this->tearDown(); throw $e; } }
/** * Make sure we always disconnect after tests */ public function runBare() { // log test timing $test = get_class($this) . '::' . $this->getName(); $t = new Horde_Support_Timer(); $t->push(); $this->_logInfo($test, 'START '); $this->_connect(); parent::runBare(); $this->_disconnect(); // log test timing $elapsed = $t->pop(); $this->_logInfo($test, 'FINISH', $elapsed); }
/** * Runs the bare test sequence. * * @author Art <*****@*****.**> * @throws Exception * @codeCoverageIgnore Won't be picked up as these are tested in separate processes * @uses PHPUnit_Framework_TestCase::runBare() */ public function runBare() { $this->parseMethodAnnotations($sleepTime, $retryCount); if ($retryCount > 0) { $numRuns = 0; while ($numRuns < $retryCount) { $numRuns++; try { parent::runBare(); return; } catch (Exception $e) { if ($numRuns == $retryCount) { throw $e; } else { PHPUnitReflection::getMessage()->setValue($this, ''); PHPUnitReflection::getStatus()->setValue($this, null); fwrite(STDERR, sprintf(self::$retryMsg, $this->getName(false), $sleepTime, $numRuns, $retryCount)); sleep($sleepTime); } } } } else { parent::runBare(); } }
/** * Runs the bare test sequence. * @return void */ public function runBare() { global $CFG, $USER, $DB; $dbwrites = $DB->perf_get_writes(); parent::runBare(); $oldcfg = phpunit_util::get_global_backup('CFG'); foreach ($CFG as $k => $v) { if (!property_exists($oldcfg, $k)) { unset($CFG->{$k}); error_log('warning: unexpected new $CFG->' . $k . ' value in testcase: ' . get_class($this) . '->' . $this->getName(true)); } else { if ($oldcfg->{$k} !== $CFG->{$k}) { $CFG->{$k} = $oldcfg->{$k}; error_log('warning: unexpected change of $CFG->' . $k . ' value in testcase: ' . get_class($this) . '->' . $this->getName(true)); } } unset($oldcfg->{$k}); } if ($oldcfg) { foreach ($oldcfg as $k => $v) { $CFG->{$k} = $v; error_log('warning: unexpected removal of $CFG->' . $k . ' in testcase: ' . get_class($this) . '->' . $this->getName(true)); } } if ($USER->id != 0) { error_log('warning: unexpected change of $USER in testcase: ' . get_class($this) . '->' . $this->getName(true)); $USER = new stdClass(); $USER->id = 0; } if ($dbwrites != $DB->perf_get_writes()) { //TODO: find out what was changed exactly error_log('warning: unexpected database modification, resetting DB state in testcase: ' . get_class($this) . '->' . $this->getName(true)); phpunit_util::reset_all_data(); } //TODO: somehow find out if there are changes in dataroot }