3 class Sabre_DAV_BasicNodeTest extends PHPUnit_Framework_TestCase {
6 * @expectedException Sabre_DAV_Exception_Forbidden
8 public function testPut() {
10 $file = new Sabre_DAV_FileMock();
16 * @expectedException Sabre_DAV_Exception_Forbidden
18 public function testGet() {
20 $file = new Sabre_DAV_FileMock();
25 public function testGetSize() {
27 $file = new Sabre_DAV_FileMock();
28 $this->assertEquals(0,$file->getSize());
33 public function testGetETag() {
35 $file = new Sabre_DAV_FileMock();
36 $this->assertNull($file->getETag());
40 public function testGetContentType() {
42 $file = new Sabre_DAV_FileMock();
43 $this->assertNull($file->getContentType());
48 * @expectedException Sabre_DAV_Exception_Forbidden
50 public function testDelete() {
52 $file = new Sabre_DAV_FileMock();
58 * @expectedException Sabre_DAV_Exception_Forbidden
60 public function testSetName() {
62 $file = new Sabre_DAV_FileMock();
67 public function testGetLastModified() {
69 $file = new Sabre_DAV_FileMock();
70 // checking if lastmod is within the range of a few seconds
71 $lastMod = $file->getLastModified();
72 $compareTime = ($lastMod + 1)-time();
73 $this->assertTrue($compareTime < 3);
77 public function testGetChild() {
79 $dir = new Sabre_DAV_DirectoryMock();
80 $file = $dir->getChild('mockfile');
81 $this->assertTrue($file instanceof Sabre_DAV_FileMock);
85 public function testChildExists() {
87 $dir = new Sabre_DAV_DirectoryMock();
88 $this->assertTrue($dir->childExists('mockfile'));
92 public function testChildExistsFalse() {
94 $dir = new Sabre_DAV_DirectoryMock();
95 $this->assertFalse($dir->childExists('mockfile2'));
100 * @expectedException Sabre_DAV_Exception_NotFound
102 public function testGetChild404() {
104 $dir = new Sabre_DAV_DirectoryMock();
105 $file = $dir->getChild('blabla');
110 * @expectedException Sabre_DAV_Exception_Forbidden
112 public function testCreateFile() {
114 $dir = new Sabre_DAV_DirectoryMock();
115 $dir->createFile('hello','data');
120 * @expectedException Sabre_DAV_Exception_Forbidden
122 public function testCreateDirectory() {
124 $dir = new Sabre_DAV_DirectoryMock();
125 $dir->createDirectory('hello');
129 public function testSimpleDirectoryConstruct() {
131 $dir = new Sabre_DAV_SimpleCollection('simpledir',array());
136 * @depends testSimpleDirectoryConstruct
138 public function testSimpleDirectoryConstructChild() {
140 $file = new Sabre_DAV_FileMock();
141 $dir = new Sabre_DAV_SimpleCollection('simpledir',array($file));
142 $file2 = $dir->getChild('mockfile');
144 $this->assertEquals($file,$file2);
149 * @expectedException Sabre_DAV_Exception
150 * @depends testSimpleDirectoryConstruct
152 public function testSimpleDirectoryBadParam() {
154 $dir = new Sabre_DAV_SimpleCollection('simpledir',array('string shouldn\'t be here'));
159 * @depends testSimpleDirectoryConstruct
161 public function testSimpleDirectoryAddChild() {
163 $file = new Sabre_DAV_FileMock();
164 $dir = new Sabre_DAV_SimpleCollection('simpledir');
165 $dir->addChild($file);
166 $file2 = $dir->getChild('mockfile');
168 $this->assertEquals($file,$file2);
173 * @depends testSimpleDirectoryConstruct
174 * @depends testSimpleDirectoryAddChild
176 public function testSimpleDirectoryGetChildren() {
178 $file = new Sabre_DAV_FileMock();
179 $dir = new Sabre_DAV_SimpleCollection('simpledir');
180 $dir->addChild($file);
182 $this->assertEquals(array($file),$dir->getChildren());
187 * @depends testSimpleDirectoryConstruct
189 public function testSimpleDirectoryGetName() {
191 $dir = new Sabre_DAV_SimpleCollection('simpledir');
192 $this->assertEquals('simpledir',$dir->getName());
197 * @depends testSimpleDirectoryConstruct
198 * @expectedException Sabre_DAV_Exception_NotFound
200 public function testSimpleDirectoryGetChild404() {
202 $dir = new Sabre_DAV_SimpleCollection('simpledir');
203 $dir->getChild('blabla');
208 class Sabre_DAV_DirectoryMock extends Sabre_DAV_Collection {
216 function getChildren() {
218 return array(new Sabre_DAV_FileMock());
224 class Sabre_DAV_FileMock extends Sabre_DAV_File {