[FOLLOWUP][BUGFIX] Fix parse time calculation 27/52827/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Wed, 17 May 2017 14:49:14 +0000 (16:49 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 17 May 2017 14:59:32 +0000 (16:59 +0200)
Unit test: Fix namespace, test file location and class inheritance.

Change-Id: Ida24b5adf747dc7c259a966fcddfdb7feb9f0951
Resolves: #80742
Releases: master, 8.7
Reviewed-on: https://review.typo3.org/52827
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Tests/TimeTracker/TimeTrackerTest.php [deleted file]
typo3/sysext/core/Tests/Unit/TimeTracker/TimeTrackerTest.php [new file with mode: 0644]

diff --git a/typo3/sysext/core/Tests/TimeTracker/TimeTrackerTest.php b/typo3/sysext/core/Tests/TimeTracker/TimeTrackerTest.php
deleted file mode 100644 (file)
index b8922de..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-<?php
-declare(strict_types=1);
-
-namespace TimeTracker;
-
-/*
- * 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\Core\TimeTracker\TimeTracker;
-
-/**
- * Class TimeTrackerTest
- */
-class TimeTrackerTest extends \PHPUnit_Framework_TestCase
-{
-    /**
-     * @var bool
-     */
-    protected $backupGlobals = true;
-
-    /**
-     * @var TimeTracker
-     */
-    protected $timeTracker;
-
-    protected function setUp()
-    {
-        $this->timeTracker = new TimeTracker();
-    }
-
-    /**
-     * @test
-     */
-    public function getParseTimeReturnsZeroIfNoValuesAreSet()
-    {
-        unset(
-            $GLOBALS['TYPO3_MISC']['microtime_end'],
-            $GLOBALS['TYPO3_MISC']['microtime_start'],
-            $GLOBALS['TYPO3_MISC']['microtime_BE_USER_start'],
-            $GLOBALS['TYPO3_MISC']['microtime_BE_USER_end']
-        );
-        $parseTime = $this->timeTracker->getParseTime();
-        self::assertSame(0, $parseTime);
-    }
-
-    /**
-     * @test
-     */
-    public function getParseTimeReturnsTotalParseTimeInMillisecondsWithoutBeUserInitialization()
-    {
-        $baseValue = time();
-        $GLOBALS['TYPO3_MISC']['microtime_start'] = $baseValue;
-        $GLOBALS['TYPO3_MISC']['microtime_end'] = $baseValue + 10;
-        $GLOBALS['TYPO3_MISC']['microtime_BE_USER_start'] = $baseValue + 1;
-        $GLOBALS['TYPO3_MISC']['microtime_BE_USER_end'] = $baseValue + 3;
-        $parseTime = $this->timeTracker->getParseTime();
-        self::assertSame(8000, $parseTime);
-    }
-
-    /**
-     * @test
-     */
-    public function getParseTimeReturnsParseTimeIfOnlyOneBeUserTimeWasSet()
-    {
-        $baseValue = time();
-        $GLOBALS['TYPO3_MISC']['microtime_start'] = $baseValue;
-        $GLOBALS['TYPO3_MISC']['microtime_end'] = $baseValue + 10;
-        $GLOBALS['TYPO3_MISC']['microtime_BE_USER_start'] = $baseValue + 1;
-        $GLOBALS['TYPO3_MISC']['microtime_BE_USER_end'] = 0;
-        $parseTime = $this->timeTracker->getParseTime();
-        self::assertSame(10000, $parseTime);
-    }
-
-    /**
-     * @test
-     */
-    public function getParseTimeReturnsParseTimeIfNoBeUserTimeWasSet()
-    {
-        $baseValue = time();
-        $GLOBALS['TYPO3_MISC']['microtime_start'] = $baseValue;
-        $GLOBALS['TYPO3_MISC']['microtime_end'] = $baseValue + 10;
-        $GLOBALS['TYPO3_MISC']['microtime_BE_USER_start'] = 0;
-        $GLOBALS['TYPO3_MISC']['microtime_BE_USER_end'] = 0;
-        $parseTime = $this->timeTracker->getParseTime();
-        self::assertSame(10000, $parseTime);
-    }
-}
diff --git a/typo3/sysext/core/Tests/Unit/TimeTracker/TimeTrackerTest.php b/typo3/sysext/core/Tests/Unit/TimeTracker/TimeTrackerTest.php
new file mode 100644 (file)
index 0000000..423003e
--- /dev/null
@@ -0,0 +1,82 @@
+<?php
+declare(strict_types=1);
+namespace TYPO3\CMS\Core\Tests\Unit\TimeTracker;
+
+/*
+ * 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\Core\TimeTracker\TimeTracker;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+
+/**
+ * Class TimeTrackerTest
+ */
+class TimeTrackerTest extends UnitTestCase
+{
+    /**
+     * @test
+     */
+    public function getParseTimeReturnsZeroIfNoValuesAreSet()
+    {
+        unset(
+            $GLOBALS['TYPO3_MISC']['microtime_end'],
+            $GLOBALS['TYPO3_MISC']['microtime_start'],
+            $GLOBALS['TYPO3_MISC']['microtime_BE_USER_start'],
+            $GLOBALS['TYPO3_MISC']['microtime_BE_USER_end']
+        );
+        $parseTime = (new TimeTracker())->getParseTime();
+        self::assertSame(0, $parseTime);
+    }
+
+    /**
+     * @test
+     */
+    public function getParseTimeReturnsTotalParseTimeInMillisecondsWithoutBeUserInitialization()
+    {
+        $baseValue = time();
+        $GLOBALS['TYPO3_MISC']['microtime_start'] = $baseValue;
+        $GLOBALS['TYPO3_MISC']['microtime_end'] = $baseValue + 10;
+        $GLOBALS['TYPO3_MISC']['microtime_BE_USER_start'] = $baseValue + 1;
+        $GLOBALS['TYPO3_MISC']['microtime_BE_USER_end'] = $baseValue + 3;
+        $parseTime = (new TimeTracker())->getParseTime();
+        self::assertSame(8000, $parseTime);
+    }
+
+    /**
+     * @test
+     */
+    public function getParseTimeReturnsParseTimeIfOnlyOneBeUserTimeWasSet()
+    {
+        $baseValue = time();
+        $GLOBALS['TYPO3_MISC']['microtime_start'] = $baseValue;
+        $GLOBALS['TYPO3_MISC']['microtime_end'] = $baseValue + 10;
+        $GLOBALS['TYPO3_MISC']['microtime_BE_USER_start'] = $baseValue + 1;
+        $GLOBALS['TYPO3_MISC']['microtime_BE_USER_end'] = 0;
+        $parseTime = (new TimeTracker())->getParseTime();
+        self::assertSame(10000, $parseTime);
+    }
+
+    /**
+     * @test
+     */
+    public function getParseTimeReturnsParseTimeIfNoBeUserTimeWasSet()
+    {
+        $baseValue = time();
+        $GLOBALS['TYPO3_MISC']['microtime_start'] = $baseValue;
+        $GLOBALS['TYPO3_MISC']['microtime_end'] = $baseValue + 10;
+        $GLOBALS['TYPO3_MISC']['microtime_BE_USER_start'] = 0;
+        $GLOBALS['TYPO3_MISC']['microtime_BE_USER_end'] = 0;
+        $parseTime = (new TimeTracker())->getParseTime();
+        self::assertSame(10000, $parseTime);
+    }
+}