summaryrefslogtreecommitdiffstats
path: root/tests/lib/connector/sabre/file.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/connector/sabre/file.php')
-rw-r--r--tests/lib/connector/sabre/file.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/lib/connector/sabre/file.php b/tests/lib/connector/sabre/file.php
index e1fed0384c6..50b8711a90d 100644
--- a/tests/lib/connector/sabre/file.php
+++ b/tests/lib/connector/sabre/file.php
@@ -36,6 +36,46 @@ class Test_OC_Connector_Sabre_File extends PHPUnit_Framework_TestCase {
}
/**
+ * @expectedException Sabre_DAV_Exception_BadRequest
+ */
+ public function testSimplePutInvalidChars() {
+ // setup
+ $file = new OC_Connector_Sabre_File('/super*star.txt');
+ $file->fileView = $this->getMock('\OC\Files\View', array('file_put_contents'), array(), '', FALSE);
+ $file->fileView->expects($this->any())->method('file_put_contents')->withAnyParameters()->will($this->returnValue(false));
+
+ // action
+ $etag = $file->put('test data');
+ }
+
+ /**
+ * Test setting name with setName()
+ */
+ public function testSetName() {
+ // setup
+ $file = new OC_Connector_Sabre_File('/test.txt');
+ $file->fileView = $this->getMock('\OC\Files\View', array('isUpdatable'), array(), '', FALSE);
+ $file->fileView->expects($this->any())->method('isUpdatable')->withAnyParameters()->will($this->returnValue(true));
+ $etag = $file->put('test data');
+ $file->setName('/renamed.txt');
+ $this->assertTrue($file->fileView->file_exists('/renamed.txt'));
+ // clean up
+ $file->delete();
+ }
+
+ /**
+ * Test setting name with setName() with invalid chars
+ * @expectedException Sabre_DAV_Exception_BadRequest
+ */
+ public function testSetNameInvalidChars() {
+ // setup
+ $file = new OC_Connector_Sabre_File('/test.txt');
+ $file->fileView = $this->getMock('\OC\Files\View', array('isUpdatable'), array(), '', FALSE);
+ $file->fileView->expects($this->any())->method('isUpdatable')->withAnyParameters()->will($this->returnValue(true));
+ $file->setName('/super*star.txt');
+ }
+
+ /**
* @expectedException Sabre_DAV_Exception_Forbidden
*/
public function testDeleteSharedFails() {