public function testLogging() { $project = new Xinc_Project(); $name = 'test ' . rand(21213, 123213); $project->setName($name); $message = 'info ' . rand(3123123, 123123213); $project->info($message); $this->assertTrue(strpos(Xinc_StreamLogger::getLastLogMessage(), $message) !== false, 'Last message should contain message'); $message = 'debug ' . rand(3123123, 123123213); $project->debug($message); $this->assertTrue(strpos(Xinc_StreamLogger::getLastLogMessage(), $message) !== false, 'Last message should contain message'); $message = 'warn ' . rand(3123123, 123123213); $project->warn($message); $this->assertTrue(strpos(Xinc_StreamLogger::getLastLogMessage(), $message) !== false, 'Last message should contain message'); $message = 'error ' . rand(3123123, 123123213); $project->error($message); $this->assertTrue(strpos(Xinc_StreamLogger::getLastLogMessage(), $message) !== false, 'Last message should contain message'); Xinc_Logger::getInstance()->setLogLevel(Xinc_Logger::LOG_LEVEL_VERBOSE); $message = 'verbose ' . rand(3123123, 123123213); ob_start(); $project->verbose($message); $contents = ob_get_clean(); $lastMsg = Xinc_StreamLogger::getLastLogMessage(); Xinc_Logger::getInstance()->setLogLevel(Xinc_Logger::LOG_LEVEL_DEBUG); $this->assertTrue(strpos($lastMsg, $message) !== false, 'Last message should contain message'); //$this->assertEquals($lastMsg, $contents, // 'Last message should contain message'); }
public function email(Xinc_Project $project, $to, $subject, $message, $from = 'Xinc') { if (empty($from)) { $from = $this->_defaultFrom; } $project->info('Executing email publisher with content ' . "\nTo: " . $to . "\nSubject: " . $subject . "\nMessage: " . $message . "\nFrom: " . $from); /** send the email */ @(include_once 'Mail.php'); if (class_exists('Mail')) { return $this->_sendPearMail($from, $to, $subject, $message); } else { $res = mail($to, $subject, $message, "From: {$from}\r\n"); if ($res) { $project->info('Email sent successfully'); return true; } else { $project->error('Email could not be sent'); return false; //$project->setStatus(Xinc_Build_Interface::FAILED); } } }
public static function getLastSuccessfulBuildTime(Xinc_Project &$project) { $projectName = $project->getName(); $statusDir = self::_getStatusDir(); $historyFile = $statusDir . DIRECTORY_SEPARATOR . $projectName . '.history'; if (file_exists($historyFile)) { $buildHistoryArr = @unserialize(file_get_contents($historyFile)); if ($buildHistoryArr === false) { throw new Xinc_Build_Exception_Unserialization($project, null); } else { if (isset($buildHistoryArr['meta'])) { //$metaFileArr['lastSuccessfulBuild'] if (isset($buildHistoryArr['lastSuccessfulBuild'])) { return $buildHistoryArr['lastSuccessfulBuild']['buildtime']; } else { $project->error('Cannot get last successful build. Using last build instead'); return self::getLastBuildTime($project); } } else { self::_migrate($projectName, $buildHistoryArr); return self::getLastBuildTime($project); /**$keys = array_keys($buildHistoryArr); $lastTimestamp = $buildHistoryArr[$keys[count($keys)-1]];*/ } } } else { $lastTimestamp = null; } return $lastTimestamp; }