Followup: [TASK] Avoid using $GLOBALS['TYPO3_DB'] in DataHandler 30/34630/3
authorSebastian Michaelsen <sebastian@michaelsen.io>
Wed, 26 Nov 2014 11:50:32 +0000 (12:50 +0100)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Wed, 26 Nov 2014 12:30:52 +0000 (13:30 +0100)
* Fix wrong PHP namespace when importing DatabaseConnection in the test
* Remove the constructor injection which was added but not used

Resolves: #63326
Releases: master
Change-Id: I310247056647d2ec21f88c606c12220061b6b54b
Reviewed-on: http://review.typo3.org/34630
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php

index 467a157..2a2b503 100644 (file)
@@ -629,10 +629,10 @@ class DataHandler {
        protected $databaseConnection;
 
        /**
-        * @param DatabaseConnection $databaseConnection
+        *
         */
-       public function __construct(DatabaseConnection $databaseConnection = NULL) {
-               $this->databaseConnection = $databaseConnection ?: $GLOBALS['TYPO3_DB'];
+       public function __construct() {
+               $this->databaseConnection = $GLOBALS['TYPO3_DB'];
        }
 
        /**
@@ -850,7 +850,7 @@ class DataHandler {
         * Processing the data-array
         * Call this function to process the data-array set by start()
         *
-        * @return void
+        * @return void|FALSE
         */
        public function process_datamap() {
                $this->controlActiveElements();
index ae48d91..dc1e898 100644 (file)
@@ -17,7 +17,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\DataHandler;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\DataHandling\DataHandler;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Dbal\Database\DatabaseConnection;
+use TYPO3\CMS\Core\Database\DatabaseConnection;
 
 /**
  * Test case
@@ -38,19 +38,25 @@ class DataHandlerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        protected $subject;
 
        /**
-        * @var \TYPO3\CMS\Core\Authentication\BackendUserAuthentication a mock logged-in back-end user
+        * @var BackendUserAuthentication a mock logged-in back-end user
         */
        protected $backEndUser;
 
+       /**
+        * Set up the tests
+        */
        public function setUp() {
                $GLOBALS['TCA'] = array();
                $this->singletonInstances = GeneralUtility::getSingletonInstances();
-               $this->backEndUser = $this->getMock('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
+               $this->backEndUser = $this->getMock(BackendUserAuthentication::class);
                $GLOBALS['TYPO3_DB'] = $this->getMock(DatabaseConnection::class, array(), array(), '', FALSE);
                $this->subject = new DataHandler();
                $this->subject->start(array(), '', $this->backEndUser);
        }
 
+       /**
+        * Tear down the tests
+        */
        public function tearDown() {
                GeneralUtility::resetSingletonInstances($this->singletonInstances);
                parent::tearDown();
@@ -170,6 +176,8 @@ class DataHandlerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        /**
         * @test
         * @dataProvider inputValuesStringsDataProvider
+        * @param string $value
+        * @param int $expectedReturnValue
         */
        public function inputValueCheckRecognizesStringValuesAsIntegerValuesCorrectly($value, $expectedReturnValue) {
                $tcaFieldConf = array(
@@ -582,7 +590,7 @@ class DataHandlerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                        array('dummy')
                );
 
-               $backendUser = $this->getMock('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
+               $backendUser = $this->getMock(BackendUserAuthentication::class);
                $subject->BE_USER = $backendUser;
                $subject->BE_USER->workspace = 1;