Blame view

sources/3rdparty/sabre/dav/tests/Sabre/DAV/Tree/FilesystemTest.php 2.19 KB
6d9380f96   Cédric Dupont   Update sources OC...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
  <?php
  
  namespace Sabre\DAV\Tree;
  
  use Sabre\DAV;
  
  /**
   * @covers Sabre\DAV\Tree
   * @covers Sabre\DAV\Tree\Filesystem
   * @covers Sabre\DAV\FS\Node
   * @covers Sabre\DAV\FS\File
   * @covers Sabre\DAV\FS\Directory
   */
  class FilesystemTest extends \PHPUnit_Framework_TestCase {
  
      function setUp() {
  
          \Sabre\TestUtil::clearTempDir();
          file_put_contents(SABRE_TEMPDIR. '/file.txt','Body');
          mkdir(SABRE_TEMPDIR.'/dir');
          file_put_contents(SABRE_TEMPDIR.'/dir/subfile.txt','Body');
  
      }
  
      function tearDown() {
  
          \Sabre\TestUtil::clearTempDir();
  
      }
  
      function testGetNodeForPath_File() {
  
          $fs = new Filesystem(SABRE_TEMPDIR);
          $node = $fs->getNodeForPath('file.txt');
          $this->assertTrue($node instanceof DAV\FS\File);
  
      }
  
      /**
       * @expectedException \Sabre\DAV\Exception\NotFound
       */
      function testGetNodeForPath_DoesntExist() {
  
          $fs = new Filesystem(SABRE_TEMPDIR);
          $node = $fs->getNodeForPath('whoop/file.txt');
  
      }
  
      function testGetNodeForPath_Directory() {
  
          $fs = new Filesystem(SABRE_TEMPDIR);
          $node = $fs->getNodeForPath('dir');
          $this->assertTrue($node instanceof DAV\FS\Directory);
          $this->assertEquals('dir', $node->getName());
          $this->assertInternalType('array', $node->getChildren());
  
      }
  
      function testCopy() {
  
          $fs = new Filesystem(SABRE_TEMPDIR);
          $fs->copy('file.txt','file2.txt');
          $this->assertTrue(file_exists(SABRE_TEMPDIR . '/file2.txt'));
          $this->assertEquals('Body',file_get_contents(SABRE_TEMPDIR . '/file2.txt'));
  
      }
  
      function testCopyDir() {
  
          $fs = new Filesystem(SABRE_TEMPDIR);
          $fs->copy('dir','dir2');
          $this->assertTrue(file_exists(SABRE_TEMPDIR . '/dir2'));
          $this->assertEquals('Body',file_get_contents(SABRE_TEMPDIR . '/dir2/subfile.txt'));
  
      }
  
      function testMove() {
  
          $fs = new Filesystem(SABRE_TEMPDIR);
          $fs->move('file.txt','file2.txt');
          $this->assertTrue(file_exists(SABRE_TEMPDIR . '/file2.txt'));
          $this->assertTrue(!file_exists(SABRE_TEMPDIR . '/file.txt'));
          $this->assertEquals('Body',file_get_contents(SABRE_TEMPDIR . '/file2.txt'));
  
      }
  
  
  }