summaryrefslogtreecommitdiffstats
path: root/tests/lib/connector/sabre/quotaplugin.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/connector/sabre/quotaplugin.php')
-rw-r--r--tests/lib/connector/sabre/quotaplugin.php23
1 files changed, 11 insertions, 12 deletions
diff --git a/tests/lib/connector/sabre/quotaplugin.php b/tests/lib/connector/sabre/quotaplugin.php
index 1186de28742..6781b970a4f 100644
--- a/tests/lib/connector/sabre/quotaplugin.php
+++ b/tests/lib/connector/sabre/quotaplugin.php
@@ -1,11 +1,11 @@
<?php
+
/**
* Copyright (c) 2013 Thomas Müller <thomas.mueller@tmit.eu>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
-
class Test_OC_Connector_Sabre_QuotaPlugin extends PHPUnit_Framework_TestCase {
/**
@@ -18,17 +18,18 @@ class Test_OC_Connector_Sabre_QuotaPlugin extends PHPUnit_Framework_TestCase {
*/
private $plugin;
- public function setUp() {
+ private function init($quota) {
+ $view = $this->buildFileViewMock($quota);
$this->server = new Sabre_DAV_Server();
- $this->plugin = new OC_Connector_Sabre_QuotaPlugin();
+ $this->plugin = new OC_Connector_Sabre_QuotaPlugin($view);
$this->plugin->initialize($this->server);
}
/**
* @dataProvider lengthProvider
*/
- public function testLength($expected, $headers)
- {
+ public function testLength($expected, $headers) {
+ $this->init(0);
$this->server->httpRequest = new Sabre_HTTP_Request($headers);
$length = $this->plugin->getLength();
$this->assertEquals($expected, $length);
@@ -37,9 +38,8 @@ class Test_OC_Connector_Sabre_QuotaPlugin extends PHPUnit_Framework_TestCase {
/**
* @dataProvider quotaOkayProvider
*/
- public function testCheckQuota($quota, $headers)
- {
- $this->plugin->fileView = $this->buildFileViewMock($quota);
+ public function testCheckQuota($quota, $headers) {
+ $this->init($quota);
$this->server->httpRequest = new Sabre_HTTP_Request($headers);
$result = $this->plugin->checkQuota('');
@@ -50,9 +50,8 @@ class Test_OC_Connector_Sabre_QuotaPlugin extends PHPUnit_Framework_TestCase {
* @expectedException Sabre_DAV_Exception_InsufficientStorage
* @dataProvider quotaExceededProvider
*/
- public function testCheckExceededQuota($quota, $headers)
- {
- $this->plugin->fileView = $this->buildFileViewMock($quota);
+ public function testCheckExceededQuota($quota, $headers) {
+ $this->init($quota);
$this->server->httpRequest = new Sabre_HTTP_Request($headers);
$this->plugin->checkQuota('');
@@ -92,7 +91,7 @@ class Test_OC_Connector_Sabre_QuotaPlugin extends PHPUnit_Framework_TestCase {
private function buildFileViewMock($quota) {
// mock filesysten
- $view = $this->getMock('\OC\Files\View', array('free_space'), array(), '', FALSE);
+ $view = $this->getMock('\OC\Files\View', array('free_space'), array(), '', false);
$view->expects($this->any())->method('free_space')->withAnyParameters()->will($this->returnValue($quota));
return $view;