[TASK] Use single quotes instead of double quotes
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Tests / Unit / Service / EnableFileServiceTest.php
1 <?php
2 namespace TYPO3\CMS\Install\Tests\Unit\Service;
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 use org\bovigo\vfs\vfsStream;
18
19 /**
20 * Test case
21 */
22 class EnableFileServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
23 {
24 /**
25 * Data provider
26 *
27 * @return array
28 */
29 public function getFirstInstallFilePathsDataProvider()
30 {
31 return array(
32 'first-install-file-present' => array(
33 array(
34 'FIRST_INSTALL2Folder' => array(),
35 'FIRST_INSTALL' => '',
36 'FIRST_INStall' => '',
37 'FIRST_INSTALL.txt' => 'with content',
38 'somethingelse' => '',
39 'dadadaFIRST_INStall' => '',
40 ),
41 array(
42 'FIRST_INSTALL',
43 'FIRST_INStall',
44 'FIRST_INSTALL.txt',
45 ),
46 ),
47 'no-first-install-file' => array(
48 array(
49 'FIRST_INSTALL2Folder' => array(),
50 'foo' => '',
51 'bar' => '',
52 'ddd.txt' => 'with content',
53 'somethingelse' => '',
54 'dadadaFIRST_INStall' => '',
55 ),
56 array(),
57 ),
58 );
59 }
60
61 /**
62 * @test
63 * @dataProvider getFirstInstallFilePathsDataProvider
64 */
65 public function getFirstInstallFilePaths($structure, $expected)
66 {
67 $vfs = vfsStream::setup('root');
68 vfsStream::create($structure, $vfs);
69 /** @var $instance \TYPO3\CMS\Install\Service\EnableFileService|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
70 $instance = $this->getAccessibleMock(\TYPO3\CMS\Install\Service\EnableFileService::class, array('dummy'), array(), '', false);
71 $instance->_setStatic('sitePath', 'vfs://root/');
72 $this->assertEquals(array(), array_diff($expected, $instance->_call('getFirstInstallFilePaths')));
73 }
74
75 /**
76 * Data provider
77 *
78 * @return array
79 */
80 public function removeFirstInstallFileDataProvider()
81 {
82 return array(
83 'first-install-file-present' => array(
84 array(
85 'FIRST_INSTALL2Folder' => array(),
86 'FIRST_INSTALL' => '',
87 'FIRST_INStall' => '',
88 'FIRST_INSTALL.txt' => 'with content',
89 'somethingelse' => '',
90 'dadadaFIRST_INStall' => '',
91 ),
92 array(
93 '.',
94 '..',
95 'FIRST_INSTALL2Folder',
96 'somethingelse',
97 'dadadaFIRST_INStall',
98 ),
99 ),
100 'no-first-install-file' => array(
101 array(
102 'FIRST_INSTALL2Folder' => array(),
103 'foo' => '',
104 'bar' => '',
105 'ddd.txt' => 'with content',
106 'somethingelse' => '',
107 'dadadaFIRST_INStall' => '',
108 ),
109 array(
110 '.',
111 '..',
112 'FIRST_INSTALL2Folder',
113 'foo',
114 'bar',
115 'ddd.txt',
116 'somethingelse',
117 'dadadaFIRST_INStall',
118 ),
119 ),
120 );
121 }
122
123 /**
124 * @test
125 * @dataProvider removeFirstInstallFileDataProvider
126 */
127 public function removeFirstInstallFile($structure, $expected)
128 {
129 $vfs = vfsStream::setup('root');
130 vfsStream::create($structure, $vfs);
131 /** @var $instance \TYPO3\CMS\Install\Service\EnableFileService|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
132 $instance = $this->getAccessibleMock(\TYPO3\CMS\Install\Service\EnableFileService::class, array('dummy'), array(), '', false);
133 $instance->_setStatic('sitePath', 'vfs://root/');
134 $instance->_call('removeFirstInstallFile');
135
136 $this->assertEquals(array(), array_diff($expected, scandir('vfs://root/')));
137 }
138 }