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);
40 $this->assertEquals('dir', $node->getName());
41 $this->assertInternalType('array', $node->getChildren());
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'));
54 function testCopyDir() {
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'));
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'));