EmConfUtilityTest.php 2.45 KB
Newer Older
1
<?php
2

3
/*
4
 * This file is part of the TYPO3 CMS project.
5
 *
6
7
8
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
9
 *
10
11
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
12
 *
13
14
 * The TYPO3 project - inspiring people to share!
 */
15

16
17
namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Utility;

18
19
20
use TYPO3\CMS\Extensionmanager\Utility\EmConfUtility;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

21
/**
22
 * Test case
23
 */
24
class EmConfUtilityTest extends UnitTestCase
25
{
26

27
28
29
30
31
    /**
     * @test
     */
    public function constructEmConfAddsCommentBlock()
    {
32
        $subject = new EmConfUtility();
33
        $emConf = $subject->constructEmConf('key', []);
34
        self::assertStringContainsString('Extension Manager/Repository config file for ext', $emConf);
35
    }
36

37
38
39
40
41
    /**
     * @test
     */
    public function fixEmConfTransfersOldConflictSettingToNewFormatWithSingleConflictingExtension()
    {
42
        $input = [
43
44
            'title' => 'a title',
            'conflicts' => 'foo',
45
46
        ];
        $expected = [
47
            'title' => 'a title',
48
49
50
            'constraints' => [
                'depends' => [],
                'conflicts' => [
51
                    'foo' => '',
52
53
54
55
                ],
                'suggests' => [],
            ],
        ];
56
        $subject = new EmConfUtility();
57
        $_EXTKEY = 'seminars';
58
        $result = $subject->constructEmConf($_EXTKEY, $input);
59
60
61
        eval(substr($result, 7));
        $result = $EM_CONF[$_EXTKEY];
        self::assertEquals($expected, $result);
62
    }
63

64
65
66
67
68
    /**
     * @test
     */
    public function fixEmConfTransfersOldConflictSettingToNewFormatWithTwoConflictingExtensions()
    {
69
        $input = [
70
71
            'title' => 'a title',
            'conflicts' => 'foo,bar',
72
73
        ];
        $expected = [
74
            'title' => 'a title',
75
76
77
            'constraints' => [
                'depends' => [],
                'conflicts' => [
78
79
                    'foo' => '',
                    'bar' => '',
80
81
82
83
                ],
                'suggests' => [],
            ],
        ];
84
85
        $subject = new EmConfUtility();

86
        $_EXTKEY = 'seminars';
87
        $result = $subject->constructEmConf($_EXTKEY, $input);
88
89
90
        eval(substr($result, 7));
        $result = $EM_CONF[$_EXTKEY];
        self::assertEquals($expected, $result);
91
    }
92
}