[BUGFIX] Fix EmConfUtility::fixEmConf conflicts generation 46/22746/3
authorSascha Egerer <sascha.egerer@dkd.de>
Thu, 1 Aug 2013 09:46:42 +0000 (11:46 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Tue, 6 Aug 2013 18:58:14 +0000 (20:58 +0200)
EmConfUtility::fixEmConf generates a string instead
of an array for "$emConf['constraints']['conflicts']"

Resolves: #50628
Releases: 6.2, 6.1, 6.0
Change-Id: I37e026569e761b8550a9b0e6a1cb10835f6c899b
Reviewed-on: https://review.typo3.org/22746
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Sascha Egerer
Tested-by: Sascha Egerer
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/extensionmanager/Classes/Utility/EmConfUtility.php
typo3/sysext/extensionmanager/Tests/Unit/Utility/EmConfUtilityTest.php

index 7d715fc..6e19894 100644 (file)
@@ -103,7 +103,7 @@ $EM_CONF[$_EXTKEY] = ' . $emConf . ';
                                }
                        }
                        if (!isset($emConf['constraints']) || !isset($emConf['constraints']['conflicts'])) {
-                               $emConf['constraints']['conflicts'] = $this->dependencyToString($emConf['conflicts']);
+                               $emConf['constraints']['conflicts'] = $this->stringToDependency($emConf['conflicts']);
                        }
                        if (!isset($emConf['constraints']) || !isset($emConf['constraints']['suggests'])) {
                                $emConf['constraints']['suggests'] = array();
index d461b44..4b0d9dc 100644 (file)
@@ -25,66 +25,68 @@ namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Utility;
  ***************************************************************/
 
 /**
- * EmConf utility test
- *
+ * Test case
  */
 class EmConfUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
 
        /**
-        * Data Provider for construct em conf tests
-        *
-        * @return array
+        * @test
         */
-       public function constructEmConfDataProvider() {
-               return array(
-                       array(
-                               array(
-                                       'extKey' => 'enetcache',
-                                       'EM_CONF' => array(
-                                               'title' => 'Plugin cache engine',
-                                               'description' => 'Provides an interface to cache plugin content elements based on 4.3 caching framework',
-                                               'category' => 'Frontend',
-                                               'shy' => 0,
-                                               'version' => '1.0.6',
-                                               'dependencies' => '',
-                                               'conflicts' => '',
-                                               'priority' => '',
-                                               'loadOrder' => '',
-                                               'TYPO3_version' => '4.3.0-0.0.0',
-                                               'PHP_version' => '',
-                                               'module' => '',
-                                               'state' => 'stable',
-                                               'uploadfolder' => 0,
-                                               'createDirs' => '',
-                                               'modify_tables' => '',
-                                               'clearcacheonload' => 0,
-                                               'lockType' => '',
-                                               'author' => 'Firstname Lastname',
-                                               'author_email' => 'test@example.com',
-                                               'author_company' => 'test',
-                                               'CGLcompliance' => NULL,
-                                               'CGLcompliance_note' => NULL
-                                       )
-                               )
-                       )
+       public function constructEmConfAddsCommentBlock() {
+               $extensionData = array(
+                       'extKey' => 'key',
+                       'EM_CONF' => array(),
                );
+               $fixture = new \TYPO3\CMS\Extensionmanager\Utility\EmConfUtility();
+               $emConf = $fixture->constructEmConf($extensionData);
+               $this->assertContains('Extension Manager/Repository config file for ext', $emConf);
        }
 
        /**
-        * Tests whether the comment block is added
-        *
-        * @param array $extensionData
         * @test
-        * @dataProvider constructEmConfDataProvider
-        * @return void
         */
-       public function constructEmConfAddsCommentBlock(array $extensionData) {
-               $fileHandlerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\EmConfUtility', array('includeEmConf'));
-               $emConf = $fileHandlerMock->_call('constructEmConf', $extensionData);
-               $this->assertContains('Extension Manager/Repository config file for ext', $emConf);
+       public function fixEmConfTransfersOldConflictSettingToNewFormatWithSingleConflictingExtension() {
+               $input = array(
+                       'title' => 'a title',
+                       'conflicts' => 'foo',
+               );
+               $expected = array(
+                       'title' => 'a title',
+                       'conflicts' => 'foo',
+                       'constraints' => array(
+                               'depends' => array(),
+                               'conflicts' => array(
+                                       'foo' => '',
+                               ),
+                               'suggests' => array(),
+                       ),
+               );
+               $fixture = new \TYPO3\CMS\Extensionmanager\Utility\EmConfUtility();
+               $this->assertEquals($expected, $fixture->fixEmConf($input));
        }
 
+       /**
+        * @test
+        */
+       public function fixEmConfTransfersOldConflictSettingToNewFormatWithTwoConflictingExtensions() {
+               $input = array(
+                       'title' => 'a title',
+                       'conflicts' => 'foo,bar',
+               );
+               $expected = array(
+                       'title' => 'a title',
+                       'conflicts' => 'foo,bar',
+                       'constraints' => array(
+                               'depends' => array(),
+                               'conflicts' => array(
+                                       'foo' => '',
+                                       'bar' => '',
+                               ),
+                               'suggests' => array(),
+                       ),
+               );
+               $fixture = new \TYPO3\CMS\Extensionmanager\Utility\EmConfUtility();
+               $this->assertEquals($expected, $fixture->fixEmConf($input));
+       }
 }
-
-
 ?>
\ No newline at end of file