From 414b2eb4b672ef5d49985de27edca3e5bb54d5d6 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Fri, 4 Oct 2013 16:09:07 +0200 Subject: upload abortion detection only for PUT e.g. LOCK would break with this approach --- .../sabre/aborteduploaddetectionplugin.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'tests/lib/connector') diff --git a/tests/lib/connector/sabre/aborteduploaddetectionplugin.php b/tests/lib/connector/sabre/aborteduploaddetectionplugin.php index bef0e4c4d7d..201f1263867 100644 --- a/tests/lib/connector/sabre/aborteduploaddetectionplugin.php +++ b/tests/lib/connector/sabre/aborteduploaddetectionplugin.php @@ -37,10 +37,11 @@ class Test_OC_Connector_Sabre_AbortedUploadDetectionPlugin extends PHPUnit_Frame /** * @dataProvider verifyContentLengthProvider */ - public function testVerifyContentLength($fileSize, $headers) + public function testVerifyContentLength($method, $fileSize, $headers) { $this->plugin->fileView = $this->buildFileViewMock($fileSize); + $headers['REQUEST_METHOD'] = $method; $this->server->httpRequest = new Sabre_HTTP_Request($headers); $this->plugin->verifyContentLength('foo.txt'); $this->assertTrue(true); @@ -50,30 +51,33 @@ class Test_OC_Connector_Sabre_AbortedUploadDetectionPlugin extends PHPUnit_Frame * @dataProvider verifyContentLengthFailedProvider * @expectedException Sabre_DAV_Exception_BadRequest */ - public function testVerifyContentLengthFailed($fileSize, $headers) + public function testVerifyContentLengthFailed($method, $fileSize, $headers) { $this->plugin->fileView = $this->buildFileViewMock($fileSize); // we expect unlink to be called $this->plugin->fileView->expects($this->once())->method('unlink'); - + $headers['REQUEST_METHOD'] = $method; $this->server->httpRequest = new Sabre_HTTP_Request($headers); $this->plugin->verifyContentLength('foo.txt'); } public function verifyContentLengthProvider() { return array( - array(1024, array()), - array(1024, array('HTTP_X_EXPECTED_ENTITY_LENGTH' => '1024')), - array(512, array('HTTP_CONTENT_LENGTH' => '512')), + array('PUT', 1024, array()), + array('PUT', 1024, array('HTTP_X_EXPECTED_ENTITY_LENGTH' => '1024')), + array('PUT', 512, array('HTTP_CONTENT_LENGTH' => '512')), + array('LOCK', 1024, array()), + array('LOCK', 1024, array('HTTP_X_EXPECTED_ENTITY_LENGTH' => '1024')), + array('LOCK', 512, array('HTTP_CONTENT_LENGTH' => '512')), ); } public function verifyContentLengthFailedProvider() { return array( - array(1025, array('HTTP_X_EXPECTED_ENTITY_LENGTH' => '1024')), - array(525, array('HTTP_CONTENT_LENGTH' => '512')), + array('PUT', 1025, array('HTTP_X_EXPECTED_ENTITY_LENGTH' => '1024')), + array('PUT', 525, array('HTTP_CONTENT_LENGTH' => '512')), ); } @@ -87,7 +91,7 @@ class Test_OC_Connector_Sabre_AbortedUploadDetectionPlugin extends PHPUnit_Frame } private function buildFileViewMock($fileSize) { - // mock filesysten + // mock filesystem $view = $this->getMock('\OC\Files\View', array('filesize', 'unlink'), array(), '', FALSE); $view->expects($this->any())->method('filesize')->withAnyParameters()->will($this->returnValue($fileSize)); -- cgit v1.2.3