be8af578b367b660b18ed04fb270bed0172ec24f
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Tests / Unit / Utility / EmConfUtilityTest.php
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Utility;
3
4 /**
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Test case
19 */
20 class EmConfUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
21
22 /**
23 * @test
24 */
25 public function constructEmConfAddsCommentBlock() {
26 $extensionData = array(
27 'extKey' => 'key',
28 'EM_CONF' => array(),
29 );
30 $fixture = new \TYPO3\CMS\Extensionmanager\Utility\EmConfUtility();
31 $emConf = $fixture->constructEmConf($extensionData);
32 $this->assertContains('Extension Manager/Repository config file for ext', $emConf);
33 }
34
35 /**
36 * @test
37 */
38 public function fixEmConfTransfersOldConflictSettingToNewFormatWithSingleConflictingExtension() {
39 $input = array(
40 'title' => 'a title',
41 'conflicts' => 'foo',
42 );
43 $expected = array(
44 'title' => 'a title',
45 'conflicts' => 'foo',
46 'constraints' => array(
47 'depends' => array(),
48 'conflicts' => array(
49 'foo' => '',
50 ),
51 'suggests' => array(),
52 ),
53 );
54 $fixture = new \TYPO3\CMS\Extensionmanager\Utility\EmConfUtility();
55 $this->assertEquals($expected, $fixture->fixEmConf($input));
56 }
57
58 /**
59 * @test
60 */
61 public function fixEmConfTransfersOldConflictSettingToNewFormatWithTwoConflictingExtensions() {
62 $input = array(
63 'title' => 'a title',
64 'conflicts' => 'foo,bar',
65 );
66 $expected = array(
67 'title' => 'a title',
68 'conflicts' => 'foo,bar',
69 'constraints' => array(
70 'depends' => array(),
71 'conflicts' => array(
72 'foo' => '',
73 'bar' => '',
74 ),
75 'suggests' => array(),
76 ),
77 );
78 $fixture = new \TYPO3\CMS\Extensionmanager\Utility\EmConfUtility();
79 $this->assertEquals($expected, $fixture->fixEmConf($input));
80 }
81
82 /**
83 * @test
84 */
85 public function dependencyToStringUnsetsDependencies() {
86 $config = array(
87 'depends' => array(
88 'php' => '5.0',
89 'something' => 'foo',
90 'anything' => 'bar'
91 )
92 );
93 $expected = 'something,anything';
94
95 /** @var \TYPO3\CMS\Extensionmanager\Utility\EmConfUtility $fixture */
96 $fixture = $fixture = new \TYPO3\CMS\Extensionmanager\Utility\EmConfUtility();
97 $result = $fixture::dependencyToString($config);
98 $this->assertEquals($expected, $result);
99 }
100
101 /**
102 * @test
103 */
104 public function dependencyToStringDealsWithInvalidInput() {
105 $input = array(
106 'depends' => 'hello world'
107 );
108 /** @var \TYPO3\CMS\Extensionmanager\Utility\EmConfUtility $fixture */
109 $fixture = $fixture = new \TYPO3\CMS\Extensionmanager\Utility\EmConfUtility();
110 $this->assertEquals('', $fixture::dependencyToString($input));
111 }
112 }