本文整理汇总了PHP中MainController::inTestMode方法的典型用法代码示例。如果您正苦于以下问题:PHP MainController::inTestMode方法的具体用法?PHP MainController::inTestMode怎么用?PHP MainController::inTestMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MainController
的用法示例。
在下文中一共展示了MainController::inTestMode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: raiseError
/**
* methods raises an exception by throwing a ExceptionController exception.
*
* @param string $text
* @param bool $stop_execution
* @param callable|null $catched_exception
* @return void
* @throws \Thallium\Controllers\ExceptionController
*/
public static function raiseError($text, $stop_execution = false, $catched_exception = null)
{
if (!isset($text) || empty($text) || !is_string($text)) {
$text = "Unspecified error.";
}
if (!isset($stop_execution) || !is_bool($stop_execution)) {
$stop_execution = false;
}
if (isset($catched_exception) && !is_null($catched_exception) && !is_object($catched_exception)) {
$catched_exception = null;
}
// If in test-mode, just throw the exception and return.
// It is then phpunits job to pick up the exception.
if (MainController::inTestMode()) {
throw new ExceptionController($text, $catched_exception);
return;
}
try {
throw new ExceptionController($text, $catched_exception);
} catch (\Thallium\Controllers\ExceptionController $e) {
if ($e->printsJson()) {
print $e;
exit(1);
}
// if Previous exceptions have been captured, first display that ones.
$prev = $e;
while ($prev = $prev->getPrevious()) {
print $prev;
}
// now finally print the actually captured exception.
print $e;
}
if ($stop_execution === true) {
trigger_error("Execution stopped.", E_USER_ERROR);
}
return;
}
示例2: setup
/**
* this is the public accessible method that triggers the installation process.
*
* @param none
* @return bool
* @throws \Thallium\Controllers\ExceptionController if an error occurs.
*/
public function setup()
{
global $db, $config;
if ($db->checkTableExists("TABLEPREFIXmeta")) {
if (($this->schema_version_before = $db->getApplicationDatabaseSchemaVersion()) === false) {
static::raiseError(get_class($db) . '::getApplicationDatabaseSchemaVersion() returned false!');
return false;
}
if (($this->framework_schema_version_before = $db->getFrameworkDatabaseSchemaVersion()) === false) {
static::raiseError(get_class($db) . '::getFrameworkDatabaseSchemaVersion() returned false!');
return false;
}
}
if (!isset($this->schema_version_before)) {
$this->schema_version_before = 0;
}
if (!isset($this->framework_schema_version_before)) {
$this->framework_schema_version_before = 0;
}
if ($this->schema_version_before < $db->getApplicationSoftwareSchemaVersion() || $this->framework_schema_version_before < $db->getFrameworkSoftwareSchemaVersion()) {
if (!$this->createDatabaseTables()) {
static::raiseError(__CLASS__ . '::createDatabaseTables() returned false!');
return false;
}
}
if ($db->getApplicationDatabaseSchemaVersion() < $db->getApplicationSoftwareSchemaVersion() || $db->getFrameworkDatabaseSchemaVersion() < $db->getFrameworkSoftwareSchemaVersion()) {
if (!$this->upgradeDatabaseSchema()) {
static::raiseError(__CLASS__ . '::upgradeDatabaseSchema() returned false!');
return false;
}
}
if (MainController::inTestMode()) {
return true;
}
if (!empty($this->schema_version_before)) {
printf('Application database schema version before upgrade: %s<br />', $this->schema_version_before);
}
printf('Application software supported schema version: %s<br />', $db->getApplicationSoftwareSchemaVersion());
printf('Application database schema version after upgrade: %s<br />', $db->getApplicationDatabaseSchemaVersion());
print '<br /><br />';
if (!empty($this->framework_schema_version_before)) {
printf('Framework database schema version before upgrade: %s<br />', $this->framework_schema_version_before);
}
printf('Framework software supported schema version: %s<br />', $db->getFrameworkSoftwareSchemaVersion());
printf('Framework database schema version after upgrade: %s<br />', $db->getFrameworkDatabaseSchemaVersion());
if (($base_path = $config->getWebPath()) === true) {
static::raiseError(get_class($config) . '"::getWebPath() returned false!');
return false;
}
printf('<br /><a href="%s">Return to application</a><br />', $base_path);
return true;
}