Commit bb540722 authored by Joas Schilling's avatar Joas Schilling
Browse files

Use base class to reset the file mapper

parent 284ba5b6
......@@ -11,7 +11,7 @@ use OCA\Files;
/**
* Class Test_Files_Helper
*/
class Test_Files_Helper extends \PHPUnit_Framework_TestCase {
class Test_Files_Helper extends \Test\TestCase {
private function makeFileInfo($name, $size, $mtime, $isDir = false) {
return new \OC\Files\FileInfo(
......@@ -90,7 +90,7 @@ class Test_Files_Helper extends \PHPUnit_Framework_TestCase {
$this->assertEquals(
$expectedOrder,
$fileNames
);
);
}
}
......@@ -39,6 +39,7 @@ class Test_Files_Versioning extends \PHPUnit_Framework_TestCase {
private $rootView;
public static function setUpBeforeClass() {
parent::setUpBeforeClass();
// clear share hooks
\OC_Hook::clear('OCP\\Share');
......@@ -55,9 +56,13 @@ class Test_Files_Versioning extends \PHPUnit_Framework_TestCase {
// cleanup test user
\OC_User::deleteUser(self::TEST_VERSIONS_USER);
\OC_User::deleteUser(self::TEST_VERSIONS_USER2);
parent::tearDownAfterClass();
}
function setUp() {
protected function setUp() {
parent::setUp();
self::loginHelper(self::TEST_VERSIONS_USER);
$this->rootView = new \OC\Files\View();
if (!$this->rootView->file_exists(self::USERS_VERSIONS_ROOT)) {
......@@ -65,8 +70,10 @@ class Test_Files_Versioning extends \PHPUnit_Framework_TestCase {
}
}
function tearDown() {
protected function tearDown() {
$this->rootView->deleteAll(self::USERS_VERSIONS_ROOT);
parent::tearDown();
}
/**
......@@ -74,7 +81,7 @@ class Test_Files_Versioning extends \PHPUnit_Framework_TestCase {
* test expire logic
* @dataProvider versionsProvider
*/
function testGetExpireList($versions, $sizeOfAllDeletedFiles) {
public function testGetExpireList($versions, $sizeOfAllDeletedFiles) {
// last interval end at 2592000
$startTime = 5000000;
......@@ -216,7 +223,7 @@ class Test_Files_Versioning extends \PHPUnit_Framework_TestCase {
);
}
function testRename() {
public function testRename() {
\OC\Files\Filesystem::file_put_contents("test.txt", "test file");
......@@ -247,7 +254,7 @@ class Test_Files_Versioning extends \PHPUnit_Framework_TestCase {
\OC\Files\Filesystem::unlink('test2.txt');
}
function testRenameInSharedFolder() {
public function testRenameInSharedFolder() {
\OC\Files\Filesystem::mkdir('folder1');
\OC\Files\Filesystem::mkdir('folder1/folder2');
......@@ -291,7 +298,7 @@ class Test_Files_Versioning extends \PHPUnit_Framework_TestCase {
\OC\Files\Filesystem::unlink('/folder1/folder2/test.txt');
}
function testRenameSharedFile() {
public function testRenameSharedFile() {
\OC\Files\Filesystem::file_put_contents("test.txt", "test file");
......@@ -334,7 +341,7 @@ class Test_Files_Versioning extends \PHPUnit_Framework_TestCase {
\OC\Files\Filesystem::unlink('/test.txt');
}
function testCopy() {
public function testCopy() {
\OC\Files\Filesystem::file_put_contents("test.txt", "test file");
......
......@@ -24,9 +24,6 @@ class MappedLocal extends \OC\Files\Storage\Common {
}
public function __destruct() {
if (defined('PHPUNIT_RUN')) {
$this->mapper->removePath($this->datadir, true, true);
}
}
public function getId() {
......
......@@ -16,7 +16,7 @@ class LongId extends \OC\Files\Storage\Temporary {
}
}
class Cache extends \PHPUnit_Framework_TestCase {
class Cache extends \Test\TestCase {
/**
* @var \OC\Files\Storage\Temporary $storage ;
*/
......@@ -452,13 +452,17 @@ class Cache extends \PHPUnit_Framework_TestCase {
$this->assertEquals(1, count($this->cache->getFolderContents('folder')));
}
public function tearDown() {
protected function tearDown() {
if ($this->cache) {
$this->cache->clear();
}
parent::tearDown();
}
public function setUp() {
protected function setUp() {
parent::setUp();
$this->storage = new \OC\Files\Storage\Temporary(array());
$this->storage2 = new \OC\Files\Storage\Temporary(array());
$this->cache = new \OC\Files\Cache\Cache($this->storage);
......
......@@ -12,7 +12,7 @@ use OC\Files\Filesystem;
use OC\Files\Storage\Temporary;
use OC\Files\View;
class ChangePropagator extends \PHPUnit_Framework_TestCase {
class ChangePropagator extends \Test\TestCase {
/**
* @var \OC\Files\Cache\ChangePropagator
*/
......@@ -23,9 +23,11 @@ class ChangePropagator extends \PHPUnit_Framework_TestCase {
*/
private $view;
public function setUp() {
protected function setUp() {
parent::setUp();
$storage = new Temporary(array());
$root = '/' . uniqid();
$root = $this->getUniqueID('/');
Filesystem::mount($storage, array(), $root);
$this->view = new View($root);
$this->propagator = new \OC\Files\Cache\ChangePropagator($this->view);
......
......@@ -43,7 +43,7 @@ class DummyUser extends \OC\User\User {
}
}
class HomeCache extends \PHPUnit_Framework_TestCase {
class HomeCache extends \Test\TestCase {
/**
* @var \OC\Files\Storage\Home $storage
*/
......@@ -59,7 +59,9 @@ class HomeCache extends \PHPUnit_Framework_TestCase {
*/
private $user;
public function setUp() {
protected function setUp() {
parent::setUp();
$this->user = new DummyUser('foo', \OC_Helper::tmpFolder());
$this->storage = new \OC\Files\Storage\Home(array('user' => $this->user));
$this->cache = $this->storage->getCache();
......
......@@ -8,7 +8,7 @@
namespace Test\Files\Cache;
class Scanner extends \PHPUnit_Framework_TestCase {
class Scanner extends \Test\TestCase {
/**
* @var \OC\Files\Storage\Storage $storage
*/
......@@ -24,16 +24,20 @@ class Scanner extends \PHPUnit_Framework_TestCase {
*/
private $cache;
function setUp() {
protected function setUp() {
parent::setUp();
$this->storage = new \OC\Files\Storage\Temporary(array());
$this->scanner = new \OC\Files\Cache\Scanner($this->storage);
$this->cache = new \OC\Files\Cache\Cache($this->storage);
}
function tearDown() {
protected function tearDown() {
if ($this->cache) {
$this->cache->clear();
}
parent::tearDown();
}
function testFile() {
......
......@@ -12,7 +12,7 @@ use OC\Files\Filesystem;
use OC\Files\Storage\Temporary;
use OC\Files\View;
class Updater extends \PHPUnit_Framework_TestCase {
class Updater extends \Test\TestCase {
/**
* @var \OC\Files\Storage\Storage
*/
......@@ -40,6 +40,7 @@ class Updater extends \PHPUnit_Framework_TestCase {
parent::setUp();
$this->originalStorage = Filesystem::getStorage('/');
$this->storage = new Temporary(array());
Filesystem::clearMounts();
Filesystem::mount($this->storage, array(), '/');
......
......@@ -11,7 +11,7 @@ namespace Test\Files\Cache;
use \OC\Files\Filesystem as Filesystem;
use OC\Files\Storage\Temporary;
class UpdaterLegacy extends \PHPUnit_Framework_TestCase {
class UpdaterLegacy extends \Test\TestCase {
/**
* @var \OC\Files\Storage\Storage $storage
*/
......@@ -34,7 +34,8 @@ class UpdaterLegacy extends \PHPUnit_Framework_TestCase {
private static $user;
public function setUp() {
protected function setUp() {
parent::setUp();
// remember files_encryption state
$this->stateFilesEncryption = \OC_App::isEnabled('files_encryption');
......@@ -71,7 +72,7 @@ class UpdaterLegacy extends \PHPUnit_Framework_TestCase {
\OC_Hook::clear('OC_Filesystem');
}
public function tearDown() {
protected function tearDown() {
if ($this->cache) {
$this->cache->clear();
}
......@@ -83,6 +84,8 @@ class UpdaterLegacy extends \PHPUnit_Framework_TestCase {
if ($this->stateFilesEncryption) {
\OC_App::enable('files_encryption');
}
parent::tearDown();
}
public function testWrite() {
......
......@@ -8,7 +8,7 @@
namespace Test\Files\Cache;
class Watcher extends \PHPUnit_Framework_TestCase {
class Watcher extends \Test\TestCase {
/**
* @var \OC\Files\Storage\Storage[] $storages
......
......@@ -56,7 +56,7 @@ class EtagTest extends \Test\TestCase {
}
public function testNewUser() {
$user1 = uniqid('user_');
$user1 = $this->getUniqueID('user_');
$this->userBackend->createUser($user1, '');
\OC_Util::tearDownFS();
......
......@@ -55,6 +55,8 @@ class Filesystem extends \Test\TestCase {
\OC\Files\Filesystem::clearMounts();
\OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
\OC_User::setUserId('');
parent::tearDown();
}
public function testMount() {
......
......@@ -22,14 +22,15 @@
namespace Test\Files;
class Mapper extends \PHPUnit_Framework_TestCase {
class Mapper extends \Test\TestCase {
/**
* @var \OC\Files\Mapper
*/
private $mapper = null;
public function setUp() {
protected function setUp() {
parent::setUp();
$this->mapper = new \OC\Files\Mapper('D:/');
}
......
......@@ -16,13 +16,14 @@ class LongId extends Temporary {
}
}
class Manager extends \PHPUnit_Framework_TestCase {
class Manager extends \Test\TestCase {
/**
* @var \OC\Files\Mount\Manager
*/
private $manager;
public function setup() {
protected function setup() {
parent::setUp();
$this->manager = new \OC\Files\Mount\Manager();
}
......
......@@ -12,7 +12,7 @@ namespace Test\Files\Mount;
use OC\Files\Storage\Loader;
use OC\Files\Storage\Wrapper\Wrapper;
class Mount extends \PHPUnit_Framework_TestCase {
class Mount extends \Test\TestCase {
public function testFromStorageObject() {
$storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
->disableOriginalConstructor()
......
......@@ -12,10 +12,11 @@ use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OC\Files\View;
class File extends \PHPUnit_Framework_TestCase {
class File extends \Test\TestCase {
private $user;
public function setUp() {
protected function setUp() {
parent::setUp();
$this->user = new \OC\User\User('', new \OC_User_Dummy);
}
......
......@@ -15,10 +15,11 @@ use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OC\Files\View;
class Folder extends \PHPUnit_Framework_TestCase {
class Folder extends \Test\TestCase {
private $user;
public function setUp() {
protected function setUp() {
parent::setUp();
$this->user = new \OC\User\User('', new \OC_User_Dummy);
}
......
......@@ -14,7 +14,7 @@ use OC\Files\Storage\Temporary;
use OC\Files\View;
use OC\User\User;
class IntegrationTests extends \PHPUnit_Framework_TestCase {
class IntegrationTests extends \Test\TestCase {
/**
* @var \OC\Files\Node\Root $root
*/
......@@ -65,7 +65,6 @@ class IntegrationTests extends \PHPUnit_Framework_TestCase {
$storage->getCache()->clear();
}
\OC\Files\Filesystem::clearMounts();
\OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
parent::tearDown();
......
......@@ -8,10 +8,11 @@
namespace Test\Files\Node;
class Node extends \PHPUnit_Framework_TestCase {
class Node extends \Test\TestCase {
private $user;
public function setUp() {
protected function setUp() {
parent::setUp();
$this->user = new \OC\User\User('', new \OC_User_Dummy);
}
......
......@@ -11,10 +11,11 @@ namespace Test\Files\Node;
use OCP\Files\NotPermittedException;
use OC\Files\Mount\Manager;
class Root extends \PHPUnit_Framework_TestCase {
class Root extends \Test\TestCase {
private $user;
public function setUp() {
protected function setUp() {
parent::setUp();
$this->user = new \OC\User\User('', new \OC_User_Dummy);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment