public function test_getStatus_shouldReturnTheWorstStatus()
 {
     $result = new DiagnosticResult('Label');
     $this->assertEquals(DiagnosticResult::STATUS_OK, $result->getStatus());
     $result->addItem(new DiagnosticResultItem(DiagnosticResult::STATUS_WARNING));
     $this->assertEquals(DiagnosticResult::STATUS_WARNING, $result->getStatus());
     $result->addItem(new DiagnosticResultItem(DiagnosticResult::STATUS_ERROR));
     $this->assertEquals(DiagnosticResult::STATUS_ERROR, $result->getStatus());
 }
    public function execute()
    {
        $label = $this->translator->translate('Installation_SystemCheckExtensions');

        $result = new DiagnosticResult($label);
        $longErrorMessage = '';

        $requiredExtensions = $this->getRequiredExtensions();

        foreach ($requiredExtensions as $extension) {
            if (! extension_loaded($extension)) {
                $status = DiagnosticResult::STATUS_ERROR;
                $comment = $extension . ': ' . $this->translator->translate('Installation_RestartWebServer');
                $longErrorMessage .= '<p>' . $this->getHelpMessage($extension) . '</p>';
            } else {
                $status = DiagnosticResult::STATUS_OK;
                $comment = $extension;
            }

            $result->addItem(new DiagnosticResultItem($status, $comment));
        }

        $result->setLongErrorMessage($longErrorMessage);

        return array($result);
    }
 public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckWriteDirs');
     $result = new DiagnosticResult($label);
     $directories = Filechecks::checkDirectoriesWritable($this->getDirectories());
     $error = false;
     foreach ($directories as $directory => $isWritable) {
         if ($isWritable) {
             $status = DiagnosticResult::STATUS_OK;
         } else {
             $status = DiagnosticResult::STATUS_ERROR;
             $error = true;
         }
         $result->addItem(new DiagnosticResultItem($status, $directory));
     }
     if ($error) {
         $longErrorMessage = $this->translator->translate('Installation_SystemCheckWriteDirsHelp');
         $longErrorMessage .= '<ul>';
         foreach ($directories as $directory => $isWritable) {
             if (!$isWritable) {
                 $longErrorMessage .= sprintf('<li><pre>chmod a+w %s</pre></li>', $directory);
             }
         }
         $longErrorMessage .= '</ul>';
         $result->setLongErrorMessage($longErrorMessage);
     }
     return array($result);
 }
Exemple #4
0
    public function execute()
    {
        $label = $this->translator->translate('Installation_SystemCheckSettings');

        $result = new DiagnosticResult($label);

        foreach ($this->getRequiredSettings() as $setting) {
            list($settingName, $requiredValue) = explode('=', $setting);

            $currentValue = (int) ini_get($settingName);

            if ($currentValue != $requiredValue) {
                $status = DiagnosticResult::STATUS_ERROR;
                $comment = sprintf(
                    '%s <br/><br/><em>%s</em><br/><em>%s</em><br/>',
                    $setting,
                    $this->translator->translate('Installation_SystemCheckPhpSetting', array($setting)),
                    $this->translator->translate('Installation_RestartWebServer')
                );
            } else {
                $status = DiagnosticResult::STATUS_OK;
                $comment = $setting;
            }

            $result->addItem(new DiagnosticResultItem($status, $comment));
        }

        return array($result);
    }
 public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckOtherFunctions');
     $result = new DiagnosticResult($label);
     foreach ($this->getRecommendedFunctions() as $function) {
         if (!PhpFunctionsCheck::functionExists($function)) {
             $status = DiagnosticResult::STATUS_WARNING;
             $comment = $function . '<br/>' . $this->getHelpMessage($function);
         } else {
             $status = DiagnosticResult::STATUS_OK;
             $comment = $function;
         }
         $result->addItem(new DiagnosticResultItem($status, $comment));
     }
     return array($result);
 }
 public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckFunctions');
     $result = new DiagnosticResult($label);
     foreach ($this->getRequiredFunctions() as $function) {
         if (!self::functionExists($function)) {
             $status = DiagnosticResult::STATUS_ERROR;
             $comment = sprintf('%s <br/><br/><em>%s</em><br/><em>%s</em><br/>', $function, $this->getHelpMessage($function), $this->translator->translate('Installation_RestartWebServer'));
         } else {
             $status = DiagnosticResult::STATUS_OK;
             $comment = $function;
         }
         $result->addItem(new DiagnosticResultItem($status, $comment));
     }
     return array($result);
 }
 public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckOtherExtensions');
     $result = new DiagnosticResult($label);
     $loadedExtensions = @get_loaded_extensions();
     foreach ($this->getRecommendedExtensions() as $extension) {
         if (!in_array($extension, $loadedExtensions)) {
             $status = DiagnosticResult::STATUS_WARNING;
             $comment = $extension . '<br/>' . $this->getHelpMessage($extension);
         } else {
             $status = DiagnosticResult::STATUS_OK;
             $comment = $extension;
         }
         $result->addItem(new DiagnosticResultItem($status, $comment));
     }
     return array($result);
 }