[TASK] Spring cleaning 07/48807/2
authorFrancois Suter <francois@typo3.org>
Tue, 5 Jul 2016 15:15:41 +0000 (17:15 +0200)
committerFrancois Suter <francois@typo3.org>
Tue, 5 Jul 2016 15:18:35 +0000 (17:18 +0200)
Clean up files, use PHP 5.5+ features, align with TYPO3 7.

Change-Id: I8f6f7bde1b386f8f229f9ee5a048ee91284ba20d
Resolves: #76946
Release: 3.0
Reviewed-on: https://review.typo3.org/48807
Reviewed-by: Francois Suter <francois@typo3.org>
Tested-by: Francois Suter <francois@typo3.org>
Classes/Domain/Model/Entry.php
Classes/Domain/Repository/EntryRepository.php
Classes/Utility/TceForms.php [deleted file]
Classes/Utility/UserFields.php [new file with mode: 0644]
Configuration/TCA/tx_devlog_domain_model_entry.php
Resources/Public/Icons/Entry.png [deleted file]
Tests/Unit/Domain/Model/EntryTest.php
Tests/Unit/Utility/LoggerTest.php
ext_emconf.php
ext_localconf.php
ext_tables.php

index e1fc554..2769bd0 100644 (file)
@@ -13,12 +13,15 @@ namespace Devlog\Devlog\Domain\Model;
  *
  * The TYPO3 project - inspiring people to share!
  */
+
+use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
+
 /**
  * Entry model class.
  *
  * @author Francois Suter <typo3@cobweb.ch>
  */
