From c2c1fc6936c2d0ba27b63f981f276b7fec13ea4b Mon Sep 17 00:00:00 2001 From: Sebastian Michaelsen <sebastian@michaelsen.io> Date: Wed, 26 Nov 2014 12:50:32 +0100 Subject: [PATCH] Followup: [TASK] Avoid using $GLOBALS['TYPO3_DB'] in DataHandler * 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> --- .../core/Classes/DataHandling/DataHandler.php | 8 ++++---- .../Tests/Unit/DataHandling/DataHandlerTest.php | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/typo3/sysext/core/Classes/DataHandling/DataHandler.php b/typo3/sysext/core/Classes/DataHandling/DataHandler.php index 467a157df92e..2a2b503638cc 100644 --- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php +++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php @@ -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(); diff --git a/typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php b/typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php index ae48d910ce6c..dc1e8980de7f 100644 --- a/typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php +++ b/typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php @@ -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; -- GitLab