[BUGFIX] Respect newlines in ['SYS']['binSetup']
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Utility / CommandUtilityTest.php
1 <?php
2 namespace TYPO3\CMS\Core\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 use TYPO3\CMS\Core\Utility\CommandUtility;
17
18 /**
19 * Test case for class \TYPO3\CMS\Core\Utility\CommandUtility
20 */
21 class CommandUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
22
23 /**
24 * Data provider for getConfiguredApps
25 *
26 * @return array
27 */
28 public function getConfiguredAppsDataProvider() {
29 $defaultExpected = array(
30 'perl' => array(
31 'app' => 'perl',
32 'path' => '/usr/bin/',
33 'valid' => TRUE
34 ),
35 'unzip' => array(
36 'app' => 'unzip',
37 'path' => '/usr/local/bin/',
38 'valid' => TRUE
39 ),
40 );
41 return array(
42 'returns empty array for empty string' => array(
43 '',
44 array()
45 ),
46 'separated by comma' => array(
47 'perl=/usr/bin/perl,unzip=/usr/local/bin/unzip',
48 $defaultExpected
49 ),
50 'separated by new line' => array(
51 'perl=/usr/bin/perl ' . LF . ' unzip=/usr/local/bin/unzip',
52 $defaultExpected
53 ),
54 'separated by new line with spaces' => array(
55 'perl = /usr/bin/perl ' . LF . ' unzip = /usr/local/bin/unzip',
56 $defaultExpected
57 ),
58 'separated by new line with spaces and empty rows' => array(
59 LF . 'perl = /usr/bin/perl ' . LF . LF . ' unzip = /usr/local/bin/unzip' . LF,
60 $defaultExpected
61 ),
62 'separated by char(10)' => array(
63 'perl=/usr/bin/perl' . '\'.chr(10).\'' . 'unzip=/usr/local/bin/unzip',
64 $defaultExpected
65 ),
66 'separated by LF as string' => array(
67 'perl=/usr/bin/perl' . '\' . LF . \'' . 'unzip=/usr/local/bin/unzip',
68 $defaultExpected
69 )
70 );
71 }
72
73 /**
74 * @dataProvider getConfiguredAppsDataProvider
75 * @param array $globalsBinSetup
76 * @param array $expected
77 * @test
78 */
79 public function getConfiguredApps($globalsBinSetup, $expected) {
80 $GLOBALS['TYPO3_CONF_VARS']['SYS']['binSetup'] = $globalsBinSetup;
81 $commandUtilityMock = $this->getAccessibleMock(CommandUtility::class, array('dummy'));
82 $result = $commandUtilityMock->_call('getConfiguredApps');
83 $this->assertSame($expected, $result);
84 }
85
86 }