2 declare(strict_types = 1);
24 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
25 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
37 $this->expectException(InvalidArgumentException::class);
38 $this->expectExceptionCode(1380485700);
40 $node = $this->getAccessibleMock(LinkNode::class, [
'dummy'], [],
'',
false);
41 $node->__construct([],
null);
49 $this->expectException(InvalidArgumentException::class);
50 $this->expectExceptionCode(1380546061);
51 $parent = $this->createMock(NodeInterface::class);
53 $node = $this->getAccessibleMock(LinkNode::class, [
'dummy'], [],
'',
false);
57 $node->__construct($structure, $parent);
65 $parent = $this->createMock(NodeInterface::class);
67 $node = $this->getAccessibleMock(LinkNode::class, [
'dummy'], [],
'',
false);
71 $node->__construct($structure, $parent);
72 $this->assertSame($parent, $node->_call(
'getParent'));
81 $node = $this->getAccessibleMock(LinkNode::class, [
'dummy'], [],
'',
false);
82 $parent = $this->createMock(RootNodeInterface::class);
83 $name = $this->getUniqueId(
'test_');
84 $node->__construct([
'name' => $name], $parent);
85 $this->assertSame($name, $node->getName());
94 $node = $this->getAccessibleMock(LinkNode::class, [
'dummy'], [],
'',
false);
95 $parent = $this->createMock(RootNodeInterface::class);
96 $name = $this->getUniqueId(
'test_');
97 $target =
'../' . $this->getUniqueId(
'test_');
98 $node->__construct([
'name' => $name,
'target' => $target], $parent);
99 $this->assertSame($target, $node->_call(
'getTarget'));
108 $node = $this->getAccessibleMock(
110 [
'isWindowsOs',
'getAbsolutePath',
'exists'],
116 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
117 $this->assertInternalType(
'array', $node->getStatus());
126 $node = $this->getAccessibleMock(
128 [
'isWindowsOs',
'getAbsolutePath',
'exists'],
134 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
135 $node->expects($this->once())->method(
'isWindowsOs')->will($this->returnValue(
true));
136 $statusArray = $node->getStatus();
146 $node = $this->getAccessibleMock(
148 [
'isWindowsOs',
'getAbsolutePath',
'exists'],
154 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
155 $node->expects($this->any())->method(
'isWindowsOs')->will($this->returnValue(
false));
156 $node->expects($this->once())->method(
'exists')->will($this->returnValue(
false));
157 $statusArray = $node->getStatus();
167 $node = $this->getAccessibleMock(
169 [
'isWindowsOs',
'getAbsolutePath',
'exists',
'isLink',
'getRelativePathBelowSiteRoot'],
174 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue(
''));
175 $node->expects($this->any())->method(
'exists')->will($this->returnValue(
true));
176 $node->expects($this->once())->method(
'isLink')->will($this->returnValue(
false));
177 $statusArray = $node->getStatus();
187 $node = $this->getAccessibleMock(
189 [
'isWindowsOs',
'getAbsolutePath',
'exists',
'isLink',
'isTargetCorrect',
'getCurrentTarget',
'getRelativePathBelowSiteRoot'],
194 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue(
''));
195 $node->expects($this->any())->method(
'getCurrentTarget')->will($this->returnValue(
''));
196 $node->expects($this->any())->method(
'exists')->will($this->returnValue(
true));
197 $node->expects($this->any())->method(
'isLink')->will($this->returnValue(
true));
198 $node->expects($this->once())->method(
'isLink')->will($this->returnValue(
false));
199 $statusArray = $node->getStatus();
209 $node = $this->getAccessibleMock(
211 [
'isWindowsOs',
'getAbsolutePath',
'exists',
'isLink',
'isTargetCorrect',
'getRelativePathBelowSiteRoot'],
216 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue(
''));
217 $node->expects($this->any())->method(
'exists')->will($this->returnValue(
true));
218 $node->expects($this->once())->method(
'isLink')->will($this->returnValue(
true));
219 $node->expects($this->once())->method(
'isTargetCorrect')->will($this->returnValue(
true));
220 $node->expects($this->once())->method(
'getRelativePathBelowSiteRoot')->will($this->returnValue(
''));
221 $statusArray = $node->getStatus();
231 $node = $this->getAccessibleMock(
233 [
'getRelativePathBelowSiteRoot'],
238 $statusArray = $node->fix();
239 $this->assertEmpty($statusArray);
247 $this->expectException(InvalidArgumentException::class);
248 $this->expectExceptionCode(1380556246);
250 $node = $this->getAccessibleMock(LinkNode::class, [
'exists'], [],
'',
false);
251 $node->expects($this->once())->method(
'exists')->will($this->returnValue(
false));
252 $this->assertFalse($node->_call(
'isLink'));
261 $node = $this->getAccessibleMock(LinkNode::class, [
'exists',
'getAbsolutePath'], [],
'',
false);
265 symlink($target, $path);
266 $this->testFilesToDelete[] = $path;
267 $this->testFilesToDelete[] = $target;
268 $node->expects($this->any())->method(
'exists')->will($this->returnValue(
true));
269 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
270 $this->assertTrue($node->_call(
'isLink'));
279 $node = $this->getAccessibleMock(LinkNode::class, [
'exists',
'getAbsolutePath'], [],
'',
false);
282 $this->testFilesToDelete[] = $path;
283 $node->expects($this->any())->method(
'exists')->will($this->returnValue(
true));
284 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
285 $this->assertFalse($node->_call(
'isLink'));
293 $this->expectException(InvalidArgumentException::class);
294 $this->expectExceptionCode(1380556245);
296 $node = $this->getAccessibleMock(LinkNode::class, [
'exists'], [],
'',
false);
297 $node->expects($this->once())->method(
'exists')->will($this->returnValue(
false));
298 $this->assertFalse($node->_call(
'isTargetCorrect'));
306 $this->expectException(InvalidArgumentException::class);
307 $this->expectExceptionCode(1380556247);
309 $node = $this->getAccessibleMock(LinkNode::class, [
'exists',
'isLink',
'getTarget'], [],
'',
false);
310 $node->expects($this->any())->method(
'exists')->will($this->returnValue(
true));
311 $node->expects($this->once())->method(
'isLink')->will($this->returnValue(
false));
312 $this->assertTrue($node->_call(
'isTargetCorrect'));
321 $node = $this->getAccessibleMock(LinkNode::class, [
'exists',
'isLink',
'getTarget'], [],
'',
false);
322 $node->expects($this->any())->method(
'exists')->will($this->returnValue(
true));
323 $node->expects($this->any())->method(
'isLink')->will($this->returnValue(
true));
324 $node->expects($this->once())->method(
'getTarget')->will($this->returnValue(
''));
325 $this->assertTrue($node->_call(
'isTargetCorrect'));
334 $node = $this->getAccessibleMock(LinkNode::class, [
'exists',
'isLink',
'getCurrentTarget',
'getTarget'], [],
'',
false);
335 $node->expects($this->any())->method(
'exists')->will($this->returnValue(
true));
336 $node->expects($this->any())->method(
'isLink')->will($this->returnValue(
true));
337 $node->expects($this->once())->method(
'getCurrentTarget')->will($this->returnValue(
'someLinkTarget/'));
338 $node->expects($this->once())->method(
'getTarget')->will($this->returnValue(
'someLinkTarget'));
339 $this->assertTrue($node->_call(
'isTargetCorrect'));
351 symlink($target, $path);
352 $this->testFilesToDelete[] = $path;
353 $this->testFilesToDelete[] = $target;
355 $node = $this->getAccessibleMock(
357 [
'exists',
'isLink',
'getTarget',
'getAbsolutePath'],
362 $node->expects($this->any())->method(
'exists')->will($this->returnValue(
true));
363 $node->expects($this->any())->method(
'isLink')->will($this->returnValue(
true));
364 $node->expects($this->once())->method(
'getTarget')->will($this->returnValue(str_replace(
'/', DIRECTORY_SEPARATOR, $target)));
365 $node->expects($this->once())->method(
'getAbsolutePath')->will($this->returnValue($path));
366 $this->assertTrue($node->_call(
'isTargetCorrect'));
378 symlink($target, $path);
379 $this->testFilesToDelete[] = $path;
380 $this->testFilesToDelete[] = $target;
382 $node = $this->getAccessibleMock(
384 [
'exists',
'isLink',
'getTarget',
'getAbsolutePath'],
389 $node->expects($this->any())->method(
'exists')->will($this->returnValue(
true));
390 $node->expects($this->any())->method(
'isLink')->will($this->returnValue(
true));
391 $node->expects($this->once())->method(
'getTarget')->will($this->returnValue(
'foo'));
392 $node->expects($this->once())->method(
'getAbsolutePath')->will($this->returnValue($path));
393 $this->assertFalse($node->_call(
'isTargetCorrect'));