]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/tests/Sabre/DAV/Tree/FilesystemTest.php
Initial Release of the calendar plugin
[friendica-addons.git] / dav / SabreDAV / tests / Sabre / DAV / Tree / FilesystemTest.php
1 <?php
2
3 /**
4  * @covers Sabre_DAV_Tree
5  * @covers Sabre_DAV_Tree_Filesystem
6  * @covers Sabre_DAV_FS_Node
7  * @covers Sabre_DAV_FS_File
8  * @covers Sabre_DAV_FS_Directory
9  */
10 class Sabre_DAV_Tree_FilesystemTest extends PHPUnit_Framework_TestCase {
11
12     function setUp() {
13
14         Sabre_TestUtil::clearTempDir();
15         file_put_contents(SABRE_TEMPDIR. '/file.txt','Body');
16         mkdir(SABRE_TEMPDIR.'/dir');
17         file_put_contents(SABRE_TEMPDIR.'/dir/subfile.txt','Body');
18
19     }
20
21     function tearDown() {
22
23         Sabre_TestUtil::clearTempDir();
24
25     }
26
27     function testGetNodeForPath_File() {
28
29         $fs = new Sabre_DAV_Tree_Filesystem(SABRE_TEMPDIR);
30         $node = $fs->getNodeForPath('file.txt');
31         $this->assertTrue($node instanceof Sabre_DAV_FS_File);
32
33     }
34
35     function testGetNodeForPath_Directory() {
36
37         $fs = new Sabre_DAV_Tree_Filesystem(SABRE_TEMPDIR);
38         $node = $fs->getNodeForPath('dir');
39         $this->assertTrue($node instanceof Sabre_DAV_FS_Directory);
40
41     }
42
43     function testCopy() {
44
45         $fs = new Sabre_DAV_Tree_Filesystem(SABRE_TEMPDIR);
46         $fs->copy('file.txt','file2.txt');
47         $this->assertTrue(file_exists(SABRE_TEMPDIR . '/file2.txt'));
48         $this->assertEquals('Body',file_get_contents(SABRE_TEMPDIR . '/file2.txt'));
49
50     }
51
52     function testCopyDir() {
53
54         $fs = new Sabre_DAV_Tree_Filesystem(SABRE_TEMPDIR);
55         $fs->copy('dir','dir2');
56         $this->assertTrue(file_exists(SABRE_TEMPDIR . '/dir2'));
57         $this->assertEquals('Body',file_get_contents(SABRE_TEMPDIR . '/dir2/subfile.txt'));
58
59     }
60
61     function testMove() {
62
63         $fs = new Sabre_DAV_Tree_Filesystem(SABRE_TEMPDIR);
64         $fs->move('file.txt','file2.txt');
65         $this->assertTrue(file_exists(SABRE_TEMPDIR . '/file2.txt'));
66         $this->assertTrue(!file_exists(SABRE_TEMPDIR . '/file.txt'));
67         $this->assertEquals('Body',file_get_contents(SABRE_TEMPDIR . '/file2.txt'));
68
69     }
70
71
72 }