ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ObjectTreeTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\DAV;
4
5require_once 'Sabre/TestUtil.php';
6
8
9 protected $tree;
10
11 function setup() {
12
14 mkdir(SABRE_TEMPDIR . '/root');
15 mkdir(SABRE_TEMPDIR . '/root/subdir');
16 file_put_contents(SABRE_TEMPDIR . '/root/file.txt', 'contents');
17 file_put_contents(SABRE_TEMPDIR . '/root/subdir/subfile.txt', 'subcontents');
18 $rootNode = new FSExt\Directory(SABRE_TEMPDIR . '/root');
19 $this->tree = new Tree($rootNode);
20
21 }
22
23 function teardown() {
24
26
27 }
28
29 function testGetRootNode() {
30
31 $root = $this->tree->getNodeForPath('');
32 $this->assertInstanceOf('Sabre\\DAV\\FSExt\\Directory', $root);
33
34 }
35
36 function testGetSubDir() {
37
38 $root = $this->tree->getNodeForPath('subdir');
39 $this->assertInstanceOf('Sabre\\DAV\\FSExt\\Directory', $root);
40
41 }
42
43 function testCopyFile() {
44
45 $this->tree->copy('file.txt', 'file2.txt');
46 $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/file2.txt'));
47 $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR . '/root/file2.txt'));
48
49 }
50
54 function testCopyDirectory() {
55
56 $this->tree->copy('subdir', 'subdir2');
57 $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/subdir2'));
58 $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/subdir2/subfile.txt'));
59 $this->assertEquals('subcontents', file_get_contents(SABRE_TEMPDIR . '/root/subdir2/subfile.txt'));
60
61 }
62
66 function testMoveFile() {
67
68 $this->tree->move('file.txt', 'file2.txt');
69 $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/file2.txt'));
70 $this->assertFalse(file_exists(SABRE_TEMPDIR . '/root/file.txt'));
71 $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR . '/root/file2.txt'));
72
73 }
74
79
80 $this->tree->move('file.txt', 'subdir/file2.txt');
81 $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/subdir/file2.txt'));
82 $this->assertFalse(file_exists(SABRE_TEMPDIR . '/root/file.txt'));
83 $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR . '/root/subdir/file2.txt'));
84
85 }
86
90 function testMoveDirectory() {
91
92 $this->tree->move('subdir', 'subdir2');
93 $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/subdir2'));
94 $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/subdir2/subfile.txt'));
95 $this->assertFalse(file_exists(SABRE_TEMPDIR . '/root/subdir'));
96 $this->assertEquals('subcontents', file_get_contents(SABRE_TEMPDIR . '/root/subdir2/subfile.txt'));
97
98 }
99
100}
An exception for terminatinating execution or to throw for unit testing.
Directory class.
Definition: Directory.php:15
testMoveFile()
@depends testCopyFile
testMoveDirectory()
@depends testCopyDirectory
testMoveFileNewParent()
@depends testMoveFile
testCopyDirectory()
@depends testCopyFile
The tree object is responsible for basic tree operations.
Definition: Tree.php:17
static clearTempDir()
This function deletes all the contents of the temporary directory.
Definition: TestUtil.php:12
$root
Definition: sabredav.php:45