[TASK] Clean up DatabaseConnection::fullQuoteArray 38/46038/2
authorNicole Cordes <typo3@cordes.co>
Sun, 17 Jan 2016 21:21:09 +0000 (22:21 +0100)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Tue, 19 Jan 2016 09:08:46 +0000 (10:08 +0100)
If the parameter $noQuote equals true, the given array can be returned
directly as there isn't anything to do.

Furthermore the AccessibleMock object from the test method can be
converted into a normal mock.

Resolves: #72781
Releases: master
Change-Id: Id58e5809b0f7d7d1c3c2c5908c70891f9e90a811
Reviewed-on: https://review.typo3.org/46038
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
typo3/sysext/core/Classes/Database/DatabaseConnection.php
typo3/sysext/core/Tests/Unit/Database/DatabaseConnectionTest.php

index 4b799fd..f6857c3 100644 (file)
@@ -883,10 +883,11 @@ class DatabaseConnection
         } elseif (!is_array($noQuote)) {
             $noQuote = (bool)$noQuote;
         }
+        if ($noQuote === true) {
+            return $arr;
+        }
         foreach ($arr as $k => $v) {
-            if ($noQuote === true) {
-                continue;
-            } elseif ($noQuote === false || !in_array($k, $noQuote)) {
+            if ($noQuote === false || !in_array($k, $noQuote)) {
                 $arr[$k] = $this->fullQuoteStr($v, $table, $allowNull);
             }
         }
index dbc32a0..6065ee8 100644 (file)
@@ -429,14 +429,13 @@ class DatabaseConnectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     public function noQuoteForFullQuoteArray(array $input, array $expected, $noQuote)
     {
         /** @var \TYPO3\CMS\Core\Database\DatabaseConnection|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $subject */
-        $subject = $this->getAccessibleMock(
+        $subject = $this->getMock(
             \TYPO3\CMS\Core\Database\DatabaseConnection::class,
             array('fullQuoteStr'),
             array(),
             '',
             false
         );
-        $subject->_set('isConnected', true);
         $subject
             ->expects($this->any())
             ->method('fullQuoteStr')