[TASK][INSTALL] Extract status objects to own namespace 61/20561/4
authorChristian Kuhn <lolli@schwarzbu.ch>
Mon, 6 May 2013 20:29:36 +0000 (22:29 +0200)
committerPhilipp Gampe <philipp.gampe@typo3.org>
Tue, 7 May 2013 19:13:51 +0000 (21:13 +0200)
With 6.1 status classes were introduced within the system environment
check that represent the different fail severities.

These objects are pretty useful within ext:install and could be used
as common helper encapsulating all status tasks.

The patch moves the status classes out of the system environment
check to an own namespace within ext:install and adds a utility class
that helps with rendering, filtering and sorting.

Change-Id: Id5c6efb567c9b88b7255a1b8ba5a620ed75a7cd3
Resolves: #47999
Releases: 6.2
Reviewed-on: https://review.typo3.org/20561
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
20 files changed:
typo3/sysext/install/Classes/Installer.php
typo3/sysext/install/Classes/Report/EnvironmentStatusReport.php
typo3/sysext/install/Classes/Status/AbstractStatus.php [new file with mode: 0644]
typo3/sysext/install/Classes/Status/ErrorStatus.php [new file with mode: 0644]
typo3/sysext/install/Classes/Status/Exception.php [new file with mode: 0644]
typo3/sysext/install/Classes/Status/InfoStatus.php [new file with mode: 0644]
typo3/sysext/install/Classes/Status/NoticeStatus.php [new file with mode: 0644]
typo3/sysext/install/Classes/Status/OkStatus.php [new file with mode: 0644]
typo3/sysext/install/Classes/Status/StatusInterface.php [new file with mode: 0644]
typo3/sysext/install/Classes/Status/StatusUtility.php [new file with mode: 0644]
typo3/sysext/install/Classes/Status/WarningStatus.php [new file with mode: 0644]
typo3/sysext/install/Classes/SystemEnvironment/AbstractStatus.php [deleted file]
typo3/sysext/install/Classes/SystemEnvironment/Check.php
typo3/sysext/install/Classes/SystemEnvironment/ErrorStatus.php [deleted file]
typo3/sysext/install/Classes/SystemEnvironment/InfoStatus.php [deleted file]
typo3/sysext/install/Classes/SystemEnvironment/NoticeStatus.php [deleted file]
typo3/sysext/install/Classes/SystemEnvironment/OkStatus.php [deleted file]
typo3/sysext/install/Classes/SystemEnvironment/StatusInterface.php [deleted file]
typo3/sysext/install/Classes/SystemEnvironment/WarningStatus.php [deleted file]
typo3/sysext/install/Tests/Unit/Status/StatusUtilityTest.php [new file with mode: 0644]

