02770, 'file_mode' => 0777, 'chown' => '', 'chgrp' => '', ); $GLOBALS['js_version_key'] = 'testrunner'; if ( !isset($_SERVER['SERVER_SOFTWARE']) ) $_SERVER["SERVER_SOFTWARE"] = 'PHPUnit'; // helps silence the license checking when running unit tests. $_SESSION['VALIDATION_EXPIRES_IN'] = 'valid'; $GLOBALS['startTime'] = microtime(true); // clean out the cache directory require_once('modules/Administration/QuickRepairAndRebuild.php'); $repair = new RepairAndClear(); $repair->module_list = array(); $repair->show_output = false; $repair->clearJsLangFiles(); $repair->clearJsFiles(); // mark that we got by the admin wizard already $focus = new Administration(); $focus->retrieveSettings(); $focus->saveSetting('system','adminwizard',1); // include the other test tools require_once 'SugarTestUserUtilities.php'; require_once 'SugarTestLangPackCreator.php'; require_once 'SugarTestThemeUtilities.php'; require_once 'SugarTestContactUtilities.php'; require_once 'SugarTestEmailUtilities.php'; require_once 'SugarTestCampaignUtilities.php'; require_once 'SugarTestLeadUtilities.php'; require_once 'SugarTestStudioUtilities.php'; require_once 'SugarTestMeetingUtilities.php'; require_once 'SugarTestCallUtilities.php'; require_once 'SugarTestAccountUtilities.php'; require_once 'SugarTestTrackerUtility.php'; require_once 'SugarTestImportUtilities.php'; require_once 'SugarTestMergeUtilities.php'; require_once 'SugarTestTaskUtilities.php'; // define our testcase subclass class Sugar_PHPUnit_Framework_TestCase extends PHPUnit_Framework_TestCase { protected $backupGlobals = FALSE; protected $useOutputBuffering = true; protected function assertPostConditions() { if(!empty($_REQUEST)) { foreach(array_keys($_REQUEST) as $k) { unset($_REQUEST[$k]); } } if(!empty($_POST)) { foreach(array_keys($_POST) as $k) { unset($_POST[$k]); } } if(!empty($_GET)) { foreach(array_keys($_GET) as $k) { unset($_GET[$k]); } } } public static function tearDownAfterClass() { unset($GLOBALS['disable_date_format']); $GLOBALS['timedate']->clearCache(); } } // define output testcase subclass class Sugar_PHPUnit_Framework_OutputTestCase extends PHPUnit_Extensions_OutputTestCase { protected $backupGlobals = FALSE; protected $_notRegex; protected $_outputCheck; protected function assertPostConditions() { if(!empty($_REQUEST)) { foreach(array_keys($_REQUEST) as $k) { unset($_REQUEST[$k]); } } if(!empty($_POST)) { foreach(array_keys($_POST) as $k) { unset($_POST[$k]); } } if(!empty($_GET)) { foreach(array_keys($_GET) as $k) { unset($_GET[$k]); } } } protected function NotRegexCallback($output) { if(empty($this->_notRegex)) { return true; } $this->assertNotRegExp($this->_notRegex, $output); return true; } public function setOutputCheck($callback) { if (!is_callable($callback)) { throw new PHPUnit_Framework_Exception; } $this->_outputCheck = $callback; } protected function runTest() { $testResult = parent::runTest(); if($this->_outputCheck) { $this->assertTrue(call_user_func($this->_outputCheck, $this->output)); } return $testResult; } public function expectOutputNotRegex($expectedRegex) { if (is_string($expectedRegex) || is_null($expectedRegex)) { $this->_notRegex = $expectedRegex; } $this->setOutputCheck(array($this, "NotRegexCallback")); } } // define a mock logger interface; used for capturing logging messages emited // the test suite class SugarMockLogger { private $_messages = array(); public function __call($method, $message) { $this->messages[] = strtoupper($method) . ': ' . $message[0]; } public function getLastMessage() { return end($this->messages); } public function getMessageCount() { return count($this->messages); } }