/** * Calling json_encode on the error stack should return a array with objects containing the message and the error code */ public function testJson() { $errorStack = new ErrorStack(); $errorStack->addError('Foo', 123); $errorStack->addError('Bar', 456); $this->assertEquals('[{"message":"Foo","code":123},{"message":"Bar","code":456}]', json_encode($errorStack)); }
function InstallerEngine($config) { if (!is_a($config, 'InstallerConfig')) { ErrorStack::addError("Invalid configuration object passed in!", ERRORSTACK_FATAL, 'InstallerEngine'); } $this->config = $config; $this->phase = 0; }
function DBVersionUnder($params) { parent::BaseTest($params); if (!is_array($this->params) || count($this->params) <= 0) { ErrorStack::addError("Invalid parameters, you need to provide the field names and version", ERRORSTACK_ERROR, 'DBVersionUnder'); $this->result = INSTALLER_TEST_FAIL; return $this->result; } }
function AdminPasswordConfirmed($params) { parent::BaseTest($params); if (!is_array($this->params) || count($this->params) <= 0) { ErrorStack::addError("Invalid parameters, you need to provide the password field names", ERRORSTACK_ERROR, 'AdminPasswordConfirmed'); $this->result = INSTALLER_TEST_FAIL; return $this->result; } }
function PHPVersionUnder($params) { parent::BaseTest($params); if (!is_array($this->params) || count($this->params) <= 0) { ErrorStack::addError("Invalid parameters, version to test against must be supplied as the only item in an array", ERRORSTACK_ERROR, 'PHPVersionUnder'); $this->result = INSTALLER_TEST_FAIL; return $this->result; } }
function WritableLocation($params) { parent::BaseTest($params); if (!is_array($this->params) || count($this->params) <= 0) { ErrorStack::addError("Invalid parameters, you must provide at least one location to test.", ERRORSTACK_ERROR, 'WritableLocation'); $this->result = INSTALLER_TEST_FAIL; return $this->result; } }
function toString() { $string = ''; if (!empty($this->class_name)) { $string = ErrorStack::levelToString($this->level) . ": {$this->class_name}: {$this->message}"; } else { $string = ErrorStack::levelToString($this->level) . ": {$this->message}"; } return $string; }
function PHPMagicQuotes($params) { parent::BaseTest($params); if (is_array($this->params) || count($this->params) < 0) { if ($params[0] != "On" && $params[0] != "Off") { ErrorStack::addError("Invalid parameters, must be On or Off", ERRORSTACK_ERROR, 'PHPMagicQuotes'); } $this->result = INSTALLER_TEST_FAIL; return $this->result; } }
function AcceptText($title, $params) { parent::BaseAction($title, $params); $this->interactive = true; $this->grouping = false; if (!is_array($params) || count($params) <= 0) { $this->result = INSTALLER_ACTION_FAIL; $this->result_message = "Invalid parameters passed to AcceptText action, filename is required."; ErrorStack::addError($this->result_message, ERRORSTACK_ERROR, 'AcceptText'); } else { $this->file_name = $params[0]; } }
function getActionPath($class_name) { if (isset($GLOBALS['INSTALLER']['ACTION_DIRS']) && is_array($GLOBALS['INSTALLER']['ACTION_DIRS'])) { foreach ($GLOBALS['INSTALLER']['ACTION_DIRS'] as $dir) { if (file_exists($dir . '/' . $class_name . '.php')) { return $dir . '/' . $class_name . '.php'; } } } if (file_exists(INSTALLER_PATH . '/actions/' . $class_name . '.php')) { return INSTALLER_PATH . '/actions/' . $class_name . '.php'; } ErrorStack::addError("Could not find file for Action class {$class_name}", ERRORSTACK_FATAL, 'Installer'); return FALSE; }
function parseVersionFile() { include $this->version_file_name; if (isset($versions)) { $this->settings['VERSION_SET'] =& $versions; } else { ErrorStack::addError("\$versions is not defined in the version file {$this->version_file_name}", ERRORSTACK_FATAL, 'InstallerConfig'); } }