index 219cca5..56316ac 100644 (file)
@@ -1329,50 +1329,17 @@ REMOTE_ADDR was \'' . GeneralUtility::getIndpEnv('REMOTE_ADDR') . '\' (' . Gener
         * Show system environment check
         */
        protected function systemEnvironmentCheck() {
+               $html = '<h3>System environment check</h3>';
+
                /** @var $statusCheck \TYPO3\CMS\Install\SystemEnvironment\Check */
                $statusCheck = GeneralUtility::makeInstance('TYPO3\\CMS\\Install\\SystemEnvironment\\Check');
                $statusObjects = $statusCheck->getStatus();
 
-               $orderedStatus = array(
-                       'error' => array(),
-                       'warning' => array(),
-                       'ok' => array(),
-                       'information' => array(),
-                       'notice' => array(),
-               );
-
-               /** @var $statusObject \TYPO3\CMS\Install\SystemEnvironment\AbstractStatus */
-               foreach ($statusObjects as $statusObject) {
-                       $severityIdentifier = $statusObject->getSeverity();
-
-                       if (empty($severityIdentifier) || !is_array($orderedStatus[$severityIdentifier])) {
-                               throw new \TYPO3\CMS\Install\Exception('Unknown status severity type', 1362602559);
-                       }
-                       $orderedStatus[$severityIdentifier][] = $statusObject;
-               }
-
-               $messageHtmlBoilerPlate =
-                       '<div class="typo3-message message-%1s" >' .
-                               '<div class="header-container" >' .
-                                       '<div class="message-header message-left" ><strong>%2s</strong></div>' .
-                                       '<div class="message-header message-right" ></div>' .
-                               '</div >' .
-                               '<div class="message-body" >%3s</div>' .
-                       '</div>' .
-                       '<p></p>';
-
-               $html = '<h3>System environment check</h3>';
-               foreach ($orderedStatus as $severity) {
-                       foreach ($severity as $status) {
-                               /** @var $status \TYPO3\CMS\Install\SystemEnvironment\AbstractStatus */
-                               $severityIdentifier = $status->getSeverity();
-                               $html .= sprintf(
-                                       $messageHtmlBoilerPlate,
-                                       $severityIdentifier,
-                                       $status->getTitle(),
-                                       $status->getMessage()
-                               );
-                       }
+               /** @var $statusUtility \TYPO3\CMS\Install\Status\StatusUtility */
+               $statusUtility = GeneralUtility::makeInstance('TYPO3\\CMS\\Install\\Status\\StatusUtility');
+               $sortedStatusObjects = $statusUtility->sortBySeverity($statusObjects);
+               foreach ($sortedStatusObjects as $statusObjectsOfOneSeverity) {
+                       $html .= $statusUtility->renderStatusObjectsAsHtml($statusObjectsOfOneSeverity);
                }
 
                $this->output($this->outputWrapper($html));
index 6a6140f..668b984 100644 (file)
@@ -50,7 +50,7 @@ class EnvironmentStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterf
                        'notice' => array(),
                );
 
-               /** @var $statusObject \TYPO3\CMS\Install\SystemEnvironment\AbstractStatus */
+               /** @var $statusObject \TYPO3\CMS\Install\Status\AbstractStatus */
                foreach ($statusObjects as $statusObject) {
                        $severityIdentifier = $statusObject->getSeverity();
                        if (empty($severityIdentifier) || !is_array($reportStatusTypes[$severityIdentifier])) {
diff --git a/typo3/sysext/install/Classes/Status/AbstractStatus.php b/typo3/sysext/install/Classes/Status/AbstractStatus.php
new file mode 100644 (file)
index 0000000..6eda79b
--- /dev/null
@@ -0,0 +1,92 @@
+<?php
+namespace TYPO3\CMS\Install\Status;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Abstract status
+ *
+ * @author Christian Kuhn <lolli@schwarzbu.ch>
+ */
+abstract class AbstractStatus implements StatusInterface {
+
+       /**
+        * @var string Severity
+        */
+       protected $severity = '';
+
+       /**
+        * @var string Title
+        */
+       protected $title = '';
+
+       /**
+        * @var string Status message
+        */
+       protected $message = '';
+
+       /**
+        * @return string The severity
+        */
+       public function getSeverity() {
+               return $this->severity;
+       }
+
+       /**
+        * @return string The title
+        */
+       public function getTitle() {
+               return $this->title;
+       }
+
+       /**
+        * Set title
+        *
+        * @param string $title The title
+        * @return void
+        */
+       public function setTitle($title) {
+               $this->title = $title;
+       }
+
+       /**
+        * Get status message
+        *
+        * @return string Status message
+        */
+       public function getMessage() {
+               return $this->message;
+       }
+
+       /**
+        * Set status message
+        *
+        * @param string $message Status message
+        * @return void
+        */
+       public function setMessage($message) {
+               $this->message = $message;
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/install/Classes/Status/ErrorStatus.php b/typo3/sysext/install/Classes/Status/ErrorStatus.php
new file mode 100644 (file)
index 0000000..bb7e447
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+namespace TYPO3\CMS\Install\Status;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Error level status
+ *
+ * @author Christian Kuhn <lolli@schwarzbu.ch>
+ */
+class ErrorStatus extends AbstractStatus implements StatusInterface {
+
+       /**
+        * @var string The severity
+        */
+       protected $severity = 'error';
+
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/install/Classes/Status/Exception.php b/typo3/sysext/install/Classes/Status/Exception.php
new file mode 100644 (file)
index 0000000..0a55144
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+namespace TYPO3\CMS\Install\Status;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * A status exception
+ */
+class Exception extends \TYPO3\CMS\Install\Exception {
+
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/install/Classes/Status/InfoStatus.php b/typo3/sysext/install/Classes/Status/InfoStatus.php
new file mode 100644 (file)
index 0000000..ca254df
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+namespace TYPO3\CMS\Install\Status;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Info level status
+ *
+ * @author Christian Kuhn <lolli@schwarzbu.ch>
+ */
+class InfoStatus extends AbstractStatus implements StatusInterface {
+
+       /**
+        * @var string The severity
+        */
+       protected $severity = 'information';
+
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/install/Classes/Status/NoticeStatus.php b/typo3/sysext/install/Classes/Status/NoticeStatus.php
new file mode 100644 (file)
index 0000000..02efe63
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+namespace TYPO3\CMS\Install\Status;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Notice level status
+ *
+ * @author Christian Kuhn <lolli@schwarzbu.ch>
+ */
+class NoticeStatus extends AbstractStatus implements StatusInterface {
+
+       /**
+        * @var string The severity
+        */
+       protected $severity = 'notice';
+
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/install/Classes/Status/OkStatus.php b/typo3/sysext/install/Classes/Status/OkStatus.php
new file mode 100644 (file)
index 0000000..30c93ee
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+namespace TYPO3\CMS\Install\Status;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Ok level status
+ *
+ * @author Christian Kuhn <lolli@schwarzbu.ch>
+ */
+class OkStatus extends AbstractStatus implements StatusInterface {
+
+       /**
+        * @var string The severity
+        */
+       protected $severity = 'ok';
+
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/install/Classes/Status/StatusInterface.php b/typo3/sysext/install/Classes/Status/StatusInterface.php
new file mode 100644 (file)
index 0000000..08c5c24
--- /dev/null
@@ -0,0 +1,71 @@
+<?php
+namespace TYPO3\CMS\Install\Status;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Status interface
+ *
+ * @author Christian Kuhn <lolli@schwarzbu.ch>
+ */
+interface StatusInterface {
+
+       /**
+        * Get severity
+        *
+        * @return string The severity
+        */
+       public function getSeverity();
+
+       /**
+        * Get title
+        *
+        * @return string The title
+        */
+       public function getTitle();
+
+       /**
+        * Set title
+        *
+        * @param string $title The title
+        * @return void
+        */
+       public function setTitle($title);
+
+       /**
+        * Get status message
+        *
+        * @return string Status message
+        */
+       public function getMessage();
+
+       /**
+        * Set status message
+        *
+        * @param string $message Status message
+        * @return void
+        */
+       public function setMessage($message);
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/install/Classes/Status/StatusUtility.php b/typo3/sysext/install/Classes/Status/StatusUtility.php
new file mode 100644 (file)
index 0000000..68ea731
--- /dev/null
@@ -0,0 +1,121 @@
+<?php
+namespace TYPO3\CMS\Install\Status;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Utility methods to handle status objects. Provides some helper
+ * methods to filter, sort and render status objects.
+ */
+class StatusUtility {
+
+       /**
+        * Default constructor
+        */
+       public function __construct() {
+               require_once __DIR__ . '/Exception.php';
+       }
+
+       /**
+        * Render a flat list of status objects
+        *
+        * @param array $statusObjects <\TYPO3\CMS\Install\Status\StatusInterface> $statusObjects
+        * @throws Exception
+        * @return string Rendered objects
+        */
+       public function renderStatusObjectsAsHtml(array $statusObjects = array()) {
+               $messageHtmlBoilerPlate =
+                       '<div class="typo3-message message-%1s" >' .
+                               '<div class="header-container">' .
+                                       '<div class="message-header message-left"><strong>%2s</strong></div>' .
+                                       '<div class="message-header message-right"></div>' .
+                               '</div>' .
+                               '<div class="message-body">%3s</div>' .
+                       '</div>' .
+                       '<p></p>';
+
+               $html = '';
+               foreach ($statusObjects as $status) {
+                       if (!$status instanceof StatusInterface) {
+                               throw new Exception(
+                                       'Object must implement StatusInterface',
+                                       1366919440
+                               );
+                       }
+                       /** @var $status StatusInterface */
+                       $severityIdentifier = $status->getSeverity();
+                       $html .= sprintf(
+                               $messageHtmlBoilerPlate,
+                               $severityIdentifier,
+                               $status->getTitle(),
+                               $status->getMessage()
+                       );
+               }
+               return $html;
+       }
+
+       /**
+        * Order status objects by severity
+        *
+        * @param array<\TYPO3\CMS\Install\Status\StatusInterface> $statusObjects Status objects in random order
+        * @return array With sub arrays by severity
+        * @throws Exception
+        */
+       public function sortBySeverity(array $statusObjects = array()) {
+               $orderedStatus = array(
+                       'error' => $this->filterBySeverity($statusObjects, 'error'),
+                       'warning' => $this->filterBySeverity($statusObjects, 'warning'),
+                       'ok' => $this->filterBySeverity($statusObjects, 'ok'),
+                       'information' => $this->filterBySeverity($statusObjects, 'information'),
+                       'notice' => $this->filterBySeverity($statusObjects, 'notice'),
+               );
+               return $orderedStatus;
+       }
+
+       /**
+        * Filter a list of status objects by severity
+        *
+        * @param array $statusObjects Given list of status objects
+        * @param string $severity Severity identifier
+        * @throws Exception
+        * @return array List of status objects with given severity
+        */
+       public function filterBySeverity(array $statusObjects = array(), $severity = 'ok') {
+               $filteredObjects = array();
+               /** @var $status StatusInterface */
+               foreach ($statusObjects as $status) {
+                       if (!$status instanceof StatusInterface) {
+                               throw new Exception(
+                                       'Object must implement StatusInterface',
+                                       1366919442
+                               );
+                       }
+                       if ($status->getSeverity() === $severity) {
+                               $filteredObjects[] = $status;
+                       }
+               }
+               return $filteredObjects;
+       }
+}
+?>
diff --git a/typo3/sysext/install/Classes/Status/WarningStatus.php b/typo3/sysext/install/Classes/Status/WarningStatus.php
new file mode 100644 (file)
index 0000000..629a1b3
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+namespace TYPO3\CMS\Install\Status;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Warning level status
+ *
+ * @author Christian Kuhn <lolli@schwarzbu.ch>
+ */
+class WarningStatus extends AbstractStatus implements StatusInterface {
+
+       /**
+        * @var string The severity
+        */
+       protected $severity = 'warning';
+
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/install/Classes/SystemEnvironment/AbstractStatus.php b/typo3/sysext/install/Classes/SystemEnvironment/AbstractStatus.php
deleted file mode 100644 (file)
index 8938891..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-<?php
-namespace TYPO3\CMS\Install\SystemEnvironment;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-
-/**
- * Abstract status
- *
- * @author Christian Kuhn <lolli@schwarzbu.ch>
- */
-abstract class AbstractStatus implements StatusInterface {
-
-       /**
-        * @var string Severity
-        */
-       protected $severity = '';
-
-       /**
-        * @var string Title
-        */
-       protected $title = '';
-
-       /**
-        * @var string Status message
-        */
-       protected $message = '';
-
-       /**
-        * @return string The severity
-        */
-       public function getSeverity() {
-               return $this->severity;
-       }
-
-       /**
-        * @return string The title
-        */
-       public function getTitle() {
-               return $this->title;
-       }
-
-       /**
-        * Set title
-        *
-        * @param string $title The title
-        * @return void
-        */
-       public function setTitle($title) {
-               $this->title = $title;
-       }
-
-       /**
-        * Get status message
-        *
-        * @return string Status message
-        */
-       public function getMessage() {
-               return $this->message;
-       }
-
-       /**
-        * Set status message
-        *
-        * @param string $message Status message
-        * @return void
-        */
-       public function setMessage($message) {
-               $this->message = $message;
-       }
-}
-?>
\ No newline at end of file
index f2c467c..02df222 100644 (file)
@@ -24,6 +24,8 @@ namespace TYPO3\CMS\Install\SystemEnvironment;
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
 
+use TYPO3\CMS\Install\Status;
+
 /**
  * Check system environment status
  *
@@ -79,19 +81,19 @@ class Check {
         * Constructor to load further classes
         */
        public function __construct() {
-               require(__DIR__ . '/StatusInterface.php');
-               require(__DIR__ . '/AbstractStatus.php');
-               require(__DIR__ . '/NoticeStatus.php');
-               require(__DIR__ . '/InfoStatus.php');
-               require(__DIR__ . '/OkStatus.php');
-               require(__DIR__ . '/WarningStatus.php');
-               require(__DIR__ . '/ErrorStatus.php');
+               require_once(__DIR__ . '/../Status/StatusInterface.php');
+               require_once(__DIR__ . '/../Status/AbstractStatus.php');
+               require_once(__DIR__ . '/../Status/NoticeStatus.php');
+               require_once(__DIR__ . '/../Status/InfoStatus.php');
+               require_once(__DIR__ . '/../Status/OkStatus.php');
+               require_once(__DIR__ . '/../Status/WarningStatus.php');
+               require_once(__DIR__ . '/../Status/ErrorStatus.php');
        }
 
        /**
         * Get all status information as array with status objects
         *
-        * @return array<\TYPO3\CMS\Install\SystemEnvironment\StatusInterface>
+        * @return array<\TYPO3\CMS\Install\Status\StatusInterface>
         */
        public function getStatus() {
                $statusArray = array();
@@ -134,14 +136,14 @@ class Check {
        /**
         * Checks if current directory (.) is in PHP include path
         *
-        * @return WarningStatus|OkStatus
+        * @return Status\WarningStatus|Status\OkStatus
         */
        protected function checkCurrentDirectoryIsInIncludePath() {
                $includePath = ini_get('include_path');
                $delimiter = $this->isWindowsOs() ? ';' : ':';
                $pathArray = $this->trimExplode($delimiter, $includePath);
                if (!in_array('.', $pathArray)) {
-                       $status = new WarningStatus();
+                       $status = new Status\WarningStatus();
                        $status->setTitle('Current directory (./) is not in include path');
                        $status->setMessage(
                                'include_path = ' . implode(' ', $pathArray) .
@@ -151,7 +153,7 @@ class Check {
                                ' some extensions.'
                        );
                } else {
-                       $status = new OkStatus();
+                       $status = new Status\OkStatus();
                        $status->setTitle('Current directory (./) is in include path.');
                }
                return $status;
@@ -160,11 +162,11 @@ class Check {
        /**
         * Check if file uploads are enabled in PHP
         *
-        * @return ErrorStatus|OkStatus
+        * @return Status\ErrorStatus|Status\OkStatus
         */
        protected function checkFileUploadEnabled() {
                if (!ini_get('file_uploads')) {
-                       $status = new ErrorStatus();
+                       $status = new Status\ErrorStatus();
                        $status->setTitle('File uploads not allowed');
                        $status->setMessage(
                                'file_uploads=' . ini_get('file_uploads') .
@@ -177,7 +179,7 @@ class Check {
                                ' you change the default form encoding value with \\$TYPO3_CONF_VARS[SYS][form_enctype].'
                        );
                } else {
-                       $status = new OkStatus();
+                       $status = new Status\OkStatus();
                        $status->setTitle('File uploads allowed');
                }
                return $status;
@@ -186,12 +188,12 @@ class Check {
        /**
         * Check maximum file upload size against default value of 10MB
         *
-        * @return ErrorStatus|OkStatus
+        * @return Status\ErrorStatus|Status\OkStatus
         */
        protected function checkMaximumFileUploadSize() {
                $maximumUploadFilesize = $this->getBytesFromSizeMeasurement(ini_get('upload_max_filesize'));
                if ($maximumUploadFilesize < 1024 * 1024 * 10) {
-                       $status = new ErrorStatus();
+                       $status = new Status\ErrorStatus();
                        $status->setTitle('Maximum upload filesize too small');
                        $status->setMessage(
                                'upload_max_filesize=' . ini_get('upload_max_filesize') .
@@ -202,7 +204,7 @@ class Check {
                                ' the limits for uploaded filesizes and not TYPO3.'
                        );
                } else {
-                       $status = new OkStatus();
+                       $status = new Status\OkStatus();
                        $status->setTitle('Maximum file upload size is higher or equal to 10MB');
                }
                return $status;
@@ -211,13 +213,13 @@ class Check {
        /**
         * Check maximum post upload size correlates with maximum file upload
         *
-        * @return ErrorStatus|OkStatus
+        * @return Status\ErrorStatus|Status\OkStatus
         */
        protected function checkPostUploadSizeIsHigherOrEqualMaximumFileUploadSize() {
                $maximumUploadFilesize = $this->getBytesFromSizeMeasurement(ini_get('upload_max_filesize'));
                $maximumPostSize = $this->getBytesFromSizeMeasurement(ini_get('post_max_size'));
                if ($maximumPostSize < $maximumUploadFilesize) {
-                       $status = new ErrorStatus();
+                       $status = new Status\ErrorStatus();
                        $status->setTitle('Maximum size for POST requests is smaller than max. upload filesize');
                        $status->setMessage(
                                'upload_max_filesize=' . ini_get('upload_max_filesize') .
@@ -227,7 +229,7 @@ class Check {
                                ' file uploads can not be larger than ' . ini_get('post_max_size') . '.'
                        );
                } else {
-                       $status = new OkStatus();
+                       $status = new Status\OkStatus();
                        $status->setTitle('Maximum post upload size correlates with maximum upload file size');
                }
                return $status;
@@ -236,12 +238,12 @@ class Check {
        /**
         * Check memory settings
         *
-        * @return ErrorStatus|WarningStatus|OkStatus
+        * @return Status\ErrorStatus|Status\WarningStatus|Status\OkStatus
         */
        protected function checkMemorySettings() {
                $memoryLimit = $this->getBytesFromSizeMeasurement(ini_get('memory_limit'));
                if ($memoryLimit <= 0) {
-                       $status = new WarningStatus();
+                       $status = new Status\WarningStatus();
                        $status->setTitle('Unlimited memory limit!');
                        $status->setMessage(
                                'Your webserver is configured to not limit PHP memory usage at all. This is a risk' .
@@ -250,7 +252,7 @@ class Check {
                                ' webserver to raise the limit to something over 64MB'
                        );
                } elseif ($memoryLimit < 1024 * 1024 * 32) {
-                       $status = new ErrorStatus();
+                       $status = new Status\ErrorStatus();
                        $status->setTitle('Memory limit below 32MB');
                        $status->setMessage(
                                'memory_limit=' . ini_get('memory_limit') .
@@ -259,7 +261,7 @@ class Check {
                                ' administrator of the webserver to raise the limit to 64MB.'
                        );
                } elseif ($memoryLimit < 1024 * 1024 * 64) {
-                       $status = new WarningStatus();
+                       $status = new Status\WarningStatus();
                        $status->setTitle('Memory limit below 64MB');
                        $status->setMessage(
                                'memory_limit=' . ini_get('memory_limit') .
@@ -269,7 +271,7 @@ class Check {
                                ' To be on the safe side, it would be better to raise the PHP memory limit to 64MB or more.'
                        );
                } else {
-                       $status = new OkStatus();
+                       $status = new Status\OkStatus();
                        $status->setTitle('Memory limit equal 64MB or more');
                }
                return $status;
@@ -278,21 +280,21 @@ class Check {
        /**
         * Check minimum PHP version
         *
-        * @return ErrorStatus|OkStatus
+        * @return Status\ErrorStatus|Status\OkStatus
         */
        protected function checkPhpVersion() {
                $minimumPhpVersion = '5.3.0';
                $recommendedPhpVersion = '5.3.7';
                $currentPhpVersion = phpversion();
                if (version_compare($currentPhpVersion, $minimumPhpVersion) < 0) {
-                       $status = new ErrorStatus();
+                       $status = new Status\ErrorStatus();
                        $status->setTitle('PHP version too low');
                        $status->setMessage(
                                'Your PHP version ' . $currentPhpVersion . ' is too old. TYPO3 CMS does not run' .
                                ' with this version. Update to at least PHP ' . $recommendedPhpVersion
                        );
                } elseif (version_compare($currentPhpVersion, $recommendedPhpVersion) < 0) {
-                       $status = new WarningStatus();
+                       $status = new Status\WarningStatus();
                        $status->setTitle('PHP version below recommended version');
                        $status->setMessage(
                                'Your PHP version ' . $currentPhpVersion . ' is below the recommended version' .
@@ -302,7 +304,7 @@ class Check {
                                ' out for an upgrade, soon.'
                        );
                } else {
-                       $status = new OkStatus();
+                       $status = new Status\OkStatus();
                        $status->setTitle('PHP version is fine');
                }
                return $status;
@@ -311,14 +313,14 @@ class Check {
        /**
         * Check maximum execution time
         *
-        * @return ErrorStatus|WarningStatus|OkStatus
+        * @return Status\ErrorStatus|Status\WarningStatus|Status\OkStatus
         */
        protected function checkMaxExecutionTime() {
                $minimumMaximumExecutionTime = 30;
                $recommendedMaximumExecutionTime = 240;
                $currentMaximumExecutionTime = ini_get('max_execution_time');
                if ($currentMaximumExecutionTime == 0 && PHP_SAPI !== 'cli') {
-                       $status = new WarningStatus();
+                       $status = new Status\WarningStatus();
                        $status->setTitle('Infinite PHP script execution time');
                        $status->setMessage(
                                'Your max_execution_time is set to 0 (infinite). While TYPO3 is fine' .
@@ -327,7 +329,7 @@ class Check {
                                ' if max_execution_time is reduced to ' . $recommendedMaximumExecutionTime
                        );
                } elseif ($currentMaximumExecutionTime < $minimumMaximumExecutionTime) {
-                       $status = new ErrorStatus();
+                       $status = new Status\ErrorStatus();
                        $status->setTitle('Low PHP script execution time');
                        $status->setMessage(
                                'Your max_execution_time is set to ' . $currentMaximumExecutionTime .
@@ -335,7 +337,7 @@ class Check {
                                ' to raise max_execution_time to ' . $recommendedMaximumExecutionTime
                        );
                } elseif ($currentMaximumExecutionTime < $recommendedMaximumExecutionTime) {
-                       $status = new WarningStatus();
+                       $status = new Status\WarningStatus();
                        $status->setTitle('Low PHP script execution time');
                        $status->setMessage(
                                'Your max_execution_time is set to ' . $currentMaximumExecutionTime .
@@ -345,7 +347,7 @@ class Check {
                                ' and maybe raise the limit to ' . $recommendedMaximumExecutionTime . '.'
                        );
                } else {
-                       $status = new OkStatus();
+                       $status = new Status\OkStatus();
                        $status->setTitle('Maximum PHP script execution equals ' . $recommendedMaximumExecutionTime . ' or more');
                }
                return $status;
@@ -354,7 +356,7 @@ class Check {
        /**
         * Check for disabled functions
         *
-        * @return ErrorStatus|OkStatus
+        * @return Status\ErrorStatus|Status\OkStatus
         */
        protected function checkDisableFunctions() {
                $disabledFunctions = trim(ini_get('disable_functions'));
@@ -376,7 +378,7 @@ class Check {
                }
 
                if (strlen($disabledFunctions) > 0 && count($disabledFunctionsArray) > 0) {
-                       $status = new ErrorStatus();
+                       $status = new Status\ErrorStatus();
                        $status->setTitle('Some PHP functions disabled');
                        $status->setMessage(
                                'disable_functions=' . implode(' ', explode(',', $disabledFunctions)) . '. These function(s)' .
@@ -387,14 +389,14 @@ class Check {
                                ' are disabled, some parts of the system may just break without further notice.'
                        );
                } elseif (strlen($disabledFunctions) > 0 && count($disabledFunctionsArray) === 0) {
-                       $status = new NoticeStatus();
+                       $status = new Status\NoticeStatus();
                        $status->setTitle('Some PHP functions currently disabled but OK');
                        $status->setMessage(
                                'disable_functions=' . implode(' ', explode(',', $disabledFunctions)) . '. These function(s)' .
                                ' are disabled. TYPO3 uses currently none of those, so you are good to go.'
                        );
                } else {
-                       $status  = new OkStatus();
+                       $status  = new Status\OkStatus();
                        $status->setTitle('No disabled PHP functions');
                }
                return $status;
@@ -403,7 +405,7 @@ class Check {
        /**
         * Check if safe mode is enabled
         *
-        * @return ErrorStatus|OkStatus
+        * @return Status\ErrorStatus|Status\OkStatus
         */
        protected function checkSafeMode() {
                $safeModeEnabled = FALSE;
@@ -415,13 +417,13 @@ class Check {
                        );
                }
                if ($safeModeEnabled) {
-                       $status = new ErrorStatus();
+                       $status = new Status\ErrorStatus();
                        $status->setTitle('PHP safe mode on');
                        $status->setMessage(
                                'safe_mode enabled. This is unsupported by TYPO3 CMS, it must be turned off.'
                        );
                } else {
-                       $status = new OkStatus();
+                       $status = new Status\OkStatus();
                        $status->setTitle('PHP safe mode off');
                }
                return $status;
@@ -430,12 +432,12 @@ class Check {
        /**
         * Check for doc_root ini setting
         *
-        * @return NoticeStatus|OkStatus
+        * @return Status\NoticeStatus|Status\OkStatus
         */
        protected function checkDocRoot() {
                $docRootSetting = trim(ini_get('doc_root'));
                if (strlen($docRootSetting) > 0) {
-                       $status = new NoticeStatus();
+                       $status = new Status\NoticeStatus();
                        $status->setTitle('doc_root is set');
                        $status->setMessage(
                                'doc_root=' . $docRootSetting . ' PHP cannot execute scripts' .
@@ -445,7 +447,7 @@ class Check {
                                ' If that is a problem, the setting must be adapted.'
                        );
                } else {
-                       $status = new OkStatus();
+                       $status = new Status\OkStatus();
                        $status->setTitle('PHP doc_root is not set');
                }
                return $status;
@@ -454,7 +456,7 @@ class Check {
        /**
         * Check sql.safe_mode
         *
-        * @return OkStatus|WarningStatus
+        * @return Status\OkStatus|Status\WarningStatus
         */
        protected function checkSqlSafeMode() {
                $sqlSafeModeEnabled = FALSE;
@@ -466,7 +468,7 @@ class Check {
                        );
                }
                if ($sqlSafeModeEnabled) {
-                       $status = new WarningStatus();
+                       $status = new Status\WarningStatus();
                        $status->setTitle('sql.safe_mode is enabled');
                        $status->setMessage(
                                'This means that you can only connect to the database with a' .
@@ -475,7 +477,7 @@ class Check {
                                ' The owner of the current file is: ' . get_current_user()
                        );
                } else {
-                       $status = new OkStatus();
+                       $status = new Status\OkStatus();
                        $status->setTitle('PHP sql.safe_mode is off');
                }
                return $status;
@@ -484,12 +486,12 @@ class Check {
        /**
         * Check open_basedir
         *
-        * @return NoticeStatus|OkStatus
+        * @return Status\NoticeStatus|Status\OkStatus
         */
        protected function checkOpenBaseDir() {
                $openBaseDirSetting = trim(ini_get('open_basedir'));
                if (strlen($openBaseDirSetting) > 0) {
-                       $status = new NoticeStatus();
+                       $status = new Status\NoticeStatus();
                        $status->setTitle('open_basedir set');
                        $status->setMessage(
                                'open_basedir = ' . ini_get('open_basedir') .
@@ -499,7 +501,7 @@ class Check {
                                ' not included in this path.'
                        );
                } else {
-                       $status = new OkStatus();
+                       $status = new Status\OkStatus();
                        $status->setTitle('PHP open_basedir is off');
                }
                return $status;
@@ -513,10 +515,10 @@ class Check {
                        $testKey = @openssl_pkey_new();
                        if (is_resource($testKey)) {
                                openssl_free_key($testKey);
-                               $status = new OkStatus();
+                               $status = new Status\OkStatus();
                                $status->setTitle('OpenSSL installed properly');
                        } else {
-                               $status = new ErrorStatus();
+                               $status = new Status\ErrorStatus();
                                $status->setTitle('OpenSSL extension not working');
                                $status->setMessage(
                                        'Something went wrong while trying to create a new private key. ' .
@@ -524,7 +526,7 @@ class Check {
                                );
                        }
                } else {
-                       $status = new ErrorStatus();
+                       $status = new Status\ErrorStatus();
                        $status->setTitle('OpenSSL extension not loaded');
                        $status->setMessage(
                                'OpenSSL is an extension to encrypt/decrypt data between requests. ' .
@@ -538,14 +540,14 @@ class Check {
        /**
         * Check enabled suhosin
         *
-        * @return NoticeStatus|OkStatus
+        * @return Status\NoticeStatus|Status\OkStatus
         */
        protected function checkSuhosinLoaded() {
                if ($this->isSuhosinLoaded()) {
-                       $status = new OkStatus();
+                       $status = new Status\OkStatus();
                        $status->setTitle('PHP suhosin extension loaded');
                } else {
-                       $status = new NoticeStatus();
+                       $status = new Status\NoticeStatus();
                        $status->setTitle('PHP suhosin extension not loaded');
                        $status->setMessage(
                                'suhosin is an extension to harden the PHP environment. In general, it is' .
@@ -560,14 +562,14 @@ class Check {
        /**
         * Check suhosin.request.max_vars
         *
-        * @return ErrorStatus|InfoStatus|OkStatus
+        * @return Status\ErrorStatus|Status\InfoStatus|Status\OkStatus
         */
        protected function checkSuhosinRequestMaxVars() {
                $recommendedRequestMaxVars = 400;
                if ($this->isSuhosinLoaded()) {
                        $currentRequestMaxVars = ini_get('suhosin.request.max_vars');
                        if ($currentRequestMaxVars < $recommendedRequestMaxVars) {
-                               $status = new ErrorStatus();
+                               $status = new Status\ErrorStatus();
                                $status->setTitle('PHP suhosin.request.max_vars not high enough');
                                $status->setMessage(
                                        'suhosin.request.max_vars=' . $currentRequestMaxVars . '. This setting' .
@@ -576,11 +578,11 @@ class Check {
                                        ' to at least ' . $recommendedRequestMaxVars
                                );
                        } else {
-                               $status = new OkStatus();
+                               $status = new Status\OkStatus();
                                $status->setTitle('PHP suhosin.request.max_vars ok');
                        }
                } else {
-                       $status = new InfoStatus();
+                       $status = new Status\InfoStatus();
                        $status->setTitle('Suhosin not loaded');
                        $status->setMessage(
                                'If enabling suhosin, suhosin.request.max_vars' .
@@ -593,14 +595,14 @@ class Check {
        /**
         * Check suhosin.post.max_vars
         *
-        * @return ErrorStatus|InfoStatus|OkStatus
+        * @return Status\ErrorStatus|Status\InfoStatus|Status\OkStatus
         */
        protected function checkSuhosinPostMaxVars() {
                $recommendedPostMaxVars = 400;
                if ($this->isSuhosinLoaded()) {
                        $currentPostMaxVars = ini_get('suhosin.post.max_vars');
                        if ($currentPostMaxVars < $recommendedPostMaxVars) {
-                               $status = new ErrorStatus();
+                               $status = new Status\ErrorStatus();
                                $status->setTitle('PHP suhosin.post.max_vars not high enough');
                                $status->setMessage(
                                        'suhosin.post.max_vars=' . $currentPostMaxVars . '. This setting' .
@@ -609,11 +611,11 @@ class Check {
                                        ' to at least ' . $recommendedPostMaxVars . '.'
                                );
                        } else {
-                               $status = new OkStatus();
+                               $status = new Status\OkStatus();
                                $status->setTitle('PHP suhosin.post.max_vars ok');
                        }
                } else {
-                       $status = new InfoStatus();
+                       $status = new Status\InfoStatus();
                        $status->setTitle('Suhosin not loaded');
                        $status->setMessage(
                                'If enabling suhosin, suhosin.post.max_vars' .
@@ -626,14 +628,14 @@ class Check {
        /**
         * Check suhosin.get.max_value_length
         *
-        * @return ErrorStatus|InfoStatus|OkStatus
+        * @return Status\ErrorStatus|Status\InfoStatus|Status\OkStatus
         */
        protected function checkSuhosinGetMaxValueLength() {
                $recommendedGetMaxValueLength = 2000;
                if ($this->isSuhosinLoaded()) {
                        $currentGetMaxValueLength = ini_get('suhosin.get.max_value_length');
                        if ($currentGetMaxValueLength < $recommendedGetMaxValueLength) {
-                               $status = new ErrorStatus();
+                               $status = new Status\ErrorStatus();
                                $status->setTitle('PHP suhosin.get.max_value_length not high enough');
                                $status->setMessage(
                                        'suhosin.get.max_value_length=' . $currentGetMaxValueLength . '. This setting' .
@@ -642,11 +644,11 @@ class Check {
                                        ' to at least ' . $recommendedGetMaxValueLength . '.'
                                );
                        } else {
-                               $status = new OkStatus();
+                               $status = new Status\OkStatus();
                                $status->setTitle('PHP suhosin.get.max_value_length ok');
                        }
                } else {
-                       $status = new InfoStatus();
+                       $status = new Status\InfoStatus();
                        $status->setTitle('Suhosin not loaded');
                        $status->setMessage(
                                'If enabling suhosin, suhosin.get.max_value_length' .
@@ -659,13 +661,13 @@ class Check {
        /**
         * Check suhosin.executor.include.whitelist contains phar
         *
-        * @return NoticeStatus|InfoStatus|OkStatus
+        * @return Status\NoticeStatus|Status\InfoStatus|Status\OkStatus
         */
        protected function checkSuhosinExecutorIncludeWhiteListContainsPhar() {
                if ($this->isSuhosinLoaded()) {
                        $currentWhiteListArray = $this->trimExplode(' ', ini_get('suhosin.executor.include.whitelist'));
                        if (!in_array('phar', $currentWhiteListArray)) {
-                               $status = new NoticeStatus();
+                               $status = new Status\NoticeStatus();
                                $status->setTitle('PHP suhosin.executor.include.whitelist does not contain phar');
                                $status->setMessage(
                                        'suhosin.executor.include.whitelist= ' . implode(' ', $currentWhiteListArray) . '. phar' .
@@ -673,11 +675,11 @@ class Check {
                                        ' in future versions. A useful setting is "suhosin.executor.include.whitelist = phar vfs".'
                                );
                        } else {
-                               $status = new OkStatus();
+                               $status = new Status\OkStatus();
                                $status->setTitle('PHP suhosin.executor.include.whitelist contains phar');
                        }
                } else {
-                       $status = new InfoStatus();
+                       $status = new Status\InfoStatus();
                        $status->setTitle('Suhosin not loaded');
                        $status->setMessage(
                                'If enabling suhosin, a useful setting is "suhosin.executor.include.whitelist = phar vfs".'
@@ -689,13 +691,13 @@ class Check {
        /**
         * Check suhosin.executor.include.whitelist contains vfs
         *
-        * @return NoticeStatus|InfoStatus|OkStatus
+        * @return Status\NoticeStatus|Status\InfoStatus|Status\OkStatus
         */
        protected function checkSuhosinExecutorIncludeWhiteListContainsVfs() {
                if ($this->isSuhosinLoaded()) {
                        $currentWhiteListArray = $this->trimExplode(' ', ini_get('suhosin.executor.include.whitelist'));
                        if (!in_array('vfs', $currentWhiteListArray)) {
-                               $status = new WarningStatus();
+                               $status = new Status\WarningStatus();
                                $status->setTitle('PHP suhosin.executor.include.whitelist does not contain vfs');
                                $status->setMessage(
                                        'suhosin.executor.include.whitelist= ' . implode(' ', $currentWhiteListArray) . '. vfs' .
@@ -704,11 +706,11 @@ class Check {
                                        ' A useful setting is "suhosin.executor.include.whitelist = phar vfs".'
                                );
                        } else {
-                               $status = new OkStatus();
+                               $status = new Status\OkStatus();
                                $status->setTitle('PHP suhosin.executor.include.whitelist contains vfs');
                        }
                } else {
-                       $status = new InfoStatus();
+                       $status = new Status\InfoStatus();
                        $status->setTitle('Suhosin not loaded');
                        $status->setMessage(
                                'If enabling suhosin, a useful setting is "suhosin.executor.include.whitelist = phar vfs".'
@@ -720,7 +722,7 @@ class Check {
        /**
         * Check if some opcode cache is loaded
         *
-        * @return WarningStatus|OkStatus
+        * @return Status\WarningStatus|Status\OkStatus
         */
        protected function checkSomePhpOpcodeCacheIsLoaded() {
                if (
@@ -732,10 +734,10 @@ class Check {
                        || extension_loaded('Zend OPcache')
                        || extension_loaded('wincache')
                ) {
-                       $status = new OkStatus();
+                       $status = new Status\OkStatus();
                        $status->setTitle('A PHP opcode cache is loaded');
                } else {
-                       $status = new WarningStatus();
+                       $status = new Status\WarningStatus();
                        $status->setTitle('No PHP opcode cache loaded');
                        $status->setMessage(
                                'PHP opcode caches hold a compiled version of executed PHP scripts in' .
@@ -753,12 +755,12 @@ class Check {
        /**
         * Check doc comments can be fetched by reflection
         *
-        * @return ErrorStatus|OkStatus
+        * @return Status\ErrorStatus|Status\OkStatus
         */
        protected function checkReflectionDocComment() {
                $testReflection = new \ReflectionMethod(get_class($this), __FUNCTION__);
                if (strlen($testReflection->getDocComment()) === 0) {
-                       $status = new ErrorStatus();
+                       $status = new Status\ErrorStatus();
                        $status->setTitle('Doc comment reflection broken');
                        $status->setMessage(
                                'TYPO3 CMS core extensions like extbase and fluid heavily rely on method' .
@@ -769,7 +771,7 @@ class Check {
                                ' This compile flag must be given, otherwise TYPO3 CMS is no fun.'
                        );
                } else {
-                       $status = new OkStatus();
+                       $status = new Status\OkStatus();
                        $status->setTitle('Document comment reflection works');
                }
                return $status;
@@ -778,14 +780,14 @@ class Check {
        /**
         * Checks thread stack size if on windows with apache
         *
-        * @return WarningStatus|OkStatus
+        * @return Status\WarningStatus|Status\OkStatus
         */
        protected function checkWindowsApacheThreadStackSize() {
                if (
                        $this->isWindowsOs()
                        && substr($_SERVER['SERVER_SOFTWARE'], 0, 6) === 'Apache'
                ) {
-                       $status = new WarningStatus();
+                       $status = new Status\WarningStatus();
                        $status->setTitle('Windows apache thread stack size');
                        $status->setMessage(
                                'This current value can not be checked by the system, so please ignore this warning if it' .
@@ -796,7 +798,7 @@ class Check {
                                ' ThreadStackSize 8388608. Restart Apache after this change.'
                        );
                } else {
-                       $status = new OkStatus();
+                       $status = new Status\OkStatus();
                        $status->setTitle('ThreadStackSize is not an issue on unix systems');
                }
                return $status;
@@ -806,18 +808,18 @@ class Check {
         * Check if a specific required PHP extension is loaded
         *
         * @param string $extension
-        * @return ErrorStatus|OkStatus
+        * @return Status\ErrorStatus|Status\OkStatus
         */
        protected function checkRequiredPhpExtension($extension) {
                if (!extension_loaded($extension)) {
-                       $status = new ErrorStatus();
+                       $status = new Status\ErrorStatus();
                        $status->setTitle('PHP extension ' . $extension . ' not loaded');
                        $status->setMessage(
                                'TYPO3 CMS uses PHP extension ' . $extension . ' but it is not loaded' .
                                ' in your environment. Change your environment to provide this extension.'
                        );
                } else {
-                       $status = new OkStatus();
+                       $status = new Status\OkStatus();
                        $status->setTitle('PHP extension ' . $extension . ' loaded');
                }
                return $status;
@@ -826,7 +828,7 @@ class Check {
        /**
         * Check smtp settings
         *
-        * @return ErrorStatus|OkStatus|WarningStatus
+        * @return Status\ErrorStatus|Status\OkStatus|Status\WarningStatus
         */
        protected function checkMailCapabilities() {
                if ($this->isWindowsOs()) {
@@ -850,7 +852,7 @@ class Check {
                        }
 
                        if ($brokenSmtp || $brokenSmtpPort) {
-                               $status = new ErrorStatus();
+                               $status = new Status\ErrorStatus();
                                $status->setTitle('Mail configuration is not set correctly');
                                $status->setMessage(
                                        'PHP mail() function requires SMTP and smtp_port to have' .
@@ -858,14 +860,14 @@ class Check {
                                        ' the mail system can be tested in the install tool.'
                                );
                        } elseif ($smtpIpAddress === '127.0.0.1' || $smtpIpAddress === '::1') {
-                               $status = new WarningStatus();
+                               $status = new Status\WarningStatus();
                                $status->setTitle('Mail is configured, potential problem exists');
                                $status->setMessage(
                                        'smtp=' . $smtpIni . ' - This server! Are you sure it runs SMTP server?' .
                                        ' If installation is completed, the mail system can be tested in the install tool.'
                                );
                        } else {
-                               $status = new OkStatus();
+                               $status = new Status\OkStatus();
                                $status->setTitle('Mail is configured');
                                $status->setMessage(
                                        'smtp=' . $smtpIni . ', smtp_port=' . ini_get('smtp_port') . '.' .
@@ -874,7 +876,7 @@ class Check {
                                );
                        }
                } elseif (!ini_get('sendmail_path')) {
-                       $status = new WarningStatus();
+                       $status = new Status\WarningStatus();
                        $status->setTitle('PHP sendmail_path not defined');
                        $status->setMessage(
                                'This may be critical to TYPO3\'s use of the mail() function.' .
@@ -884,7 +886,7 @@ class Check {
                } else {
                        list($mailBinary) = explode(' ', ini_get('sendmail_path'));
                        if (!@is_executable($mailBinary)) {
-                               $status = new ErrorStatus();
+                               $status = new Status\ErrorStatus();
                                $status->setTitle('Mail program not found or not executable');
                                $status->setMessage(
                                        'sendmail_path = ' . ini_get('sendmail_path') .
@@ -893,7 +895,7 @@ class Check {
                                        ' installation is completed, the mail system can be tested in the install tool.'
                                );
                        } else {
-                               $status = new OkStatus();
+                               $status = new Status\OkStatus();
                                $status->setTitle('PHP sendmail path given');
                                $status->setMessage(
                                        'sendmail_path = ' . ini_get('sendmail_path') . '.' .
@@ -909,17 +911,17 @@ class Check {
        /**
         * Check imagecreatetruecolor to verify gdlib works as expected
         *
-        * @return ErrorStatus|OkStatus
+        * @return Status\ErrorStatus|Status\OkStatus
         */
        protected function checkGdLibTrueColorSupport() {
                if (function_exists('imagecreatetruecolor')) {
                        $imageResource = @imagecreatetruecolor(50, 100);
                        if (is_resource($imageResource)) {
                                imagedestroy($imageResource);
-                               $status = new OkStatus();
+                               $status = new Status\OkStatus();
                                $status->setTitle('PHP GD library true color works');
                        } else {
-                               $status = new ErrorStatus();
+                               $status = new Status\ErrorStatus();
                                $status->setTitle('PHP GD library true color support broken');
                                $status->setMessage(
                                        'GD is loaded, but calling a imagecreatetruecolor returned an error.' .
@@ -927,7 +929,7 @@ class Check {
                                );
                        }
                } else {
-                       $status = new ErrorStatus();
+                       $status = new Status\ErrorStatus();
                        $status->setTitle('PHP GD library true color support missing');
                        $status->setMessage(
                                'Gdlib is essential for TYPO3 CMS to work properly.'
@@ -939,7 +941,7 @@ class Check {
        /**
         * Check gif support of GD library
         *
-        * @return ErrorStatus|OkStatus
+        * @return Status\ErrorStatus|Status\OkStatus
         */
        protected function checkGdLibGifSupport() {
                if (
@@ -950,10 +952,10 @@ class Check {
                        $imageResource = @imagecreatefromgif(__DIR__ . '/TestImages/jesus.gif');
                        if (is_resource($imageResource)) {
                                imagedestroy($imageResource);
-                               $status = new OkStatus();
+                               $status = new Status\OkStatus();
                                $status->setTitle('PHP GD library has gif support');
                        } else {
-                               $status = new ErrorStatus();
+                               $status = new Status\ErrorStatus();
                                $status->setTitle('PHP GD library gif support broken');
                                $status->setMessage(
                                        'GD is loaded, but calling a gif related message gives errors.' .
@@ -961,7 +963,7 @@ class Check {
                                );
                        }
                } else {
-                       $status = new ErrorStatus();
+                       $status = new Status\ErrorStatus();
                        $status->setTitle('PHP GD library gif support missing');
                        $status->setMessage(
                                'GD must be compiled with gif support. This is essential for' .
@@ -974,7 +976,7 @@ class Check {
        /**
         * Check jgp support of GD library
         *
-        * @return ErrorStatus|OkStatus
+        * @return Status\ErrorStatus|Status\OkStatus
         */
        protected function checkGdLibJpgSupport() {
                if (
@@ -982,10 +984,10 @@ class Check {
                        && function_exists('imagejpeg')
                        && (imagetypes() & IMG_JPG)
                ) {
-                       $status = new OkStatus();
+                       $status = new Status\OkStatus();
                        $status->setTitle('PHP GD library has jpg support');
                } else {
-                       $status= new ErrorStatus();
+                       $status= new Status\ErrorStatus();
                        $status->setTitle('PHP GD library jpg support missing');
                        $status->setMessage(
                                'GD must be compiled with jpg support. This is essential for' .
@@ -998,7 +1000,7 @@ class Check {
        /**
         * Check png support of GD library
         *
-        * @return ErrorStatus|OkStatus
+        * @return Status\ErrorStatus|Status\OkStatus
         */
        protected function checkGdLibPngSupport() {
                if (
@@ -1009,10 +1011,10 @@ class Check {
                        $imageResource = @imagecreatefrompng(__DIR__ . '/TestImages/jesus.png');
                        if (is_resource($imageResource)) {
                                imagedestroy($imageResource);
-                               $status = new OkStatus();
+                               $status = new Status\OkStatus();
                                $status->setTitle('PHP GD library has png support');
                        } else {
-                               $status = new ErrorStatus();
+                               $status = new Status\ErrorStatus();
                                $status->setTitle('PHP GD library png support broken');
                                $status->setMessage(
                                        'GD is compiled with png support, but a test call fails.' .
@@ -1021,7 +1023,7 @@ class Check {
                                );
                        }
                } else {
-                       $status = new ErrorStatus();
+                       $status = new Status\ErrorStatus();
                        $status->setTitle('PHP GD library png support missing');
                        $status->setMessage(
                                'GD must be compiled with png support. This is essential for' .
@@ -1034,11 +1036,11 @@ class Check {
        /**
         * Check gdlib supports freetype
         *
-        * @return ErrorStatus|OkStatus
+        * @return Status\ErrorStatus|Status\OkStatus
         */
        protected function checkGdLibFreeTypeSupport() {
                if (function_exists('imagettftext')) {
-                       $status = new OkStatus();
+                       $status = new Status\OkStatus();
                        $status->setTitle('PHP GD library has freetype font support');
                        $status->setMessage(
                                'There is a difference between the font size setting the GD' .
@@ -1046,7 +1048,7 @@ class Check {
                                ' a test in the install tool helps to find out the value you need.'
                        );
                } else {
-                       $status = new ErrorStatus();
+                       $status = new Status\ErrorStatus();
                        $status->setTitle('PHP GD library freetype support missing');
                        $status->setMessage(
                                'Some core functionality and extension rely on the GD' .
@@ -1060,18 +1062,18 @@ class Check {
        /**
         * Check php magic quotes
         *
-        * @return OkStatus|WarningStatus
+        * @return Status\OkStatus|Status\WarningStatus
         */
        protected function checkPhpMagicQuotes() {
                if (get_magic_quotes_gpc()) {
-                       $status = new WarningStatus();
+                       $status = new Status\WarningStatus();
                        $status->setTitle('PHP magic quotes on');
                        $status->setMessage(
                                'PHP ini setting magic_quotes_gpc in on. The setting is deprecated since PHP 5.3.' .
                                ' You are advised to set it to "Off" until it gets completely removed.'
                        );
                } else {
-                       $status = new OkStatus();
+                       $status = new Status\OkStatus();
                        $status->setTitle('PHP magic quotes off');
                }
                return $status;
@@ -1080,7 +1082,7 @@ class Check {
        /**
         * Check register globals
         *
-        * @return ErrorStatus|OkStatus
+        * @return Status\ErrorStatus|Status\OkStatus
         */
        protected function checkRegisterGlobals() {
                $registerGlobalsEnabled = filter_var(
@@ -1089,7 +1091,7 @@ class Check {
                        array(FILTER_REQUIRE_SCALAR, FILTER_NULL_ON_FAILURE)
                );
                if ($registerGlobalsEnabled === TRUE) {
-                       $status = new ErrorStatus();
+                       $status = new Status\ErrorStatus();
                        $status->setTitle('PHP register globals on');
                        $status->setMessage(
                                'TYPO3 requires PHP setting "register_globals" set to off.' .
@@ -1097,7 +1099,7 @@ class Check {
                                ' never be enabled.'
                        );
                } else {
-                       $status = new OkStatus();
+                       $status = new Status\OkStatus();
                        $status->setTitle('PHP register globals off');
                }
                return $status;
diff --git a/typo3/sysext/install/Classes/SystemEnvironment/ErrorStatus.php b/typo3/sysext/install/Classes/SystemEnvironment/ErrorStatus.php
deleted file mode 100644 (file)
index 8899c29..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-namespace TYPO3\CMS\Install\SystemEnvironment;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-
-/**
- * Error level status
- *
- * @author Christian Kuhn <lolli@schwarzbu.ch>
- */
-class ErrorStatus extends AbstractStatus implements StatusInterface {
-
-       /**
-        * @var string The severity
-        */
-       protected $severity = 'error';
-
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/install/Classes/SystemEnvironment/InfoStatus.php b/typo3/sysext/install/Classes/SystemEnvironment/InfoStatus.php
deleted file mode 100644 (file)
index 682ea7a..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-namespace TYPO3\CMS\Install\SystemEnvironment;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-
-/**
- * Info level status
- *
- * @author Christian Kuhn <lolli@schwarzbu.ch>
- */
-class InfoStatus extends AbstractStatus implements StatusInterface {
-
-       /**
-        * @var string The severity
-        */
-       protected $severity = 'information';
-
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/install/Classes/SystemEnvironment/NoticeStatus.php b/typo3/sysext/install/Classes/SystemEnvironment/NoticeStatus.php
deleted file mode 100644 (file)
index 8ee7c12..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-namespace TYPO3\CMS\Install\SystemEnvironment;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-
-/**
- * Notice level status
- *
- * @author Christian Kuhn <lolli@schwarzbu.ch>
- */
-class NoticeStatus extends AbstractStatus implements StatusInterface {
-
-       /**
-        * @var string The severity
-        */
-       protected $severity = 'notice';
-
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/install/Classes/SystemEnvironment/OkStatus.php b/typo3/sysext/install/Classes/SystemEnvironment/OkStatus.php
deleted file mode 100644 (file)
index 680026e..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-namespace TYPO3\CMS\Install\SystemEnvironment;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-
-/**
- * Ok level status
- *
- * @author Christian Kuhn <lolli@schwarzbu.ch>
- */
-class OkStatus extends AbstractStatus implements StatusInterface {
-
-       /**
-        * @var string The severity
-        */
-       protected $severity = 'ok';
-
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/install/Classes/SystemEnvironment/StatusInterface.php b/typo3/sysext/install/Classes/SystemEnvironment/StatusInterface.php
deleted file mode 100644 (file)
index 98ba128..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-namespace TYPO3\CMS\Install\SystemEnvironment;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-
-/**
- * Interface for SystemEnvironment status
- *
- * @author Christian Kuhn <lolli@schwarzbu.ch>
- */
-interface StatusInterface {
-
-       /**
-        * @return string The severity
-        */
-       public function getSeverity();
-
-       /**
-        * @return string The title
-        */
-       public function getTitle();
-
-       /**
-        * Set title
-        *
-        * @param string $title The title
-        * @return void
-        */
-       public function setTitle($title);
-
-       /**
-        * Get status message
-        *
-        * @return string Status message
-        */
-       public function getMessage();
-
-       /**
-        * Set status message
-        *
-        * @param string $message Status message
-        * @return void
-        */
-       public function setMessage($message);
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/install/Classes/SystemEnvironment/WarningStatus.php b/typo3/sysext/install/Classes/SystemEnvironment/WarningStatus.php
deleted file mode 100644 (file)
index 441ed2b..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-namespace TYPO3\CMS\Install\SystemEnvironment;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-
-/**
- * Warning level status
- *
- * @author Christian Kuhn <lolli@schwarzbu.ch>
- */
-class WarningStatus extends AbstractStatus implements StatusInterface {
-
-       /**
-        * @var string The severity
-        */
-       protected $severity = 'warning';
-
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/install/Tests/Unit/Status/StatusUtilityTest.php b/typo3/sysext/install/Tests/Unit/Status/StatusUtilityTest.php
new file mode 100644 (file)
index 0000000..a14ca10
--- /dev/null
@@ -0,0 +1,112 @@
+<?php
+namespace TYPO3\CMS\Install\Tests\Unit\Status;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Test case
+ */
+class StatusUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
+
+       /**
+        * @test
+        * @expectedException \TYPO3\CMS\Install\Status\Exception
+        */
+       public function renderStatusObjectsAsHtmlThrowsExceptionIfObjectDoesNotImplementStatusInterface() {
+               $statusUtility = new \TYPO3\CMS\Install\Status\StatusUtility();
+               $statusUtility->renderStatusObjectsAsHtml(array(new \stdClass()));
+       }
+
+       /**
+        * @test
+        */
+       public function renderStatusObjectsAsHtmlRendersSeverity() {
+               $mockStatus = $this->getMock('TYPO3\\CMS\\Install\\Status\\StatusInterface');
+               $uniqueSeverity = uniqid('severity_');
+               $mockStatus->expects($this->once())->method('getSeverity')->will($this->returnValue($uniqueSeverity));
+               $statusUtility = new \TYPO3\CMS\Install\Status\StatusUtility();
+               $this->assertContains($uniqueSeverity, $statusUtility->renderStatusObjectsAsHtml(array($mockStatus)));
+       }
+
+       /**
+        * @test
+        */
+       public function renderStatusObjectsAsHtmlRendersTitle() {
+               $mockStatus = $this->getMock('TYPO3\\CMS\\Install\\Status\\StatusInterface');
+               $uniqueTitle = uniqid('title_');
+               $mockStatus->expects($this->once())->method('getTitle')->will($this->returnValue($uniqueTitle));
+               $statusUtility = new \TYPO3\CMS\Install\Status\StatusUtility();
+               $this->assertContains($uniqueTitle, $statusUtility->renderStatusObjectsAsHtml(array($mockStatus)));
+       }
+
+       /**
+        * @test
+        */
+       public function renderStatusObjectsAsHtmlRendersMessage() {
+               $mockStatus = $this->getMock('TYPO3\\CMS\\Install\\Status\\StatusInterface');
+               $uniqueMessage = uniqid('message_');
+               $mockStatus->expects($this->once())->method('getMessage')->will($this->returnValue($uniqueMessage));
+               $statusUtility = new \TYPO3\CMS\Install\Status\StatusUtility();
+               $this->assertContains($uniqueMessage, $statusUtility->renderStatusObjectsAsHtml(array($mockStatus)));
+       }
+
+       /**
+        * @test
+        */
+       public function sortBySeveritySortsGivenStatusObjects() {
+               $errorMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\ErrorStatus', array('dummy'));
+               $warningMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\WarningStatus', array('dummy'));
+               $okMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\OkStatus', array('dummy'));
+               $infoMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\InfoStatus', array('dummy'));
+               $noticeMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\NoticeStatus', array('dummy'));
+               $statusUtility = new \TYPO3\CMS\Install\Status\StatusUtility();
+               $return = $statusUtility->sortBySeverity(array($noticeMock, $infoMock, $okMock, $warningMock, $errorMock));
+               $this->assertSame(array($errorMock), $return['error']);
+               $this->assertSame(array($warningMock), $return['warning']);
+               $this->assertSame(array($okMock), $return['ok']);
+               $this->assertSame(array($infoMock), $return['information']);
+               $this->assertSame(array($noticeMock), $return['notice']);
+       }
+
+       /**
+        * @test
+        * @expectedException \TYPO3\CMS\Install\Status\Exception
+        */
+       public function filterBySeverityThrowsExceptionIfObjectNotImplementingStatusInterfaceIsGiven() {
+               $statusUtility = new \TYPO3\CMS\Install\Status\StatusUtility();
+               $statusUtility->filterBySeverity(array(new \stdClass()));
+       }
+
+       /**
+        * @test
+        */
+       public function filterBySeverityReturnsSpecificSeverityOnly() {
+               $errorMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\ErrorStatus', array('dummy'));
+               $warningMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\WarningStatus', array('dummy'));
+               $statusUtility = new \TYPO3\CMS\Install\Status\StatusUtility();
+               $return = $statusUtility->filterBySeverity(array($errorMock, $warningMock), 'error');
+               $this->assertSame(array($errorMock), $return);
+       }
+}
+?>
\ No newline at end of file