c2c2ae0e557cfdd352ba0d3bc2ae2763276208e7
[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 * Copyright notice
6 *
7 * (c) 2012
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Test case
29 */
30 class EmConfUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
31
32 /**
33 * @test
34 */
35 public function constructEmConfAddsCommentBlock() {
36 $extensionData = array(
37 'extKey' => 'key',
38 'EM_CONF' => array(),
39 );
40 $fixture = new \TYPO3\CMS\Extensionmanager\Utility\EmConfUtility();
41 $emConf = $fixture->constructEmConf($extensionData);
42 $this->assertContains('Extension Manager/Repository config file for ext', $emConf);
43 }
44
45 /**
46 * @test
47 */
48 public function fixEmConfTransfersOldConflictSettingToNewFormatWithSingleConflictingExtension() {
49 $input = array(
50 'title' => 'a title',
51 'conflicts' => 'foo',
52 );
53 $expected = array(
54 'title' => 'a title',
55 'conflicts' => 'foo',
56 'constraints' => array(
57 'depends' => array(),
58 'conflicts' => array(
59 'foo' => '',
60 ),
61 'suggests' => array(),
62 ),
63 );
64 $fixture = new \TYPO3\CMS\Extensionmanager\Utility\EmConfUtility();
65 $this->assertEquals($expected, $fixture->fixEmConf($input));
66 }
67
68 /**
69 * @test
70 */
71 public function fixEmConfTransfersOldConflictSettingToNewFormatWithTwoConflictingExtensions() {
72 $input = array(
73 'title' => 'a title',
74 'conflicts' => 'foo,bar',
75 );
76 $expected = array(
77 'title' => 'a title',
78 'conflicts' => 'foo,bar',
79 'constraints' => array(
80 'depends' => array(),
81 'conflicts' => array(
82 'foo' => '',
83 'bar' => '',
84 ),
85 'suggests' => array(),
86 ),
87 );
88 $fixture = new \TYPO3\CMS\Extensionmanager\Utility\EmConfUtility();
89 $this->assertEquals($expected, $fixture->fixEmConf($input));
90 }
91
92 /**
93 * @test
94 */
95 public function dependencyToStringUnsetsDependencies() {
96 $config = array(
97 'depends' => array(
98 'php' => '5.0',
99 'something' => 'foo',
100 'anything' => 'bar'
101 )
102 );
103 $expected = 'something,anything';
104
105 /** @var \TYPO3\CMS\Extensionmanager\Utility\EmConfUtility $fixture */
106 $fixture = $fixture = new \TYPO3\CMS\Extensionmanager\Utility\EmConfUtility();
107 $result = $fixture::dependencyToString($config);
108 $this->assertEquals($expected, $result);
109 }
110
111 /**
112 * @test
113 */
114 public function dependencyToStringDealsWithInvalidInput() {
115 $input = array(
116 'depends' => 'hello world'
117 );
118 /** @var \TYPO3\CMS\Extensionmanager\Utility\EmConfUtility $fixture */
119 $fixture = $fixture = new \TYPO3\CMS\Extensionmanager\Utility\EmConfUtility();
120 $this->assertEquals('', $fixture::dependencyToString($input));
121 }
122 }