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