@@ -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); | |||
} | |||
@@ -30,7 +30,9 @@ class Swift extends \Test\Files\Storage\Storage { | |||
private $objectStorage; | |||
public function setUp() { | |||
protected function setUp() { | |||
parent::setUp(); | |||
if (!getenv('RUN_OBJECTSTORE_TESTS')) { | |||
$this->markTestSkipped('objectstore tests are unreliable on travis'); | |||
} | |||
@@ -74,12 +76,14 @@ class Swift extends \Test\Files\Storage\Storage { | |||
$this->instance = new ObjectStoreStorage($params); | |||
} | |||
public function tearDown() { | |||
protected function tearDown() { | |||
if (is_null($this->instance)) { | |||
return; | |||
} | |||
$this->objectStorage->deleteContainer(true); | |||
$this->instance->getCache()->clear(); | |||
parent::tearDown(); | |||
} | |||
public function testStat() { |
@@ -27,12 +27,15 @@ class CommonTest extends Storage { | |||
* @var string tmpDir | |||
*/ | |||
private $tmpDir; | |||
public function setUp() { | |||
protected function setUp() { | |||
parent::setUp(); | |||
$this->tmpDir=\OC_Helper::tmpFolder(); | |||
$this->instance=new \OC\Files\Storage\CommonTest(array('datadir'=>$this->tmpDir)); | |||
} | |||
public function tearDown() { | |||
protected function tearDown() { | |||
\OC_Helper::rmdirr($this->tmpDir); | |||
parent::tearDown(); | |||
} | |||
} |
@@ -60,15 +60,18 @@ class Home extends Storage { | |||
*/ | |||
private $user; | |||
public function setUp() { | |||
protected function setUp() { | |||
parent::setUp(); | |||
$this->tmpDir = \OC_Helper::tmpFolder(); | |||
$this->userId = uniqid('user_'); | |||
$this->userId = $this->getUniqueID('user_'); | |||
$this->user = new DummyUser($this->userId, $this->tmpDir); | |||
$this->instance = new \OC\Files\Storage\Home(array('user' => $this->user)); | |||
} | |||
public function tearDown() { | |||
protected function tearDown() { | |||
\OC_Helper::rmdirr($this->tmpDir); | |||
parent::tearDown(); | |||
} | |||
/** |
@@ -28,13 +28,16 @@ class Local extends Storage { | |||
*/ | |||
private $tmpDir; | |||
public function setUp() { | |||
protected function setUp() { | |||
parent::setUp(); | |||
$this->tmpDir = \OC_Helper::tmpFolder(); | |||
$this->instance = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir)); | |||
} | |||
public function tearDown() { | |||
protected function tearDown() { | |||
\OC_Helper::rmdirr($this->tmpDir); | |||
parent::tearDown(); | |||
} | |||
public function testStableEtag() { |
@@ -27,14 +27,17 @@ class MappedLocal extends Storage { | |||
* @var string tmpDir | |||
*/ | |||
private $tmpDir; | |||
public function setUp() { | |||
protected function setUp() { | |||
parent::setUp(); | |||
$this->tmpDir=\OC_Helper::tmpFolder(); | |||
$this->instance=new \OC\Files\Storage\MappedLocal(array('datadir'=>$this->tmpDir)); | |||
} | |||
public function tearDown() { | |||
protected function tearDown() { | |||
\OC_Helper::rmdirr($this->tmpDir); | |||
unset($this->instance); | |||
parent::tearDown(); | |||
} | |||
} | |||
@@ -28,15 +28,18 @@ class MappedLocalWithDottedDataDir extends Storage { | |||
*/ | |||
private $tmpDir; | |||
public function setUp() { | |||
protected function setUp() { | |||
parent::setUp(); | |||
$this->tmpDir = \OC_Helper::tmpFolder().'dir.123'.DIRECTORY_SEPARATOR; | |||
mkdir($this->tmpDir); | |||
$this->instance=new \OC\Files\Storage\MappedLocal(array('datadir'=>$this->tmpDir)); | |||
} | |||
public function tearDown() { | |||
protected function tearDown() { | |||
\OC_Helper::rmdirr($this->tmpDir); | |||
unset($this->instance); | |||
parent::tearDown(); | |||
} | |||
} | |||
@@ -17,14 +17,17 @@ class Quota extends \Test\Files\Storage\Storage { | |||
*/ | |||
private $tmpDir; | |||
public function setUp() { | |||
protected function setUp() { | |||
parent::setUp(); | |||
$this->tmpDir = \OC_Helper::tmpFolder(); | |||
$storage = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir)); | |||
$this->instance = new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => 10000000)); | |||
} | |||
public function tearDown() { | |||
protected function tearDown() { | |||
\OC_Helper::rmdirr($this->tmpDir); | |||
parent::tearDown(); | |||
} | |||
/** |
@@ -14,14 +14,17 @@ class Wrapper extends \Test\Files\Storage\Storage { | |||
*/ | |||
private $tmpDir; | |||
public function setUp() { | |||
protected function setUp() { | |||
parent::setUp(); | |||
$this->tmpDir = \OC_Helper::tmpFolder(); | |||
$storage = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir)); | |||
$this->instance = new \OC\Files\Storage\Wrapper\Wrapper(array('storage' => $storage)); | |||
} | |||
public function tearDown() { | |||
protected function tearDown() { | |||
\OC_Helper::rmdirr($this->tmpDir); | |||
parent::tearDown(); | |||
} | |||
public function testInstanceOfStorageWrapper() { |
@@ -8,9 +8,10 @@ | |||
namespace Test\Files\Stream; | |||
class Quota extends \PHPUnit_Framework_TestCase { | |||
public function tearDown() { | |||
class Quota extends \Test\TestCase { | |||
protected function tearDown() { | |||
\OC\Files\Stream\Quota::clear(); | |||
parent::tearDown(); | |||
} | |||
/** |
@@ -8,18 +8,20 @@ | |||
namespace Test\Files\Stream; | |||
class StaticStream extends \PHPUnit_Framework_TestCase { | |||
class StaticStream extends \Test\TestCase { | |||
private $sourceFile; | |||
private $sourceText; | |||
public function __construct() { | |||
protected function setUp() { | |||
parent::setUp(); | |||
$this->sourceFile = \OC::$SERVERROOT . '/tests/data/lorem.txt'; | |||
$this->sourceText = file_get_contents($this->sourceFile); | |||
} | |||
public function tearDown() { | |||
protected function tearDown() { | |||
\OC\Files\Stream\StaticStream::clear(); | |||
parent::tearDown(); | |||
} | |||
public function testContent() { |
@@ -38,7 +38,6 @@ class TestScanner extends \OC\Files\Utils\Scanner { | |||
} | |||
} | |||
class Scanner extends \Test\TestCase { | |||
/** @var \OC\Files\Storage\Storage */ | |||
private $originalStorage; |
@@ -16,7 +16,7 @@ class TemporaryNoTouch extends \OC\Files\Storage\Temporary { | |||
} | |||
} | |||
class View extends \PHPUnit_Framework_TestCase { | |||
class View extends \Test\TestCase { | |||
/** | |||
* @var \OC\Files\Storage\Storage[] $storages | |||
*/ |
@@ -30,4 +30,14 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase { | |||
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' | |||
); | |||
} | |||
public static function tearDownAfterClass() { | |||
if (\OC_Util::runningOnWindows()) { | |||
$rootDirectory = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data-autotest'); | |||
$mapper = new \OC\Files\Mapper($rootDirectory); | |||
$mapper->removePath($rootDirectory, true, true); | |||
} | |||
parent::tearDownAfterClass(); | |||
} | |||
} |