23 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
36 $node = $this->getAccessibleMock(AbstractNode::class, [
'dummy'], [],
'',
false);
37 $name = $this->getUniqueId(
'name_');
38 $node->_set(
'name', $name);
39 $this->assertSame($name, $node->getName());
48 $node = $this->getAccessibleMock(AbstractNode::class, [
'dummy'], [],
'',
false);
50 $node->_set(
'targetPermission', $permission);
51 $this->assertSame($permission, $node->_call(
'getTargetPermission'));
60 $node = $this->getAccessibleMock(AbstractNode::class, [
'dummy'], [],
'',
false);
62 $node->_set(
'children', $children);
63 $this->assertSame($children, $node->_call(
'getChildren'));
72 $node = $this->getAccessibleMock(AbstractNode::class, [
'dummy'], [],
'',
false);
73 $parent = $this->createMock(\
TYPO3\CMS\Install\FolderStructure\RootNodeInterface::class);
74 $node->_set(
'parent', $parent);
75 $this->assertSame($parent, $node->_call(
'getParent'));
84 $node = $this->getAccessibleMock(AbstractNode::class, [
'dummy'], [],
'',
false);
85 $parent = $this->createMock(\
TYPO3\CMS\Install\FolderStructure\RootNodeInterface::class);
86 $parentPath =
'/foo/bar';
87 $parent->expects($this->once())->method(
'getAbsolutePath')->will($this->returnValue($parentPath));
88 $name = $this->getUniqueId(
'test_');
89 $node->_set(
'parent', $parent);
90 $node->_set(
'name', $name);
91 $this->assertSame($parentPath .
'/' . $name, $node->getAbsolutePath());
100 $node = $this->getAccessibleMock(AbstractNode::class, [
'dummy'], [],
'',
false);
101 $parentMock = $this->createMock(\
TYPO3\CMS\Install\FolderStructure\NodeInterface::class);
102 $parentMock->expects($this->once())->method(
'isWritable');
103 $node->_set(
'parent', $parentMock);
113 $node = $this->getAccessibleMock(AbstractNode::class, [
'dummy'], [],
'',
false);
114 $parentMock = $this->createMock(\
TYPO3\CMS\Install\FolderStructure\NodeInterface::class);
115 $parentMock->expects($this->once())->method(
'isWritable')->will($this->returnValue(
true));
116 $node->_set(
'parent', $parentMock);
117 $this->assertTrue($node->isWritable());
126 $node = $this->getAccessibleMock(AbstractNode::class, [
'getAbsolutePath'], [],
'',
false);
128 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
129 $this->assertTrue($node->_call(
'exists'));
139 $node = $this->getAccessibleMock(AbstractNode::class, [
'getAbsolutePath'], [],
'',
false);
143 symlink($target, $path);
145 $this->testFilesToDelete[] = $path;
146 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
147 $this->assertTrue($node->_call(
'exists'));
156 $node = $this->getAccessibleMock(AbstractNode::class, [
'getAbsolutePath'], [],
'',
false);
158 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
159 $this->assertFalse($node->_call(
'exists'));
168 $node = $this->getAccessibleMock(
170 [
'isPermissionCorrect',
'getAbsolutePath'],
175 $this->expectException(Exception::class);
176 $this->expectExceptionCode(1366744035);
177 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue(
''));
178 $node->expects($this->once())->method(
'isPermissionCorrect')->will($this->returnValue(
true));
179 $node->_call(
'fixPermission');
187 if (function_exists(
'posix_getegid') && posix_getegid() === 0) {
188 $this->markTestSkipped(
'Test skipped if run on linux as root');
191 $node = $this->getAccessibleMock(
193 [
'isPermissionCorrect',
'getRelativePathBelowSiteRoot',
'getAbsolutePath'],
198 $node->expects($this->any())->method(
'getRelativePathBelowSiteRoot')->will($this->returnValue(
''));
199 $node->expects($this->once())->method(
'isPermissionCorrect')->will($this->returnValue(
false));
201 $subPath = $path .
'/' . $this->getUniqueId(
'dir_');
204 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($subPath));
205 $node->_set(
'targetPermission',
'2770');
215 if (function_exists(
'posix_getegid') && posix_getegid() === 0) {
216 $this->markTestSkipped(
'Test skipped if run on linux as root');
219 $node = $this->getAccessibleMock(
221 [
'isPermissionCorrect',
'getRelativePathBelowSiteRoot',
'getAbsolutePath'],
226 $node->expects($this->any())->method(
'getRelativePathBelowSiteRoot')->will($this->returnValue(
''));
227 $node->expects($this->once())->method(
'isPermissionCorrect')->will($this->returnValue(
false));
229 $subPath = $path .
'/' . $this->getUniqueId(
'dir_');
232 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($subPath));
233 $node->_set(
'targetPermission',
'2770');
244 $node = $this->getAccessibleMock(
246 [
'isPermissionCorrect',
'getRelativePathBelowSiteRoot',
'getAbsolutePath'],
251 $node->expects($this->any())->method(
'getRelativePathBelowSiteRoot')->will($this->returnValue(
''));
252 $node->expects($this->once())->method(
'isPermissionCorrect')->will($this->returnValue(
false));
254 $subPath = $path .
'/' . $this->getUniqueId(
'dir_');
257 $node->_set(
'targetPermission',
'2770');
258 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($subPath));
259 $this->assertEquals(
FlashMessage::OK, $node->_call(
'fixPermission')->getSeverity());
260 $resultDirectoryPermissions = substr(decoct(fileperms($subPath)), 1);
261 $this->assertSame(
'2770', $resultDirectoryPermissions);
270 $node = $this->getAccessibleMock(AbstractNode::class, [
'isWindowsOs'], [],
'',
false);
271 $node->expects($this->once())->method(
'isWindowsOs')->will($this->returnValue(
true));
272 $this->assertTrue($node->_call(
'isPermissionCorrect'));
281 $node = $this->getAccessibleMock(AbstractNode::class, [
'isWindowsOs',
'getCurrentPermission'], [],
'',
false);
282 $node->expects($this->any())->method(
'isWindowsOs')->will($this->returnValue(
false));
283 $node->expects($this->any())->method(
'getCurrentPermission')->will($this->returnValue(
'foo'));
284 $node->_set(
'targetPermission',
'bar');
285 $this->assertFalse($node->_call(
'isPermissionCorrect'));
294 $node = $this->getAccessibleMock(AbstractNode::class, [
'getAbsolutePath'], [],
'',
false);
298 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
299 $this->assertSame(
'2775', $node->_call(
'getCurrentPermission'));
308 $node = $this->getAccessibleMock(AbstractNode::class, [
'getAbsolutePath'], [],
'',
false);
313 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($file));
314 $this->assertSame(
'0770', $node->_call(
'getCurrentPermission'));
322 $this->expectException(InvalidArgumentException::class);
323 $this->expectExceptionCode(1366398198);
325 $node = $this->getAccessibleMock(AbstractNode::class, [
'dummy'], [],
'',
false);
326 $node->_call(
'getRelativePathBelowSiteRoot',
'/tmp');
335 $node = $this->getAccessibleMock(
343 $node->_call(
'getRelativePathBelowSiteRoot',
null);
352 $node = $this->getAccessibleMock(AbstractNode::class, [
'dummy'], [],
'',
false);
354 $this->assertSame(
'/', $result);
363 $node = $this->getAccessibleMock(AbstractNode::class, [
'dummy'], [],
'',
false);
365 $this->assertSame(
'/foo/bar', $result);