Make root tests extend the \Test\TestCase

This commit is contained in:
Joas Schilling 2014-11-10 22:59:50 +01:00
parent 76ebd3a050
commit cb3a598cdb
46 changed files with 160 additions and 83 deletions

View File

@ -8,12 +8,14 @@
* *
*/ */
class Test_ActivityManager extends PHPUnit_Framework_TestCase { class Test_ActivityManager extends \Test\TestCase {
/** @var \OC\ActivityManager */ /** @var \OC\ActivityManager */
private $activityManager; private $activityManager;
public function setUp() { protected function setUp() {
parent::setUp();
$this->activityManager = new \OC\ActivityManager(); $this->activityManager = new \OC\ActivityManager();
$this->activityManager->registerExtension(function() { $this->activityManager->registerExtension(function() {
return new NoOpExtension(); return new NoOpExtension();

View File

@ -6,7 +6,7 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_API extends PHPUnit_Framework_TestCase { class Test_API extends \Test\TestCase {
// Helps build a response variable // Helps build a response variable

View File

@ -7,7 +7,7 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_App extends PHPUnit_Framework_TestCase { class Test_App extends \Test\TestCase {
private $oldAppConfigService; private $oldAppConfigService;

View File

@ -7,8 +7,10 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_Appconfig extends PHPUnit_Framework_TestCase { class Test_Appconfig extends \Test\TestCase {
public static function setUpBeforeClass() { public static function setUpBeforeClass() {
parent::setUpBeforeClass();
$query = \OC_DB::prepare('INSERT INTO `*PREFIX*appconfig` VALUES (?, ?, ?)'); $query = \OC_DB::prepare('INSERT INTO `*PREFIX*appconfig` VALUES (?, ?, ?)');
$query->execute(array('testapp', 'enabled', 'true')); $query->execute(array('testapp', 'enabled', 'true'));
@ -33,6 +35,8 @@ class Test_Appconfig extends PHPUnit_Framework_TestCase {
$query->execute(array('someapp')); $query->execute(array('someapp'));
$query->execute(array('123456')); $query->execute(array('123456'));
$query->execute(array('anotherapp')); $query->execute(array('anotherapp'));
parent::tearDownAfterClass();
} }
public function testGetApps() { public function testGetApps() {

View File

@ -6,7 +6,7 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
abstract class Test_Archive extends PHPUnit_Framework_TestCase { abstract class Test_Archive extends \Test\TestCase {
/** /**
* @var OC_Archive * @var OC_Archive
*/ */

View File

@ -7,11 +7,12 @@
*/ */
class Test_Archive_TAR extends Test_Archive { class Test_Archive_TAR extends Test_Archive {
public function setUp() { protected function setUp() {
parent::setUp();
if (OC_Util::runningOnWindows()) { if (OC_Util::runningOnWindows()) {
$this->markTestSkipped('[Windows] tar archives are not supported on Windows'); $this->markTestSkipped('[Windows] tar archives are not supported on Windows');
} }
parent::setUp();
} }
protected function getExisting() { protected function getExisting() {

View File

@ -6,8 +6,15 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
if (!OC_Util::runningOnWindows()) {
class Test_Archive_ZIP extends Test_Archive { class Test_Archive_ZIP extends Test_Archive {
protected function setUp() {
parent::setUp();
if (OC_Util::runningOnWindows()) {
$this->markTestSkipped('[Windows] ');
}
}
protected function getExisting() { protected function getExisting() {
$dir = OC::$SERVERROOT . '/tests/data'; $dir = OC::$SERVERROOT . '/tests/data';
return new OC_Archive_ZIP($dir . '/data.zip'); return new OC_Archive_ZIP($dir . '/data.zip');
@ -17,4 +24,3 @@ class Test_Archive_ZIP extends Test_Archive {
return new OC_Archive_ZIP(OCP\Files::tmpFile('.zip')); return new OC_Archive_ZIP(OCP\Files::tmpFile('.zip'));
} }
} }
}

View File

@ -8,13 +8,14 @@
namespace Test; namespace Test;
class AutoLoader extends \PHPUnit_Framework_TestCase { class AutoLoader extends TestCase {
/** /**
* @var \OC\Autoloader $loader * @var \OC\Autoloader $loader
*/ */
private $loader; private $loader;
public function setUp() { protected function setUp() {
parent::setUp();
$this->loader = new \OC\AutoLoader(); $this->loader = new \OC\AutoLoader();
} }

View File

@ -6,12 +6,14 @@
* later. * later.
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_Avatar extends PHPUnit_Framework_TestCase { class Test_Avatar extends \Test\TestCase {
private $user; private $user;
public function setUp() { protected function setUp() {
$this->user = uniqid(); parent::setUp();
$this->user = $this->getUniqueID();
$storage = new \OC\Files\Storage\Temporary(array()); $storage = new \OC\Files\Storage\Temporary(array());
\OC\Files\Filesystem::mount($storage, array(), '/' . $this->user . '/'); \OC\Files\Filesystem::mount($storage, array(), '/' . $this->user . '/');
} }

View File

@ -6,16 +6,17 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
abstract class Test_Cache extends PHPUnit_Framework_TestCase { abstract class Test_Cache extends \Test\TestCase {
/** /**
* @var \OC\Cache cache; * @var \OC\Cache cache;
*/ */
protected $instance; protected $instance;
public function tearDown() { protected function tearDown() {
if($this->instance) { if($this->instance) {
$this->instance->clear(); $this->instance->clear();
} }
parent::tearDown();
} }
function testSimple() { function testSimple() {

View File

@ -33,8 +33,10 @@ class FileCache extends \Test_Cache {
function skip() { function skip() {
//$this->skipUnless(OC_User::isLoggedIn()); //$this->skipUnless(OC_User::isLoggedIn());
} }
public function setUp() { protected function setUp() {
parent::setUp();
//clear all proxies and hooks so we can do clean testing //clear all proxies and hooks so we can do clean testing
\OC_FileProxy::clearProxies(); \OC_FileProxy::clearProxies();
\OC_Hook::clear('OC_Filesystem'); \OC_Hook::clear('OC_Filesystem');
@ -70,7 +72,7 @@ class FileCache extends \Test_Cache {
$this->instance=new \OC\Cache\File(); $this->instance=new \OC\Cache\File();
} }
public function tearDown() { protected function tearDown() {
\OC_User::setUserId($this->user); \OC_User::setUserId($this->user);
\OC_Config::setValue('cachedirectory', $this->datadir); \OC_Config::setValue('cachedirectory', $this->datadir);

View File

@ -30,7 +30,9 @@ class UserCache extends \Test_Cache {
/** @var \OC\Files\Storage\Storage */ /** @var \OC\Files\Storage\Storage */
private $storage; private $storage;
public function setUp() { protected function setUp() {
parent::setUp();
//clear all proxies and hooks so we can do clean testing //clear all proxies and hooks so we can do clean testing
\OC_FileProxy::clearProxies(); \OC_FileProxy::clearProxies();
\OC_Hook::clear('OC_Filesystem'); \OC_Hook::clear('OC_Filesystem');
@ -66,7 +68,7 @@ class UserCache extends \Test_Cache {
$this->instance=new \OC\Cache\UserCache(); $this->instance=new \OC\Cache\UserCache();
} }
public function tearDown() { protected function tearDown() {
\OC_User::setUserId($this->user); \OC_User::setUserId($this->user);
\OC_Config::setValue('cachedirectory', $this->datadir); \OC_Config::setValue('cachedirectory', $this->datadir);

View File

@ -6,7 +6,7 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_Config extends PHPUnit_Framework_TestCase { class Test_Config extends \Test\TestCase {
const TESTCONTENT = '<?php $CONFIG=array("foo"=>"bar", "beers" => array("Appenzeller", "Guinness", "Kölsch"), "alcohol_free" => false);'; const TESTCONTENT = '<?php $CONFIG=array("foo"=>"bar", "beers" => array("Appenzeller", "Guinness", "Kölsch"), "alcohol_free" => false);';
/** @var array */ /** @var array */
@ -18,15 +18,18 @@ class Test_Config extends PHPUnit_Framework_TestCase {
/** @var string */ /** @var string */
private $randomTmpDir; private $randomTmpDir;
function setUp() { protected function setUp() {
parent::setUp();
$this->randomTmpDir = \OC_Helper::tmpFolder(); $this->randomTmpDir = \OC_Helper::tmpFolder();
$this->configFile = $this->randomTmpDir.'testconfig.php'; $this->configFile = $this->randomTmpDir.'testconfig.php';
file_put_contents($this->configFile, self::TESTCONTENT); file_put_contents($this->configFile, self::TESTCONTENT);
$this->config = new OC\Config($this->randomTmpDir, 'testconfig.php'); $this->config = new OC\Config($this->randomTmpDir, 'testconfig.php');
} }
public function tearDown() { protected function tearDown() {
unlink($this->configFile); unlink($this->configFile);
parent::tearDown();
} }
public function testGetKeys() { public function testGetKeys() {

View File

@ -6,7 +6,7 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_DB extends PHPUnit_Framework_TestCase { class Test_DB extends \Test\TestCase {
protected $backupGlobals = FALSE; protected $backupGlobals = FALSE;
protected static $schema_file = 'static://test_db_scheme'; protected static $schema_file = 'static://test_db_scheme';
@ -32,7 +32,9 @@ class Test_DB extends PHPUnit_Framework_TestCase {
*/ */
private $table4; private $table4;
public function setUp() { protected function setUp() {
parent::setUp();
$dbfile = OC::$SERVERROOT.'/tests/data/db_structure.xml'; $dbfile = OC::$SERVERROOT.'/tests/data/db_structure.xml';
$r = '_'.OC_Util::generateRandomBytes(4).'_'; $r = '_'.OC_Util::generateRandomBytes(4).'_';
@ -48,9 +50,11 @@ class Test_DB extends PHPUnit_Framework_TestCase {
$this->table4 = $this->test_prefix.'decimal'; $this->table4 = $this->test_prefix.'decimal';
} }
public function tearDown() { protected function tearDown() {
OC_DB::removeDBStructure(self::$schema_file); OC_DB::removeDBStructure(self::$schema_file);
unlink(self::$schema_file); unlink(self::$schema_file);
parent::tearDown();
} }
public function testQuotes() { public function testQuotes() {

View File

@ -9,13 +9,15 @@
use OCP\Security\ISecureRandom; use OCP\Security\ISecureRandom;
class Test_DBSchema extends PHPUnit_Framework_TestCase { class Test_DBSchema extends \Test\TestCase {
protected $schema_file = 'static://test_db_scheme'; protected $schema_file = 'static://test_db_scheme';
protected $schema_file2 = 'static://test_db_scheme2'; protected $schema_file2 = 'static://test_db_scheme2';
protected $table1; protected $table1;
protected $table2; protected $table2;
public function setUp() { protected function setUp() {
parent::setUp();
$dbfile = OC::$SERVERROOT.'/tests/data/db_structure.xml'; $dbfile = OC::$SERVERROOT.'/tests/data/db_structure.xml';
$dbfile2 = OC::$SERVERROOT.'/tests/data/db_structure2.xml'; $dbfile2 = OC::$SERVERROOT.'/tests/data/db_structure2.xml';
@ -32,9 +34,11 @@ class Test_DBSchema extends PHPUnit_Framework_TestCase {
$this->table2 = $r.'cntcts_cards'; $this->table2 = $r.'cntcts_cards';
} }
public function tearDown() { protected function tearDown() {
unlink($this->schema_file); unlink($this->schema_file);
unlink($this->schema_file2); unlink($this->schema_file2);
parent::tearDown();
} }
// everything in one test, they depend on each other // everything in one test, they depend on each other

View File

@ -20,7 +20,7 @@
* *
*/ */
class Test_ErrorHandler extends \PHPUnit_Framework_TestCase { class Test_ErrorHandler extends \Test\TestCase {
/** /**
* provide username, password combinations for testRemovePassword * provide username, password combinations for testRemovePassword

View File

@ -6,7 +6,7 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_Geo extends PHPUnit_Framework_TestCase { class Test_Geo extends \Test\TestCase {
/** /**
* @medium * @medium

View File

@ -6,7 +6,7 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_Helper extends PHPUnit_Framework_TestCase { class Test_Helper extends \Test\TestCase {
/** /**
* @dataProvider humanFileSizeProvider * @dataProvider humanFileSizeProvider

View File

@ -6,14 +6,16 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class TestHTTPHelper extends \PHPUnit_Framework_TestCase { class TestHTTPHelper extends \Test\TestCase {
/** @var \OC\AllConfig*/ /** @var \OC\AllConfig*/
private $config; private $config;
/** @var \OC\HTTPHelper */ /** @var \OC\HTTPHelper */
private $httpHelperMock; private $httpHelperMock;
function setUp() { protected function setUp() {
parent::setUp();
$this->config = $this->getMockBuilder('\OC\AllConfig') $this->config = $this->getMockBuilder('\OC\AllConfig')
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->httpHelperMock = $this->getMockBuilder('\OC\HTTPHelper') $this->httpHelperMock = $this->getMockBuilder('\OC\HTTPHelper')

View File

@ -6,10 +6,12 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_Image extends PHPUnit_Framework_TestCase { class Test_Image extends \Test\TestCase {
public static function tearDownAfterClass() { public static function tearDownAfterClass() {
@unlink(OC::$SERVERROOT.'/tests/data/testimage2.png'); @unlink(OC::$SERVERROOT.'/tests/data/testimage2.png');
@unlink(OC::$SERVERROOT.'/tests/data/testimage2.jpg'); @unlink(OC::$SERVERROOT.'/tests/data/testimage2.jpg');
parent::tearDownAfterClass();
} }
public function testGetMimeTypeForFile() { public function testGetMimeTypeForFile() {

View File

@ -6,20 +6,24 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_Installer extends PHPUnit_Framework_TestCase { class Test_Installer extends \Test\TestCase {
private static $appid = 'testapp'; private static $appid = 'testapp';
private $appstore; private $appstore;
public function setUp() { protected function setUp() {
parent::setUp();
$this->appstore = OC_Config::getValue('appstoreenabled', true); $this->appstore = OC_Config::getValue('appstoreenabled', true);
OC_Config::setValue('appstoreenabled', true); OC_Config::setValue('appstoreenabled', true);
OC_Installer::removeApp(self::$appid); OC_Installer::removeApp(self::$appid);
} }
public function tearDown() { protected function tearDown() {
OC_Installer::removeApp(self::$appid); OC_Installer::removeApp(self::$appid);
OC_Config::setValue('appstoreenabled', $this->appstore); OC_Config::setValue('appstoreenabled', $this->appstore);
parent::tearDown();
} }
public function testInstallApp() { public function testInstallApp() {

View File

@ -6,7 +6,7 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_L10n extends PHPUnit_Framework_TestCase { class Test_L10n extends \Test\TestCase {
public function testGermanPluralTranslations() { public function testGermanPluralTranslations() {
$l = new OC_L10N('test'); $l = new OC_L10N('test');

View File

@ -8,10 +8,10 @@
namespace Test; namespace Test;
class LargeFileHelper extends \PHPUnit_Framework_TestCase { class LargeFileHelper extends TestCase {
protected $helper; protected $helper;
public function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->helper = new \OC\LargeFileHelper; $this->helper = new \OC\LargeFileHelper;
} }

View File

@ -12,11 +12,11 @@ namespace Test;
* Tests whether LargeFileHelper is able to determine file size at all. * Tests whether LargeFileHelper is able to determine file size at all.
* Large files are not considered yet. * Large files are not considered yet.
*/ */
class LargeFileHelperGetFileSize extends \PHPUnit_Framework_TestCase { class LargeFileHelperGetFileSize extends TestCase {
/** @var \OC\LargeFileHelper */ /** @var \OC\LargeFileHelper */
protected $helper; protected $helper;
public function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->helper = new \OC\LargeFileHelper(); $this->helper = new \OC\LargeFileHelper();
} }

View File

@ -10,14 +10,16 @@ namespace Test;
use OC\Log; use OC\Log;
class Logger extends \PHPUnit_Framework_TestCase { class Logger extends TestCase {
/** /**
* @var \OCP\ILogger * @var \OCP\ILogger
*/ */
private $logger; private $logger;
static private $logs = array(); static private $logs = array();
public function setUp() { protected function setUp() {
parent::setUp();
self::$logs = array(); self::$logs = array();
$this->logger = new Log('Test\Logger'); $this->logger = new Log('Test\Logger');
} }

View File

@ -6,10 +6,12 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_Mail extends PHPUnit_Framework_TestCase { class Test_Mail extends \Test\TestCase {
protected function setUp() protected function setUp()
{ {
parent::setUp();
if (!function_exists('idn_to_ascii')) { if (!function_exists('idn_to_ascii')) {
$this->markTestSkipped( $this->markTestSkipped(
'The intl extension is not available.' 'The intl extension is not available.'

View File

@ -6,7 +6,7 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_Migrate extends PHPUnit_Framework_TestCase { class Test_Migrate extends \Test\TestCase {
public $users; public $users;
public $tmpfiles = array(); public $tmpfiles = array();
@ -38,7 +38,7 @@ class Test_Migrate extends PHPUnit_Framework_TestCase {
* @return string the test users id * @return string the test users id
*/ */
public function generateUser() { public function generateUser() {
$username = uniqid(); $username = $this->getUniqueID();
\OC_User::createUser($username, 'password'); \OC_User::createUser($username, 'password');
\OC_Util::tearDownFS(); \OC_Util::tearDownFS();
\OC_User::setUserId(''); \OC_User::setUserId('');

View File

@ -6,9 +6,11 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_NaturalSort extends PHPUnit_Framework_TestCase { class Test_NaturalSort extends \Test\TestCase {
public function setUp() { public function setUp() {
parent::setUp();
if(!class_exists('Collator')) { if(!class_exists('Collator')) {
$this->markTestSkipped('The intl module is not available, natural sorting will not work as expected.'); $this->markTestSkipped('The intl module is not available, natural sorting will not work as expected.');
return; return;

View File

@ -7,8 +7,10 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_Preferences extends PHPUnit_Framework_TestCase { class Test_Preferences extends \Test\TestCase {
public static function setUpBeforeClass() { public static function setUpBeforeClass() {
parent::setUpBeforeClass();
$query = \OC_DB::prepare('INSERT INTO `*PREFIX*preferences` VALUES(?, ?, ?, ?)'); $query = \OC_DB::prepare('INSERT INTO `*PREFIX*preferences` VALUES(?, ?, ?, ?)');
$query->execute(array("Someuser", "someapp", "somekey", "somevalue")); $query->execute(array("Someuser", "someapp", "somekey", "somevalue"));
@ -34,6 +36,8 @@ class Test_Preferences extends PHPUnit_Framework_TestCase {
$query->execute(array('Someuser')); $query->execute(array('Someuser'));
$query->execute(array('Anotheruser')); $query->execute(array('Anotheruser'));
$query->execute(array('Anuser')); $query->execute(array('Anuser'));
parent::tearDownAfterClass();
} }
public function testGetUsers() { public function testGetUsers() {

View File

@ -7,7 +7,7 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_Preferences_Object extends PHPUnit_Framework_TestCase { class Test_Preferences_Object extends \Test\TestCase {
public function testGetUsers() public function testGetUsers()
{ {
$statementMock = $this->getMock('\Doctrine\DBAL\Statement', array(), array(), '', false); $statementMock = $this->getMock('\Doctrine\DBAL\Statement', array(), array(), '', false);

View File

@ -8,7 +8,7 @@
namespace Test; namespace Test;
class Preview extends \Test\TestCase { class Preview extends TestCase {
/** /**
* @var string * @var string

View File

@ -29,7 +29,7 @@ class TestRepairStep extends BasicEmitter implements \OC\RepairStep{
} }
} }
class Test_Repair extends PHPUnit_Framework_TestCase { class Test_Repair extends \Test\TestCase {
public function testRunRepairStep() { public function testRunRepairStep() {
$output = array(); $output = array();

View File

@ -6,19 +6,23 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_Request extends PHPUnit_Framework_TestCase { class Test_Request extends \Test\TestCase {
protected function setUp() {
parent::setUp();
public function setUp() {
OC::$server->getConfig()->setSystemValue('overwritewebroot', '/domain.tld/ownCloud'); OC::$server->getConfig()->setSystemValue('overwritewebroot', '/domain.tld/ownCloud');
OC::$server->getConfig()->setSystemValue('trusted_proxies', array()); OC::$server->getConfig()->setSystemValue('trusted_proxies', array());
OC::$server->getConfig()->setSystemValue('forwarded_for_headers', array()); OC::$server->getConfig()->setSystemValue('forwarded_for_headers', array());
} }
public function tearDown() { protected function tearDown() {
OC::$server->getConfig()->setSystemValue('overwritewebroot', ''); OC::$server->getConfig()->setSystemValue('overwritewebroot', '');
OC::$server->getConfig()->setSystemValue('trusted_proxies', array()); OC::$server->getConfig()->setSystemValue('trusted_proxies', array());
OC::$server->getConfig()->setSystemValue('forwarded_for_headers', array()); OC::$server->getConfig()->setSystemValue('forwarded_for_headers', array());
parent::tearDown();
} }
public function testScriptNameOverWrite() { public function testScriptNameOverWrite() {

View File

@ -8,14 +8,16 @@
use OCP\IConfig; use OCP\IConfig;
class Test_OC_Setup extends PHPUnit_Framework_TestCase { class Test_OC_Setup extends \Test\TestCase {
/** @var IConfig */ /** @var IConfig */
protected $config; protected $config;
/** @var \OC_Setup */ /** @var \OC_Setup */
protected $setupClass; protected $setupClass;
public function setUp() { protected function setUp() {
parent::setUp();
$this->config = $this->getMock('\OCP\IConfig'); $this->config = $this->getMock('\OCP\IConfig');
$this->setupClass = $this->getMock('\OC_Setup', array('class_exists', 'is_callable'), array($this->config)); $this->setupClass = $this->getMock('\OC_Setup', array('class_exists', 'is_callable'), array($this->config));
} }

View File

@ -20,7 +20,7 @@
* *
*/ */
class Test_StreamWrappers extends PHPUnit_Framework_TestCase { class Test_StreamWrappers extends \Test\TestCase {
public function testFakeDir() { public function testFakeDir() {
$items = array('foo', 'bar'); $items = array('foo', 'bar');
\OC\Files\Stream\Dir::register('test', $items); \OC\Files\Stream\Dir::register('test', $items);

View File

@ -20,13 +20,14 @@
* *
*/ */
class Test_Tags extends PHPUnit_Framework_TestCase { class Test_Tags extends \Test\TestCase {
protected $objectType; protected $objectType;
protected $user; protected $user;
protected $backupGlobals = FALSE; protected $backupGlobals = FALSE;
public function setUp() { protected function setUp() {
parent::setUp();
OC_User::clearBackends(); OC_User::clearBackends();
OC_User::useBackend('dummy'); OC_User::useBackend('dummy');
@ -39,9 +40,11 @@ class Test_Tags extends PHPUnit_Framework_TestCase {
} }
public function tearDown() { protected function tearDown() {
//$query = OC_DB::prepare('DELETE FROM `*PREFIX*vcategories` WHERE `item_type` = ?'); //$query = OC_DB::prepare('DELETE FROM `*PREFIX*vcategories` WHERE `item_type` = ?');
//$query->execute(array('test')); //$query->execute(array('test'));
parent::tearDown();
} }
public function testInstantiateWithDefaults() { public function testInstantiateWithDefaults() {

View File

@ -20,9 +20,11 @@
* *
*/ */
class Test_TemplateFunctions extends PHPUnit_Framework_TestCase { class Test_TemplateFunctions extends \Test\TestCase {
protected function setUp() {
parent::setUp();
public function setUp() {
$loader = new \OC\Autoloader(); $loader = new \OC\Autoloader();
$loader->load('OC_Template'); $loader->load('OC_Template');
} }

View File

@ -11,23 +11,27 @@ namespace OC\Test;
/** /**
* @package OC\Test * @package OC\Test
*/ */
class OC_TemplateLayout extends \PHPUnit_Framework_TestCase { class OC_TemplateLayout extends \Test\TestCase {
private $oldServerUri; private $oldServerURI;
private $oldScriptName; private $oldScriptName;
public function setUp() { protected function setUp() {
parent::setUp();
$this->oldServerURI = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : null; $this->oldServerURI = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : null;
$this->oldScriptName = $_SERVER['SCRIPT_NAME']; $this->oldScriptName = $_SERVER['SCRIPT_NAME'];
} }
public function tearDown() { protected function tearDown() {
if ($this->oldServerURI === null) { if ($this->oldServerURI === null) {
unset($_SERVER['REQUEST_URI']); unset($_SERVER['REQUEST_URI']);
} else { } else {
$_SERVER['REQUEST_URI'] = $this->oldServerURI; $_SERVER['REQUEST_URI'] = $this->oldServerURI;
} }
$_SERVER['SCRIPT_NAME'] = $this->oldScriptName; $_SERVER['SCRIPT_NAME'] = $this->oldScriptName;
parent::tearDown();
} }
/** /**

View File

@ -21,18 +21,21 @@ class NullLogger extends Log {
} }
} }
class TempManager extends \PHPUnit_Framework_TestCase { class TempManager extends \Test\TestCase {
protected $baseDir; protected $baseDir;
public function setUp() { protected function setUp() {
parent::setUp();
$this->baseDir = get_temp_dir() . '/oc_tmp_test'; $this->baseDir = get_temp_dir() . '/oc_tmp_test';
if (!is_dir($this->baseDir)) { if (!is_dir($this->baseDir)) {
mkdir($this->baseDir); mkdir($this->baseDir);
} }
} }
public function tearDown() { protected function tearDown() {
\OC_Helper::rmdirr($this->baseDir); \OC_Helper::rmdirr($this->baseDir);
parent::tearDown();
} }
/** /**

View File

@ -8,7 +8,7 @@
namespace OC; namespace OC;
class UpdaterTest extends \PHPUnit_Framework_TestCase { class UpdaterTest extends \Test\TestCase {
public function testVersionCompatbility() { public function testVersionCompatbility() {
return array( return array(

View File

@ -6,7 +6,7 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_Urlgenerator extends PHPUnit_Framework_TestCase { class Test_Urlgenerator extends \Test\TestCase {
/** /**
* @small * @small

View File

@ -9,13 +9,15 @@
namespace Test; namespace Test;
class User extends \PHPUnit_Framework_TestCase { class User extends TestCase {
/** /**
* @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/ */
private $backend; private $backend;
protected function setUp(){ protected function setUp(){
parent::setUp();
$this->backend = $this->getMock('\OC_User_Dummy'); $this->backend = $this->getMock('\OC_User_Dummy');
$manager = \OC_User::getManager(); $manager = \OC_User::getManager();
$manager->registerBackend($this->backend); $manager->registerBackend($this->backend);

View File

@ -6,7 +6,7 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_Util extends PHPUnit_Framework_TestCase { class Test_Util extends \Test\TestCase {
public function testGetVersion() { public function testGetVersion() {
$version = \OC_Util::getVersion(); $version = \OC_Util::getVersion();
$this->assertTrue(is_array($version)); $this->assertTrue(is_array($version));

View File

@ -9,7 +9,7 @@
/** /**
* Tests for server check functions * Tests for server check functions
*/ */
class Test_Util_CheckServer extends PHPUnit_Framework_TestCase { class Test_Util_CheckServer extends \Test\TestCase {
private $datadir; private $datadir;
@ -32,16 +32,19 @@ class Test_Util_CheckServer extends PHPUnit_Framework_TestCase {
return $config; return $config;
} }
public function setUp() { protected function setUp() {
parent::setUp();
$this->datadir = \OC_Helper::tmpFolder(); $this->datadir = \OC_Helper::tmpFolder();
file_put_contents($this->datadir . '/.ocdata', ''); file_put_contents($this->datadir . '/.ocdata', '');
\OC::$server->getSession()->set('checkServer_succeeded', false); \OC::$server->getSession()->set('checkServer_succeeded', false);
} }
public function tearDown() { protected function tearDown() {
// clean up // clean up
@unlink($this->datadir . '/.ocdata'); @unlink($this->datadir . '/.ocdata');
parent::tearDown();
} }
/** /**

View File

@ -6,9 +6,11 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class Test_VObject extends PHPUnit_Framework_TestCase { class Test_VObject extends \Test\TestCase {
protected function setUp() {
parent::setUp();
public function setUp() {
Sabre\VObject\Property::$classMap['SUMMARY'] = 'OC\VObject\StringProperty'; Sabre\VObject\Property::$classMap['SUMMARY'] = 'OC\VObject\StringProperty';
Sabre\VObject\Property::$classMap['ORG'] = 'OC\VObject\CompoundProperty'; Sabre\VObject\Property::$classMap['ORG'] = 'OC\VObject\CompoundProperty';
} }

View File

@ -14,11 +14,13 @@ use \OC\Settings\Application;
/** /**
* @package OC\Settings\Controller * @package OC\Settings\Controller
*/ */
class MailSettingsControllerTest extends \PHPUnit_Framework_TestCase { class MailSettingsControllerTest extends \Test\TestCase {
private $container; private $container;
protected function setUp() { protected function setUp() {
parent::setUp();
$app = new Application(); $app = new Application();
$this->container = $app->getContainer(); $this->container = $app->getContainer();
$this->container['Config'] = $this->getMockBuilder('\OCP\IConfig') $this->container['Config'] = $this->getMockBuilder('\OCP\IConfig')