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
10 class Sabre_DAV_Tree_FilesystemTest extends PHPUnit_Framework_TestCase {
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');
23 Sabre_TestUtil::clearTempDir();
27 function testGetNodeForPath_File() {
29 $fs = new Sabre_DAV_Tree_Filesystem(SABRE_TEMPDIR);
30 $node = $fs->getNodeForPath('file.txt');
31 $this->assertTrue($node instanceof Sabre_DAV_FS_File);
35 function testGetNodeForPath_Directory() {
37 $fs = new Sabre_DAV_Tree_Filesystem(SABRE_TEMPDIR);
38 $node = $fs->getNodeForPath('dir');
39 $this->assertTrue($node instanceof Sabre_DAV_FS_Directory);
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'));
52 function testCopyDir() {
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'));
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'));