-class Entry extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
+class Entry extends AbstractEntity
 {
 
     /**
@@ -103,7 +106,7 @@ class Entry extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
      *
      * @var mixed
      */
-    protected $extraData = NULL;
+    protected $extraData = null;
 
     /**
      * Gets the run ID.
index 87ead8f..2535f88 100644 (file)
@@ -13,6 +13,7 @@ namespace Devlog\Devlog\Domain\Repository;
  *
  * The TYPO3 project - inspiring people to share!
  */
+
 use TYPO3\CMS\Core\SingletonInterface;
 
 /**
@@ -33,12 +34,12 @@ class EntryRepository implements SingletonInterface
     /**
      * @var array Extension configuration
      */
-    protected $extensionConfiguration = NULL;
+    protected $extensionConfiguration = null;
 
     /**
      * @var integer Number of rows in the database (cached to avoid querying too often)
      */
-    protected $numberOfRows = NULL;
+    protected $numberOfRows = null;
 
     /**
      * Returns all available records in the log table.
@@ -50,13 +51,18 @@ class EntryRepository implements SingletonInterface
      */
     public function findAll()
     {
-        $entries = $this->getDatabaseConnection()->exec_SELECTgetRows(
-            '*',
-            $this->databaseTable,
-            '',
-            '',
-            'crdate DESC, sorting ASC'
-        );
+        try {
+            $entries = $this->getDatabaseConnection()->exec_SELECTgetRows(
+                    '*',
+                    $this->databaseTable,
+                    '',
+                    '',
+                    'crdate DESC, sorting ASC'
+            );
+        }
+        catch (\Exception $e) {
+            $entries = array();
+        }
         $numEntries = count($entries);
         for ($i = 0; $i < $numEntries; $i++) {
             $entries[$i]['extra_data'] = gzuncompress($entries[$i]['extra_data']);
@@ -72,17 +78,17 @@ class EntryRepository implements SingletonInterface
     public function add($entry)
     {
         $fields = array(
-            'run_id' => $entry->getRunId(),
-            'sorting' => $entry->getSorting(),
-            'severity' => $entry->getSeverity(),
-            'extkey' => $entry->getExtkey(),
-            'message' => $entry->getMessage(),
-            'location' => $entry->getLocation(),
-            'line' => $entry->getLine(),
-            'ip' => $entry->getIp(),
-            'cruser_id' => $entry->getCruserId(),
-            'crdate' => $entry->getCrdate(),
-            'pid' => $entry->getPid(),
+                'run_id' => $entry->getRunId(),
+                'sorting' => $entry->getSorting(),
+                'severity' => $entry->getSeverity(),
+                'extkey' => $entry->getExtkey(),
+                'message' => $entry->getMessage(),
+                'location' => $entry->getLocation(),
+                'line' => $entry->getLine(),
+                'ip' => $entry->getIp(),
+                'cruser_id' => $entry->getCruserId(),
+                'crdate' => $entry->getCrdate(),
+                'pid' => $entry->getPid(),
         );
         // Handle extra data
         $fields['extra_data'] = gzcompress(serialize($entry->getExtraData()));
@@ -93,8 +99,8 @@ class EntryRepository implements SingletonInterface
             $fields['extra_data'] = gzcompress(serialize('Extra data too large, not saved.'));
         }
         return $this->getDatabaseConnection()->exec_INSERTquery(
-            $this->databaseTable,
-            $fields
+                $this->databaseTable,
+                $fields
         );
     }
 
@@ -106,34 +112,34 @@ class EntryRepository implements SingletonInterface
     public function cleanUp()
     {
         // Get the total number of rows, if not already defined
-        if ($this->numberOfRows === NULL) {
+        if ($this->numberOfRows === null) {
             $this->numberOfRows = $this->getDatabaseConnection()->exec_SELECTcountRows(
-                'uid',
-                'tx_devlog_domain_model_entry'
+                    'uid',
+                    'tx_devlog_domain_model_entry'
             );
         }
         // Check if number of rows is above the limit and clean up if necessary
         if ($this->numberOfRows > $this->extensionConfiguration['maximumRows']) {
             // Select the row from which to start cleaning up
-            // To achieve this, order by creation date (so oldest come first)
+            // To achieve this, order by creation date (so oldest comes first)
             // then offset by 10% of maximumRows and get the next record
             // This will return a timestamp that is used as a cut-off date
             $numberOfRowsToRemove = round(0.1 * $this->extensionConfiguration['maximumRows']);
             $cutOffRow = $this->getDatabaseConnection()->exec_SELECTgetRows(
-                'crdate',
-                'tx_devlog_domain_model_entry',
-                '',
-                '',
-                'crdate',
-                $numberOfRowsToRemove . ',1'
+                    'crdate',
+                    'tx_devlog_domain_model_entry',
+                    '',
+                    '',
+                    'crdate',
+                    $numberOfRowsToRemove . ',1'
             );
             $cutOffDate = $cutOffRow[0]['crdate'];
             // Delete all rows older or same age as previously found timestamp
             // This will probably delete a bit more than 10% of maximumRows, but will at least
             // delete complete log runs
             $this->getDatabaseConnection()->exec_DELETEquery(
-                'tx_devlog_domain_model_entry',
-                'crdate <= \'' . $cutOffDate . '\''
+                    'tx_devlog_domain_model_entry',
+                    'crdate <= \'' . $cutOffDate . '\''
             );
             $numberOfRemovedRows = $this->getDatabaseConnection()->sql_affected_rows();
             // Update (cached) number of rows
diff --git a/Classes/Utility/TceForms.php b/Classes/Utility/TceForms.php
deleted file mode 100644 (file)
index a713b71..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-<?php
-namespace Devlog\Devlog\Utility;
-
-/**
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Backend\Utility\IconUtility;
-
-/**
- * TCEforms custom field for devlog table.
- */
-class TceForms
-{
-
-    /**
-     * @var string
-     */
-    protected $extKey = 'devlog';
-
-    /**
-     * Returns the severity of the entry using TYPO3's icon and labels
-     *
-     * @param array $PA Information related to the field
-     * @param \TYPO3\CMS\Backend\Form\FormEngine $formObject Reference to calling TCEforms object
-     *
-     * @return string The HTML for the form field
-     */
-    public function displaySeverity($PA, $formObject)
-    {
-        // Translate severity to icon "name"
-        $severity = $PA['row']['severity'];
-        switch ($severity) {
-            case -1:
-                $severityName = 'ok';
-                break;
-            case 1:
-                $severityName = 'notification';
-                break;
-            case 2:
-                $severityName = 'warning';
-                break;
-            case 3:
-                $severityName = 'error';
-                break;
-            default:
-                $severityName = 'information';
-        }
-
-        $html = IconUtility::getSpriteIcon(
-            'status-dialog-' . $severityName,
-            array(
-                'title' => $this->getLanguageObject()->sL('LLL:EXT:devlog/Resources/Private/Language/locallang.xlf:severity_' . $severityName)
-            )
-        );
-        return $html;
-    }
-
-    /**
-     * Returns the extra data as a nice HTML dump.
-     *
-     * @param array $PA Information related to the field
-     * @param \TYPO3\CMS\Backend\Form\FormEngine $formObject Reference to calling TCEforms object
-     *
-     * @return string The HTML for the form field
-     */
-    public function displayExtraData($PA, $formObject)
-    {
-        if (empty($PA['row']['extra_data'])) {
-            $html = $this->getLanguageObject()->sL('LLL:EXT:devlog/Resources/Private/Language/locallang.xlf:no_extra_data');
-        } else {
-            $data = unserialize(gzuncompress($PA['row']['extra_data']));
-            $html = \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(
-                $data,
-                NULL,
-                10,
-                FALSE,
-                TRUE,
-                TRUE
-            );
-        }
-        return $html;
-    }
-
-    /**
-     * Wrapper around the global language object.
-     *
-     * @return \TYPO3\CMS\Lang\LanguageService
-     */
-    protected function getLanguageObject()
-    {
-        return $GLOBALS['LANG'];
-    }
-}
diff --git a/Classes/Utility/UserFields.php b/Classes/Utility/UserFields.php
new file mode 100644 (file)
index 0000000..2f464f5
--- /dev/null
@@ -0,0 +1,106 @@
+<?php
+namespace Devlog\Devlog\Utility;
+
+/**
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Backend\Form\Element\UserElement;
+use TYPO3\CMS\Core\Imaging\Icon;
+use TYPO3\CMS\Core\Imaging\IconFactory;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Custom fields for tx_devlog_domain_model_entry table.
+ */
+class UserFields
+{
+
+    /**
+     * @var string
+     */
+    protected $extKey = 'devlog';
+
+    /**
+     * Returns the severity of the entry using TYPO3's icon and labels.
+     *
+     * @param array $parameters Information related to the field
+     * @param UserElement $userElement Reference to calling object
+     *
+     * @return string The HTML for the form field
+     */
+    public function displaySeverity($parameters, $formObject)
+    {
+        // Translate severity to icon "name"
+        $severity = $parameters['row']['severity'];
+        switch ($severity) {
+            case -1:
+                $severityName = 'ok';
+                break;
+            case 1:
+                $severityName = 'notification';
+                break;
+            case 2:
+                $severityName = 'warning';
+                break;
+            case 3:
+                $severityName = 'error';
+                break;
+            default:
+                $severityName = 'information';
+        }
+
+        $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
+        $html = $iconFactory->getIcon(
+                'status-dialog-' . $severityName,
+                Icon::SIZE_DEFAULT
+        );
+        $html .= $this->getLanguageObject()->sL('LLL:EXT:devlog/Resources/Private/Language/locallang.xlf:status_' . $severityName);
+        return $html;
+    }
+
+    /**
+     * Returns the extra data as a nice HTML dump.
+     *
+     * @param array $PA Information related to the field
+     * @param UserElement $userElement Reference to calling object
+     *
+     * @return string The HTML for the form field
+     */
+    public function displayExtraData($PA, $formObject)
+    {
+        if (empty($PA['row']['extra_data'])) {
+            $html = $this->getLanguageObject()->sL('LLL:EXT:devlog/Resources/Private/Language/locallang.xlf:no_extra_data');
+        } else {
+            $data = unserialize(gzuncompress($PA['row']['extra_data']));
+            $html = \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(
+                    $data,
+                    null,
+                    10,
+                    false,
+                    true,
+                    true
+            );
+        }
+        return $html;
+    }
+
+    /**
+     * Wrapper around the global language object.
+     *
+     * @return \TYPO3\CMS\Lang\LanguageService
+     */
+    protected function getLanguageObject()
+    {
+        return $GLOBALS['LANG'];
+    }
+}
index 62be9ad..8df6a85 100644 (file)
 <?php
-if (!defined ('TYPO3_MODE')) {
+if (!defined('TYPO3_MODE')) {
     die ('Access denied.');
 }
 
 return array(
-    'ctrl' => array(
-        'title'        => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry',
-        'label' => 'message',
-        'tstamp' => 'tstamp',
-        'crdate' => 'crdate',
-        'cruser_id' => 'cruser_id',
-        'default_sortby' => 'ORDER BY crdate DESC, sorting ASC',
-        'dividers2tabs' => TRUE,
-        'searchFields' => 'severity,extkey,message,location,ip,line,extra_data',
-        'typeicon_column' => 'severity',
-        'typeicon_classes' => array(
-            'default' => 'extensions-devlog-entry',
-            '-1' => 'status-dialog-ok',
-            '0' => 'status-dialog-information',
-            '1' => 'status-dialog-notification',
-            '2' => 'status-dialog-warning',
-            '3' => 'status-dialog-error'
-        ),
-    ),
-    'interface' => array(
-        'showRecordFieldList' => 'severity, extkey, message, location, line, ip, extra_data',
-    ),
-    'types' => array(
-        '1' => array('showitem' => 'crdate, cruser_id, severity, extkey, message, location, line, ip, extra_data'),
-    ),
-    'columns' => array(
-        'crdate' => array(
-            'exclude' => 0,
-            'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.crdate',
-            'config' => array(
-                'type' => 'input',
-                'readOnly' => TRUE,
-                'eval' => 'datetime'
-            )
-        ),
-        'cruser_id' => array(
-            'exclude' => 0,
-            'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.cruser_id',
-            'config' => array(
-                'type' => 'select',
-                'readOnly' => TRUE,
-                'items' => array(
-                    array()
+        'ctrl' => array(
+                'title' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry',
+                'label' => 'message',
+                'tstamp' => 'tstamp',
+                'crdate' => 'crdate',
+                'cruser_id' => 'cruser_id',
+                'default_sortby' => 'ORDER BY crdate DESC, sorting ASC',
+                'rootLevel' => -1,
+                'dividers2tabs' => true,
+                'searchFields' => 'severity,extkey,message,location,ip,line,extra_data',
+                'typeicon_column' => 'severity',
+                'typeicon_classes' => array(
+                        'default' => 'status-dialog-information',
+                        '-1' => 'status-dialog-ok',
+                        '0' => 'status-dialog-information',
+                        '1' => 'status-dialog-notification',
+                        '2' => 'status-dialog-warning',
+                        '3' => 'status-dialog-error'
                 ),
-                'foreign_table' => 'be_users',
-                'size' => 1
-            )
-        ),
-        'severity' => array(
-            'exclude' => 0,
-            'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.severity',
-            'config' => array(
-                'type' => 'user',
-                'userFunc' => 'Devlog\\Devlog\\Utility\\TceForms->displaySeverity',
-            )
-        ),
-        'extkey' => array(
-            'exclude' => 0,
-            'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.extkey',
-            'config' => array(
-                'type' => 'input',
-                'readOnly' => TRUE,
-                'size' => 30,
-                'eval' => 'trim'
-            ),
         ),
-        'message' => array(
-            'exclude' => 0,
-            'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.message',
-            'config' => array(
-                'type' => 'text',
-                'readOnly' => TRUE,
-                'cols' => 50,
-                'rows' => 5,
-                'eval' => 'trim'
-            )
+        'interface' => array(
+                'showRecordFieldList' => 'severity, extkey, message, location, line, ip, extra_data',
         ),
-        'location' => array(
-            'exclude' => 0,
-            'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.location',
-            'config' => array(
-                'type' => 'input',
-                'readOnly' => TRUE,
-                'size' => 30,
-                'eval' => 'trim'
-            ),
+        'types' => array(
+                '1' => array('showitem' => 'crdate, cruser_id, severity, extkey, message, location, line, ip, extra_data'),
         ),
-        'line' => array(
-            'exclude' => 0,
-            'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.line',
-            'config' => array(
-                'type' => 'input',
-                'readOnly' => TRUE,
-                'size' => 30,
-                'eval' => 'trim'
-            ),
-        ),
-        'ip' => array(
-            'exclude' => 0,
-            'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.ip',
-            'config' => array(
-                'type' => 'input',
-                'readOnly' => TRUE,
-                'size' => 30,
-                'eval' => 'trim'
-            ),
-        ),
-        'extra_data' => array(
-            'exclude' => 0,
-            'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.extra_data',
-            'config' => array(
-                'type' => 'user',
-                'userFunc' => 'Devlog\\Devlog\\Utility\\TceForms->displayExtraData',
-            )
+        'columns' => array(
+                'crdate' => array(
+                        'exclude' => 0,
+                        'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.crdate',
+                        'config' => array(
+                                'type' => 'input',
+                                'readOnly' => true,
+                                'eval' => 'datetime'
+                        )
+                ),
+                'cruser_id' => array(
+                        'exclude' => 0,
+                        'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.cruser_id',
+                        'config' => array(
+                                'type' => 'select',
+                                'readOnly' => true,
+                                'items' => array(
+                                        array()
+                                ),
+                                'foreign_table' => 'be_users',
+                                'size' => 1
+                        )
+                ),
+                'severity' => array(
+                        'exclude' => 0,
+                        'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.severity',
+                        'config' => array(
+                                'type' => 'user',
+                                'userFunc' => \Devlog\Devlog\Utility\UserFields::class . '->displaySeverity',
+                        )
+                ),
+                'extkey' => array(
+                        'exclude' => 0,
+                        'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.extkey',
+                        'config' => array(
+                                'type' => 'input',
+                                'readOnly' => true,
+                                'size' => 30,
+                                'eval' => 'trim'
+                        ),
+                ),
+                'message' => array(
+                        'exclude' => 0,
+                        'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.message',
+                        'config' => array(
+                                'type' => 'text',
+                                'readOnly' => true,
+                                'cols' => 50,
+                                'rows' => 5,
+                                'eval' => 'trim'
+                        )
+                ),
+                'location' => array(
+                        'exclude' => 0,
+                        'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.location',
+                        'config' => array(
+                                'type' => 'input',
+                                'readOnly' => true,
+                                'size' => 30,
+                                'eval' => 'trim'
+                        ),
+                ),
+                'line' => array(
+                        'exclude' => 0,
+                        'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.line',
+                        'config' => array(
+                                'type' => 'input',
+                                'readOnly' => true,
+                                'size' => 30,
+                                'eval' => 'trim'
+                        ),
+                ),
+                'ip' => array(
+                        'exclude' => 0,
+                        'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.ip',
+                        'config' => array(
+                                'type' => 'input',
+                                'readOnly' => true,
+                                'size' => 30,
+                                'eval' => 'trim'
+                        ),
+                ),
+                'extra_data' => array(
+                        'exclude' => 0,
+                        'label' => 'LLL:EXT:devlog/Resources/Private/Language/locallang_db.xlf:tx_devlog_domain_model_entry.extra_data',
+                        'config' => array(
+                                'type' => 'user',
+                                'userFunc' => \Devlog\Devlog\Utility\UserFields::class . '->displayExtraData',
+                        )
+                ),
         ),
-    ),
 );
diff --git a/Resources/Public/Icons/Entry.png b/Resources/Public/Icons/Entry.png
deleted file mode 100644 (file)
index 7dfe426..0000000
Binary files a/Resources/Public/Icons/Entry.png and /dev/null differ
index 526621a..7c502d7 100644 (file)
@@ -25,9 +25,14 @@ use Devlog\Devlog\Domain\Model\Entry;
 class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
 {
     /**
+     * @var array List of globals to exclude (contain closures which cannot be serialized)
+     */
+    protected $backupGlobalsBlacklist = array('TYPO3_LOADED_EXT', 'TYPO3_CONF_VARS');
+
+    /**
      * @var Entry
      */
-    protected $subject = NULL;
+    protected $subject = null;
 
     protected function setUp()
     {
@@ -45,9 +50,9 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function getRunIdReturnsInitialValueForString()
     {
-        $this->assertSame(
-            '',
-            $this->subject->getRunId()
+        self::assertSame(
+                '',
+                $this->subject->getRunId()
         );
     }
 
@@ -59,10 +64,10 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $this->subject->setRunId('12345678987.65432100');
 
-        $this->assertAttributeEquals(
-            '12345678987.65432100',
-            'runId',
-            $this->subject
+        self::assertAttributeEquals(
+                '12345678987.65432100',
+                'runId',
+                $this->subject
         );
     }
 
@@ -72,9 +77,9 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function getSortingReturnsInitialValueForInteger()
     {
-        $this->assertSame(
-            0,
-            $this->subject->getSorting()
+        self::assertSame(
+                0,
+                $this->subject->getSorting()
         );
     }
 
@@ -86,10 +91,10 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $this->subject->setSorting(12);
 
-        $this->assertAttributeEquals(
-            12,
-            'sorting',
-            $this->subject
+        self::assertAttributeEquals(
+                12,
+                'sorting',
+                $this->subject
         );
     }
 
@@ -99,9 +104,9 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function getCrdateReturnsInitialValueForInteger()
     {
-        $this->assertSame(
-            0,
-            $this->subject->getCrdate()
+        self::assertSame(
+                0,
+                $this->subject->getCrdate()
         );
     }
 
@@ -113,10 +118,10 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $this->subject->setCrdate(1417705263);
 
-        $this->assertAttributeEquals(
-            1417705263,
-            'crdate',
-            $this->subject
+        self::assertAttributeEquals(
+                1417705263,
+                'crdate',
+                $this->subject
         );
     }
 
@@ -126,9 +131,9 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function getSeverityReturnsInitialValueForInteger()
     {
-        $this->assertSame(
-            0,
-            $this->subject->getSeverity()
+        self::assertSame(
+                0,
+                $this->subject->getSeverity()
         );
     }
 
@@ -140,10 +145,10 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $this->subject->setSeverity(2);
 
-        $this->assertAttributeEquals(
-            2,
-            'severity',
-            $this->subject
+        self::assertAttributeEquals(
+                2,
+                'severity',
+                $this->subject
         );
     }
 
@@ -153,9 +158,9 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function getExtkeyReturnsInitialValueForString()
     {
-        $this->assertSame(
-            '',
-            $this->subject->getExtkey()
+        self::assertSame(
+                '',
+                $this->subject->getExtkey()
         );
     }
 
@@ -167,10 +172,10 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $this->subject->setExtkey('devlog');
 
-        $this->assertAttributeEquals(
-            'devlog',
-            'extkey',
-            $this->subject
+        self::assertAttributeEquals(
+                'devlog',
+                'extkey',
+                $this->subject
         );
     }
 
@@ -180,9 +185,9 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function getMessageReturnsInitialValueForString()
     {
-        $this->assertSame(
-            '',
-            $this->subject->getMessage()
+        self::assertSame(
+                '',
+                $this->subject->getMessage()
         );
     }
 
@@ -194,10 +199,10 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $this->subject->setMessage('This is a message');
 
-        $this->assertAttributeEquals(
-            'This is a message',
-            'message',
-            $this->subject
+        self::assertAttributeEquals(
+                'This is a message',
+                'message',
+                $this->subject
         );
     }
 
@@ -207,9 +212,9 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function getLocationReturnsInitialValueForString()
     {
-        $this->assertSame(
-            '',
-            $this->subject->getLocation()
+        self::assertSame(
+                '',
+                $this->subject->getLocation()
         );
     }
 
@@ -221,10 +226,10 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $this->subject->setLocation('Entry.php');
 
-        $this->assertAttributeEquals(
-            'Entry.php',
-            'location',
-            $this->subject
+        self::assertAttributeEquals(
+                'Entry.php',
+                'location',
+                $this->subject
         );
     }
 
@@ -234,9 +239,9 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function getLineReturnsInitialValueForInteger()
     {
-        $this->assertSame(
-            0,
-            $this->subject->getLine()
+        self::assertSame(
+                0,
+                $this->subject->getLine()
         );
     }
 
@@ -248,10 +253,10 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $this->subject->setLine(42);
 
-        $this->assertAttributeEquals(
-            42,
-            'line',
-            $this->subject
+        self::assertAttributeEquals(
+                42,
+                'line',
+                $this->subject
         );
     }
 
@@ -261,9 +266,9 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function getIpReturnsInitialValueForString()
     {
-        $this->assertSame(
-            '',
-            $this->subject->getIp()
+        self::assertSame(
+                '',
+                $this->subject->getIp()
         );
     }
 
@@ -275,10 +280,10 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $this->subject->setIp('127.0.0.1');
 
-        $this->assertAttributeEquals(
-            '127.0.0.1',
-            'ip',
-            $this->subject
+        self::assertAttributeEquals(
+                '127.0.0.1',
+                'ip',
+                $this->subject
         );
     }
 
@@ -288,9 +293,9 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function getCruserIdReturnsInitialValueForInteger()
     {
-        $this->assertSame(
-            0,
-            $this->subject->getCruserId()
+        self::assertSame(
+                0,
+                $this->subject->getCruserId()
         );
     }
 
@@ -302,10 +307,10 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $this->subject->setCruserId(5);
 
-        $this->assertAttributeEquals(
-            5,
-            'cruserId',
-            $this->subject
+        self::assertAttributeEquals(
+                5,
+                'cruserId',
+                $this->subject
         );
     }
 
@@ -315,9 +320,9 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function getPidReturnsInitialValueForInteger()
     {
-        $this->assertSame(
-            0,
-            $this->subject->getPid()
+        self::assertSame(
+                0,
+                $this->subject->getPid()
         );
     }
 
@@ -329,10 +334,10 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $this->subject->setPid(17);
 
-        $this->assertAttributeEquals(
-            17,
-            'pid',
-            $this->subject
+        self::assertAttributeEquals(
+                17,
+                'pid',
+                $this->subject
         );
     }
 
@@ -342,8 +347,8 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function getExtraDataReturnsInitialValueForString()
     {
-        $this->assertNull(
-            $this->subject->getExtraData()
+        self::assertNull(
+                $this->subject->getExtraData()
         );
     }
 
@@ -355,10 +360,10 @@ class EntryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $this->subject->setExtraData('SomeBlob');
 
-        $this->assertAttributeEquals(
-            'SomeBlob',
-            'extraData',
-            $this->subject
+        self::assertAttributeEquals(
+                'SomeBlob',
+                'extraData',
+                $this->subject
         );
     }
 }
index 849495a..990f08a 100644 (file)
@@ -24,17 +24,22 @@ use Devlog\Devlog\Utility\Logger;
 class LoggerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
 {
     /**
+     * @var array List of globals to exclude (contain closures which cannot be serialized)
+     */
+    protected $backupGlobalsBlacklist = array('TYPO3_LOADED_EXT', 'TYPO3_CONF_VARS');
+
+    /**
      * @var Logger
      */
-    protected $subject = NULL;
+    protected $subject = null;
 
     /**
      * @var array Test extension configuration
      */
     protected $testConfiguration = array(
-        'minimumLogLevel' => 1,
-        'excludeKeys' => 'foo,bar',
-        'ipFilter' => '127.0.0.1,::1'
+            'minimumLogLevel' => 1,
+            'excludeKeys' => 'foo,bar',
+            'ipFilter' => '127.0.0.1,::1'
     );
 
     /**
@@ -44,7 +49,7 @@ class LoggerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $this->subject = new Logger();
         $this->subject->setExtensionConfiguration(
-            $this->testConfiguration
+                $this->testConfiguration
         );
     }
 
@@ -62,41 +67,41 @@ class LoggerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function entryIsAccepted()
     {
-        $this->assertTrue(
-            $this->subject->isEntryAccepted(
-                array(
-                    'severity' => 2,
-                    'extKey' => 'whatever',
-                    'ip' => '127.0.0.1'
+        self::assertTrue(
+                $this->subject->isEntryAccepted(
+                        array(
+                                'severity' => 2,
+                                'extKey' => 'whatever',
+                                'ip' => '127.0.0.1'
+                        )
                 )
-            )
         );
     }
 
     public function validEntriesProvider()
     {
         return array(
-            'Severity too low' => array(
-                array(
-                    'severity' => 0,
-                    'extKey' => 'whatever',
-                    'ip' => '127.0.0.1'
-                )
-            ),
-            'Excluded extension key' => array(
-                array(
-                    'severity' => 3,
-                    'extKey' => 'foo',
-                    'ip' => '127.0.0.1'
+                'Severity too low' => array(
+                        array(
+                                'severity' => 0,
+                                'extKey' => 'whatever',
+                                'ip' => '127.0.0.1'
+                        )
+                ),
+                'Excluded extension key' => array(
+                        array(
+                                'severity' => 3,
+                                'extKey' => 'foo',
+                                'ip' => '127.0.0.1'
+                        )
+                ),
+                'IP does not match' => array(
+                        array(
+                                'severity' => 3,
+                                'extKey' => 'whatever',
+                                'ip' => '192.168.1.1'
+                        )
                 )
-            ),
-            'IP does not match' => array(
-                array(
-                    'severity' => 3,
-                    'extKey' => 'whatever',
-                    'ip' => '192.168.1.1'
-                )
-            )
         );
     }
 
@@ -108,52 +113,52 @@ class LoggerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function entryIsRefused($entry)
     {
-        $this->assertFalse(
-            $this->subject->isEntryAccepted(
-                $entry
-            )
+        self::assertFalse(
+                $this->subject->isEntryAccepted(
+                        $entry
+                )
         );
     }
 
     public function ipAddressesProvider()
     {
         return array(
-            'Valid IP v4' => array(
-                '127.0.0.1',
-                '',
-                '',
-                TRUE
-            ),
-            'Valid IP v6' => array(
-                '::1',
-                '',
-                '',
-                TRUE
-            ),
-            'Valid with devIPMask' => array(
-                '192.168.1.67',
-                'devIPMask',
-                '192.168.1.*',
-                TRUE
-            ),
-            'IP v4' => array(
-                '192.168.1.1',
-                '',
-                '',
-                FALSE
-            ),
-            'IP v6' => array(
-                '2001:db8::ff00:42:8329',
-                '',
-                '',
-                FALSE
-            ),
-            'devIPMask' => array(
-                '80.58.212.14',
-                'devIPMask',
-                '192.168.1.*',
-                FALSE
-            )
+                'Valid IP v4' => array(
+                        '127.0.0.1',
+                        '',
+                        '',
+                        true
+                ),
+                'Valid IP v6' => array(
+                        '::1',
+                        '',
+                        '',
+                        true
+                ),
+                'Valid with devIPMask' => array(
+                        '192.168.1.67',
+                        'devIPMask',
+                        '192.168.1.*',
+                        true
+                ),
+                'IP v4' => array(
+                        '192.168.1.1',
+                        '',
+                        '',
+                        false
+                ),
+                'IP v6' => array(
+                        '2001:db8::ff00:42:8329',
+                        '',
+                        '',
+                        false
+                ),
+                'devIPMask' => array(
+                        '80.58.212.14',
+                        'devIPMask',
+                        '192.168.1.*',
+                        false
+                )
         );
     }
 
@@ -164,7 +169,7 @@ class LoggerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      * @param boolean $result TRUE or FALSE, depending on IP address validity
      * @test
      * @dataProvider ipAddressesProvider
-     * @covers \Devlog\Devlog\Utility\Logger::isIpAddressAccepted
+     * @covers       \Devlog\Devlog\Utility\Logger::isIpAddressAccepted
      */
     public function isIpAddressValid($testValue, $configurationOverride, $devIpMask, $result)
     {
@@ -178,19 +183,19 @@ class LoggerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
             $specialConfiguration = $this->testConfiguration;
             $specialConfiguration['ipFilter'] = $configurationOverride;
             $this->subject->setExtensionConfiguration(
-                $specialConfiguration
+                    $specialConfiguration
             );
         }
         // Perform the actual test
-        $this->assertSame(
-            $result,
-            $this->subject->isIpAddressAccepted(
-                $testValue
-            )
+        self::assertSame(
+                $result,
+                $this->subject->isIpAddressAccepted(
+                        $testValue
+                )
         );
         // Restore extension configuration
         $this->subject->setExtensionConfiguration(
-            $this->testConfiguration
+                $this->testConfiguration
         );
         // Restore devIPmask
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'] = $savedIpMask;
@@ -203,9 +208,9 @@ class LoggerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function getConfigurationReturnsTestValue()
     {
-        $this->assertSame(
-            $this->subject->getExtensionConfiguration(),
-            $this->testConfiguration
+        self::assertSame(
+                $this->subject->getExtensionConfiguration(),
+                $this->testConfiguration
         );
     }
 
@@ -216,8 +221,8 @@ class LoggerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function getIsLoggingEnabledReturnsInitialValueForBoolean()
     {
-        $this->assertTrue(
-            $this->subject->isLoggingEnabled()
+        self::assertTrue(
+                $this->subject->isLoggingEnabled()
         );
     }
 
@@ -227,12 +232,12 @@ class LoggerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function setIsLoggingEnabledForBooleanSetsIsLoggingEnabled()
     {
-        $this->subject->setIsLoggingEnabled(FALSE);
+        $this->subject->setIsLoggingEnabled(false);
 
-        $this->assertAttributeEquals(
-            FALSE,
-            'isLoggingEnabled',
-            $this->subject
+        self::assertAttributeEquals(
+                false,
+                'isLoggingEnabled',
+                $this->subject
         );
     }
 }
index 52100bb..6fd41b7 100644 (file)
@@ -26,7 +26,7 @@ $EM_CONF[$_EXTKEY] = array(
     'author' => 'Francois Suter',
     'author_email' => 'typo3@cobweb.ch',
     'author_company' => '',
-    'version' => '3.0-dev',
+    'version' => '3.0.0-dev',
     'constraints' => array(
         'depends' => array(
             'typo3' => '7.6.0-7.99.99',
index 1fee33d..7d02bb5 100644 (file)
@@ -4,8 +4,8 @@ if (!defined ('TYPO3_MODE')) {
 }
 
 // Register the logging method with the appropriate hook
-$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['devLog'][$_EXTKEY] = 'Devlog\\Devlog\\Utility\\Logger->log';
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['devLog'][$_EXTKEY] = \Devlog\Devlog\Utility\Logger::class . '->log';
 
 // Register log writers
-$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['devlog']['writers']['db'] = 'Devlog\\Devlog\\Writer\\DatabaseWriter';
-$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['devlog']['writers']['file'] = 'Devlog\\Devlog\\Writer\\FileWriter';
+$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['devlog']['writers']['db'] = \Devlog\Devlog\Writer\DatabaseWriter::class;
+$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['devlog']['writers']['file'] = \Devlog\Devlog\Writer\FileWriter::class;
index ffde468..3a977b3 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-if (!defined ('TYPO3_MODE')) {
+if (!defined('TYPO3_MODE')) {
     die ('Access denied.');
 }
 
@@ -7,13 +7,6 @@ if (!defined ('TYPO3_MODE')) {
 
 // Add context sensitive help (csh) to the backend module and to the tx_devlog table
 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr(
-    'tx_devlog_domain_model_entry',
-    'EXT:devlog/Resources/Private/Language/locallang_csh_txdevlog.xlf'
+        'tx_devlog_domain_model_entry',
+        'EXT:devlog/Resources/Private/Language/locallang_csh_txdevlog.xlf'
 );
-
-$pathToExtension = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('devlog');
-// Register the extension's icons
-$icons = array(
-    'entry' => $pathToExtension . 'Resources/Public/Icons/Entry.png',
-);
-\TYPO3\CMS\Backend\Sprite\SpriteManager::addSingleIcons($icons, 'devlog');