]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/tests/Sabre/DAV/Tree/FilesystemTest.php
Merge remote branch 'friendica/master'
[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         $this->assertEquals('dir', $node->getName());
41         $this->assertInternalType('array', $node->getChildren());
42
43     }
44
45     function testCopy() {
46
47         $fs = new Sabre_DAV_Tree_Filesystem(SABRE_TEMPDIR);
48         $fs->copy('file.txt','file2.txt');
49         $this->assertTrue(file_exists(SABRE_TEMPDIR . '/file2.txt'));
50         $this->assertEquals('Body',file_get_contents(SABRE_TEMPDIR . '/file2.txt'));
51
52     }
53
54     function testCopyDir() {
55
56         $fs = new Sabre_DAV_Tree_Filesystem(SABRE_TEMPDIR);
57         $fs->copy('dir','dir2');
58         $this->assertTrue(file_exists(SABRE_TEMPDIR . '/dir2'));
59         $this->assertEquals('Body',file_get_contents(SABRE_TEMPDIR . '/dir2/subfile.txt'));
60
61     }
62
63     function testMove() {
64
65         $fs = new Sabre_DAV_Tree_Filesystem(SABRE_TEMPDIR);
66         $fs->move('file.txt','file2.txt');
67         $this->assertTrue(file_exists(SABRE_TEMPDIR . '/file2.txt'));
68         $this->assertTrue(!file_exists(SABRE_TEMPDIR . '/file.txt'));
69         $this->assertEquals('Body',file_get_contents(SABRE_TEMPDIR . '/file2.txt'));
70
71     }
72
73
74 }