+ public function checkGit()
+ {
+ $line = exec('git --version', $lines, $retval);
+ if ($retval !== 0) {
+ $this->fail('Running git executable failed.');
+ }
+ if (!preg_match('#^git version ([0-9.]+(rc[0-9]+)?)(?: \(Apple Git-\d+\))?$#', $line, $matches)) {
+ $this->fail('git version output format unexpected: ' . $line);
+ return;
+ }
+ if (version_compare($matches[1], '1.7.5') < 0) {
+ $this->fail(
+ 'git version needs to be at least 1.7.5, got: ' . $matches[1]
+ );
+ }
+ }
+
+ public function checkDatabase()
+ {
+ if ($this->elasticsearch == '') {
+ return;
+ }
+
+ $es = parse_url($this->elasticsearch);
+ if (!preg_match("#/.+/#", $es['path'], $matches)) {
+ $this->fail(
+ 'Improper elasticsearch url. Elasticsearch requires a'
+ . ' search domain to store your data.'
+ . ' (e.g. http://localhost:9200/phorkie/)'
+ );
+ }
+ $dbs = new Database();
+ $dbs->getSetup()->setup();
+ }
+
+ public function checkMimeTypeDetection()
+ {
+ $rp = new Repository_Post();
+ $type = $rp->getType('<?php echo "foo"; ?>', true);
+ if ($type != 'php') {
+ $msg = 'MIME type detection fails';
+ if ($type instanceof \PEAR_Error) {
+ $msg .= '. Error: ' . $type->getMessage();
+ }
+ $this->fail($msg);
+ }
+ }
+
+ public function checkRemoteForking()
+ {
+ if (!isset($GLOBALS['phorkie']['cfg']['git']['public'])
+ || $GLOBALS['phorkie']['cfg']['git']['public'] == ''
+ ) {
+ $this->fail(
+ 'No public git URL prefix configured.'
+ . ' Remote forking will not work'
+ );
+ }
+ }
+