Make remaining files extend the test base

This commit is contained in:
Joas Schilling 2014-11-10 23:30:38 +01:00
parent cb3a598cdb
commit 6202ca33ba
70 changed files with 191 additions and 117 deletions

View File

@ -25,7 +25,7 @@
namespace OC\AppFramework;
class AppTest extends \PHPUnit_Framework_TestCase {
class AppTest extends \Test\TestCase {
private $container;
private $api;
@ -38,6 +38,8 @@ class AppTest extends \PHPUnit_Framework_TestCase {
private $controllerMethod;
protected function setUp() {
parent::setUp();
$this->container = new \OC\AppFramework\DependencyInjection\DIContainer('test', array());
$this->controller = $this->getMockBuilder(
'OCP\AppFramework\Controller')

View File

@ -31,7 +31,7 @@ use OCP\AppFramework\Http\TemplateResponse;
class ChildApiController extends ApiController {};
class ApiControllerTest extends \PHPUnit_Framework_TestCase {
class ApiControllerTest extends \Test\TestCase {
public function testCors() {

View File

@ -54,7 +54,7 @@ class ChildController extends Controller {
}
};
class ControllerTest extends \PHPUnit_Framework_TestCase {
class ControllerTest extends \Test\TestCase {
/**
* @var Controller
@ -63,6 +63,8 @@ class ControllerTest extends \PHPUnit_Framework_TestCase {
private $app;
protected function setUp(){
parent::setUp();
$request = new Request(
array(
'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'),

View File

@ -49,11 +49,12 @@ class TestEntity extends Entity {
};
class EntityTest extends \PHPUnit_Framework_TestCase {
class EntityTest extends \Test\TestCase {
private $entity;
protected function setUp(){
parent::setUp();
$this->entity = new TestEntity();
}

View File

@ -57,7 +57,7 @@ class MapperTest extends MapperTestUtility {
*/
private $mapper;
public function setUp(){
protected function setUp(){
parent::setUp();
$this->mapper = new ExampleMapper($this->db);
}

View File

@ -28,9 +28,7 @@ namespace Test\AppFramework\Db;
/**
* Simple utility class for testing mappers
*/
abstract class MapperTestUtility extends \PHPUnit_Framework_TestCase {
abstract class MapperTestUtility extends \Test\TestCase {
protected $db;
private $query;
private $pdoResult;
@ -45,6 +43,8 @@ abstract class MapperTestUtility extends \PHPUnit_Framework_TestCase {
* db. After this the db can be accessed by using $this->db
*/
protected function setUp(){
parent::setUp();
$this->db = $this->getMockBuilder(
'\OCP\IDb')
->disableOriginalConstructor()

View File

@ -29,12 +29,13 @@ namespace OC\AppFramework\DependencyInjection;
use \OC\AppFramework\Http\Request;
class DIContainerTest extends \PHPUnit_Framework_TestCase {
class DIContainerTest extends \Test\TestCase {
private $container;
private $api;
protected function setUp(){
parent::setUp();
$this->container = new DIContainer('name');
$this->api = $this->getMock('OC\AppFramework\Core\API', array(), array('hi'));
}

View File

@ -29,7 +29,7 @@ use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http;
class DataResponseTest extends \PHPUnit_Framework_TestCase {
class DataResponseTest extends \Test\TestCase {
/**
* @var DataResponse
@ -37,6 +37,7 @@ class DataResponseTest extends \PHPUnit_Framework_TestCase {
private $response;
protected function setUp() {
parent::setUp();
$this->response = new DataResponse();
}

View File

@ -62,9 +62,7 @@ class TestController extends Controller {
}
class DispatcherTest extends \PHPUnit_Framework_TestCase {
class DispatcherTest extends \Test\TestCase {
private $middlewareDispatcher;
private $dispatcher;
private $controllerMethod;
@ -75,6 +73,7 @@ class DispatcherTest extends \PHPUnit_Framework_TestCase {
private $reflector;
protected function setUp() {
parent::setUp();
$this->controllerMethod = 'test';
$app = $this->getMockBuilder(

View File

@ -30,7 +30,7 @@ class ChildDownloadResponse extends DownloadResponse {
};
class DownloadResponseTest extends \PHPUnit_Framework_TestCase {
class DownloadResponseTest extends \Test\TestCase {
/**
* @var ChildDownloadResponse
@ -38,6 +38,7 @@ class DownloadResponseTest extends \PHPUnit_Framework_TestCase {
protected $response;
protected function setUp(){
parent::setUp();
$this->response = new ChildDownloadResponse('file', 'content');
}

View File

@ -27,7 +27,7 @@ namespace OC\AppFramework\Http;
use OC\AppFramework\Http;
class HttpTest extends \PHPUnit_Framework_TestCase {
class HttpTest extends \Test\TestCase {
private $server;
@ -37,6 +37,8 @@ class HttpTest extends \PHPUnit_Framework_TestCase {
private $http;
protected function setUp(){
parent::setUp();
$this->server = array();
$this->http = new Http($this->server);
}

View File

@ -30,7 +30,7 @@ namespace OC\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http;
class JSONResponseTest extends \PHPUnit_Framework_TestCase {
class JSONResponseTest extends \Test\TestCase {
/**
* @var JSONResponse
@ -38,6 +38,7 @@ class JSONResponseTest extends \PHPUnit_Framework_TestCase {
private $json;
protected function setUp() {
parent::setUp();
$this->json = new JSONResponse();
}

View File

@ -27,7 +27,7 @@ namespace OCP\AppFramework\Http;
use OCP\AppFramework\Http;
class RedirectResponseTest extends \PHPUnit_Framework_TestCase {
class RedirectResponseTest extends \Test\TestCase {
/**
* @var RedirectResponse
@ -35,6 +35,7 @@ class RedirectResponseTest extends \PHPUnit_Framework_TestCase {
protected $response;
protected function setUp(){
parent::setUp();
$this->response = new RedirectResponse('/url');
}

View File

@ -10,9 +10,11 @@ namespace OC\AppFramework\Http;
global $data;
class RequestTest extends \PHPUnit_Framework_TestCase {
class RequestTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
public function setUp() {
require_once __DIR__ . '/requeststream.php';
if (in_array('fakeinput', stream_get_wrappers())) {
stream_wrapper_unregister('fakeinput');
@ -21,8 +23,9 @@ class RequestTest extends \PHPUnit_Framework_TestCase {
$this->stream = 'fakeinput://data';
}
public function tearDown() {
protected function tearDown() {
stream_wrapper_unregister('fakeinput');
parent::tearDown();
}
public function testRequestAccessors() {

View File

@ -29,7 +29,7 @@ use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http;
class ResponseTest extends \PHPUnit_Framework_TestCase {
class ResponseTest extends \Test\TestCase {
/**
* @var \OCP\AppFramework\Http\Response
@ -37,6 +37,7 @@ class ResponseTest extends \PHPUnit_Framework_TestCase {
private $childResponse;
protected function setUp(){
parent::setUp();
$this->childResponse = new Response();
}

View File

@ -28,7 +28,7 @@ use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http;
class TemplateResponseTest extends \PHPUnit_Framework_TestCase {
class TemplateResponseTest extends \Test\TestCase {
/**
* @var \OCP\AppFramework\Http\TemplateResponse
@ -41,6 +41,8 @@ class TemplateResponseTest extends \PHPUnit_Framework_TestCase {
private $api;
protected function setUp() {
parent::setUp();
$this->api = $this->getMock('OC\AppFramework\Core\API',
array('getAppName'), array('test'));
$this->api->expects($this->any())

View File

@ -100,7 +100,7 @@ class TestMiddleware extends Middleware {
}
class MiddlewareDispatcherTest extends \PHPUnit_Framework_TestCase {
class MiddlewareDispatcherTest extends \Test\TestCase {
public $exception;
public $response;
@ -113,8 +113,9 @@ class MiddlewareDispatcherTest extends \PHPUnit_Framework_TestCase {
*/
private $dispatcher;
protected function setUp() {
parent::setUp();
public function setUp() {
$this->dispatcher = new MiddlewareDispatcher();
$this->controller = $this->getControllerMock();
$this->method = 'method';

View File

@ -31,7 +31,7 @@ use OCP\AppFramework\Middleware;
class ChildMiddleware extends Middleware {};
class MiddlewareTest extends \PHPUnit_Framework_TestCase {
class MiddlewareTest extends \Test\TestCase {
/**
* @var Middleware
@ -42,6 +42,8 @@ class MiddlewareTest extends \PHPUnit_Framework_TestCase {
private $api;
protected function setUp(){
parent::setUp();
$this->middleware = new ChildMiddleware();
$this->api = $this->getMockBuilder(

View File

@ -18,11 +18,12 @@ use OC\AppFramework\Utility\ControllerMethodReflector;
use OCP\AppFramework\Http\Response;
class CORSMiddlewareTest extends \PHPUnit_Framework_TestCase {
class CORSMiddlewareTest extends \Test\TestCase {
private $reflector;
protected function setUp() {
parent::setUp();
$this->reflector = new ControllerMethodReflector();
}

View File

@ -31,7 +31,7 @@ use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\JSONResponse;
class SecurityMiddlewareTest extends \PHPUnit_Framework_TestCase {
class SecurityMiddlewareTest extends \Test\TestCase {
private $middleware;
private $controller;
@ -43,7 +43,9 @@ class SecurityMiddlewareTest extends \PHPUnit_Framework_TestCase {
private $navigationManager;
private $urlGenerator;
public function setUp() {
protected function setUp() {
parent::setUp();
$this->controller = $this->getMockBuilder('OCP\AppFramework\Controller')
->disableOriginalConstructor()
->getMock();

View File

@ -18,7 +18,7 @@ use OC\AppFramework\Utility\ControllerMethodReflector;
use OCP\AppFramework\Http\Response;
class SessionMiddlewareTest extends \PHPUnit_Framework_TestCase {
class SessionMiddlewareTest extends \Test\TestCase {
/**
* @var ControllerMethodReflector
@ -31,6 +31,8 @@ class SessionMiddlewareTest extends \PHPUnit_Framework_TestCase {
private $request;
protected function setUp() {
parent::setUp();
$this->request = new Request();
$this->reflector = new ControllerMethodReflector();
}

View File

@ -6,7 +6,7 @@ use OC\AppFramework\DependencyInjection\DIContainer;
use OC\AppFramework\routing\RouteConfig;
class RoutingTest extends \PHPUnit_Framework_TestCase
class RoutingTest extends \Test\TestCase
{
public function testSimpleRoute()

View File

@ -25,7 +25,7 @@
namespace OC\AppFramework\Utility;
class ControllerMethodReflectorTest extends \PHPUnit_Framework_TestCase {
class ControllerMethodReflectorTest extends \Test\TestCase {
/**

View File

@ -8,10 +8,11 @@
namespace Test\BackgroundJob;
class Job extends \PHPUnit_Framework_TestCase {
class Job extends \Test\TestCase {
private $run = false;
public function setUp() {
protected function setUp() {
parent::setUp();
$this->run = false;
}

View File

@ -8,7 +8,7 @@
namespace Test\BackgroundJob;
class JobList extends \PHPUnit_Framework_TestCase {
class JobList extends \Test\TestCase {
/**
* @var \OC\BackgroundJob\JobList
*/
@ -19,7 +19,9 @@ class JobList extends \PHPUnit_Framework_TestCase {
*/
protected $config;
public function setUp() {
protected function setUp() {
parent::setUp();
$conn = \OC::$server->getDatabaseConnection();
$this->config = $this->getMock('\OCP\IConfig');
$this->instance = new \OC\BackgroundJob\JobList($conn, $this->config);

View File

@ -23,7 +23,7 @@ class TestQueuedJob extends \OC\BackgroundJob\QueuedJob {
}
}
class QueuedJob extends \PHPUnit_Framework_TestCase {
class QueuedJob extends \Test\TestCase {
/**
* @var DummyJobList $jobList
*/
@ -39,7 +39,9 @@ class QueuedJob extends \PHPUnit_Framework_TestCase {
$this->jobRun = true;
}
public function setup() {
protected function setup() {
parent::setUp();
$this->jobList = new DummyJobList();
$this->job = new TestQueuedJob($this);
$this->jobList->add($this->job);

View File

@ -24,7 +24,7 @@ class TestTimedJob extends \OC\BackgroundJob\TimedJob {
}
}
class TimedJob extends \PHPUnit_Framework_TestCase {
class TimedJob extends \Test\TestCase {
/**
* @var DummyJobList $jobList
*/
@ -40,7 +40,9 @@ class TimedJob extends \PHPUnit_Framework_TestCase {
$this->jobRun = true;
}
public function setup() {
protected function setup() {
parent::setUp();
$this->jobList = new DummyJobList();
$this->job = new TestTimedJob($this);
$this->jobList->add($this->job);

View File

@ -16,6 +16,7 @@ abstract class Test_Cache extends \Test\TestCase {
if($this->instance) {
$this->instance->clear();
}
parent::tearDown();
}

View File

@ -6,12 +6,14 @@
* later.
* See the COPYING-README file.
*/
class Test_OC_Connector_Sabre_Directory extends PHPUnit_Framework_TestCase {
class Test_OC_Connector_Sabre_Directory extends \Test\TestCase {
private $view;
private $info;
public function setUp() {
protected function setUp() {
parent::setUp();
$this->view = $this->getMock('OC\Files\View', array(), array(), '', false);
$this->info = $this->getMock('OC\Files\FileInfo', array(), array(), '', false);
}

View File

@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
class Test_OC_Connector_Sabre_File extends PHPUnit_Framework_TestCase {
class Test_OC_Connector_Sabre_File extends \Test\TestCase {
/**
* @expectedException \Sabre\DAV\Exception

View File

@ -12,7 +12,7 @@ namespace Test\Connector\Sabre;
use OC\Files\FileInfo;
use OC\Files\View;
class Node extends \PHPUnit_Framework_TestCase {
class Node extends \Test\TestCase {
public function davPermissionsProvider() {
return array(
array(\OCP\PERMISSION_ALL, 'file', false, false, 'RDNVW'),

View File

@ -13,7 +13,7 @@ use OC\Files\FileInfo;
use OC_Connector_Sabre_Directory;
use PHPUnit_Framework_TestCase;
class TestDoubleFileView extends \OC\Files\View{
class TestDoubleFileView extends \OC\Files\View {
public function __construct($updatables, $deletables, $canRename = true) {
$this->updatables = $updatables;
@ -42,7 +42,7 @@ class TestDoubleFileView extends \OC\Files\View{
}
}
class ObjectTree extends PHPUnit_Framework_TestCase {
class ObjectTree extends \Test\TestCase {
/**
* @dataProvider moveFailedProvider

View File

@ -6,7 +6,7 @@
* later.
* See the COPYING-README file.
*/
class Test_OC_Connector_Sabre_QuotaPlugin extends PHPUnit_Framework_TestCase {
class Test_OC_Connector_Sabre_QuotaPlugin extends \Test\TestCase {
/**
* @var \Sabre\DAV\Server

View File

@ -11,7 +11,7 @@ use OC\Contacts\LocalAddressBook;
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
class Test_LocalAddressBook extends PHPUnit_Framework_TestCase
class Test_LocalAddressBook extends \Test\TestCase
{
public function testSearchFN() {

View File

@ -12,15 +12,17 @@ namespace Test\DB;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
class MDB2SchemaManager extends \PHPUnit_Framework_TestCase {
class MDB2SchemaManager extends \Test\TestCase {
public function tearDown() {
protected function tearDown() {
// do not drop the table for Oracle as it will create a bogus transaction
// that will break the following test suites requiring transactions
if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') === 'oci') {
return;
}
\OC_DB::dropTable('table');
parent::tearDown();
}
public function testAutoIncrement() {

View File

@ -11,7 +11,7 @@ namespace Test\DB;
use Doctrine\DBAL\Platforms\MySqlPlatform;
class MDB2SchemaReader extends \PHPUnit_Framework_TestCase {
class MDB2SchemaReader extends \Test\TestCase {
/**
* @var \OC\DB\MDB2SchemaReader $reader
*/

View File

@ -15,7 +15,7 @@ use Doctrine\DBAL\Platforms\SQLServerPlatform;
use \Doctrine\DBAL\Schema\Schema;
use \Doctrine\DBAL\Schema\SchemaConfig;
class Migrator extends \PHPUnit_Framework_TestCase {
class Migrator extends \Test\TestCase {
/**
* @var \Doctrine\DBAL\Connection $connection
*/
@ -28,7 +28,9 @@ class Migrator extends \PHPUnit_Framework_TestCase {
private $tableName;
public function setUp() {
protected function setUp() {
parent::setUp();
$this->connection = \OC_DB::getConnection();
if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
$this->markTestSkipped('DB migration tests are not supported on OCI');
@ -40,8 +42,9 @@ class Migrator extends \PHPUnit_Framework_TestCase {
$this->tableName = 'test_' . uniqid();
}
public function tearDown() {
protected function tearDown() {
$this->connection->exec('DROP TABLE ' . $this->tableName);
parent::tearDown();
}
/**

View File

@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
class TestMySqlMigration extends \PHPUnit_Framework_TestCase {
class TestMySqlMigration extends \Test\TestCase {
/** @var \Doctrine\DBAL\Connection */
private $connection;
@ -14,7 +14,9 @@ class TestMySqlMigration extends \PHPUnit_Framework_TestCase {
/** @var string */
private $tableName;
public function setUp() {
protected function setUp() {
parent::setUp();
$this->connection = \OC_DB::getConnection();
if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
$this->markTestSkipped("Test only relevant on MySql");
@ -25,8 +27,9 @@ class TestMySqlMigration extends \PHPUnit_Framework_TestCase {
$this->connection->exec("CREATE TABLE $this->tableName(b BIT, e ENUM('1','2','3','4'))");
}
public function tearDown() {
protected function tearDown() {
$this->connection->getSchemaManager()->dropTable($this->tableName);
parent::tearDown();
}
public function testNonOCTables() {

View File

@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
class TestSqliteMigration extends \PHPUnit_Framework_TestCase {
class TestSqliteMigration extends \Test\TestCase {
/** @var \Doctrine\DBAL\Connection */
private $connection;
@ -14,7 +14,9 @@ class TestSqliteMigration extends \PHPUnit_Framework_TestCase {
/** @var string */
private $tableName;
public function setUp() {
protected function setUp() {
parent::setUp();
$this->connection = \OC_DB::getConnection();
if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
$this->markTestSkipped("Test only relevant on Sqlite");
@ -25,8 +27,9 @@ class TestSqliteMigration extends \PHPUnit_Framework_TestCase {
$this->connection->exec("CREATE TABLE $this->tableName(t0 tinyint unsigned, t1 tinyint)");
}
public function tearDown() {
protected function tearDown() {
$this->connection->getSchemaManager()->dropTable($this->tableName);
parent::tearDown();
}
public function testNonOCTables() {

View File

@ -11,7 +11,7 @@ namespace Test\Group;
use OC\User\User;
class Group extends \PHPUnit_Framework_TestCase {
class Group extends \Test\TestCase {
/**
* @return \OC\User\Manager | \OC\User\Manager
*/

View File

@ -11,7 +11,7 @@ namespace Test\Group;
use OC\User\User;
class Manager extends \PHPUnit_Framework_TestCase {
class Manager extends \Test\TestCase {
public function testGet() {
/**
* @var \PHPUnit_Framework_MockObject_MockObject | \OC_Group_Backend $backend

View File

@ -9,7 +9,7 @@
namespace Test\Group;
class Test_MetaData extends \PHPUnit_Framework_TestCase {
class Test_MetaData extends \Test\TestCase {
private function getGroupManagerMock() {
return $this->getMockBuilder('\OC\Group\Manager')
->disableOriginalConstructor()

View File

@ -31,13 +31,14 @@ class DummyEmitter extends \OC\Hooks\BasicEmitter {
class EmittedException extends \Exception {
}
class BasicEmitter extends \PHPUnit_Framework_TestCase {
class BasicEmitter extends \Test\TestCase {
/**
* @var \OC\Hooks\Emitter $emitter
*/
protected $emitter;
public function setUp() {
protected function setUp() {
parent::setUp();
$this->emitter = new DummyEmitter();
}

View File

@ -26,7 +26,9 @@ class LegacyEmitter extends BasicEmitter {
//we can't use exceptions here since OC_Hooks catches all exceptions
private static $emitted = false;
public function setUp() {
protected function setUp() {
parent::setUp();
$this->emitter = new DummyLegacyEmitter();
self::$emitted = false;
\OC_Hook::clear('Test','test');

View File

@ -10,7 +10,9 @@
namespace Test\Memcache;
class APC extends Cache {
public function setUp() {
protected function setUp() {
parent::setUp();
if(!\OC\Memcache\APC::isAvailable()) {
$this->markTestSkipped('The apc extension is not available.');
return;

View File

@ -10,7 +10,9 @@
namespace Test\Memcache;
class APCu extends Cache {
public function setUp() {
protected function setUp() {
parent::setUp();
if(!\OC\Memcache\APCu::isAvailable()) {
$this->markTestSkipped('The APCu extension is not available.');
return;

View File

@ -50,9 +50,11 @@ abstract class Cache extends \Test_Cache {
$this->assertFalse($this->instance->hasKey('foo'));
}
public function tearDown() {
protected function tearDown() {
if ($this->instance) {
$this->instance->clear();
}
parent::tearDown();
}
}

View File

@ -11,6 +11,8 @@ namespace Test\Memcache;
class Memcached extends Cache {
static public function setUpBeforeClass() {
parent::setUpBeforeClass();
if (!\OC\Memcache\Memcached::isAvailable()) {
self::markTestSkipped('The memcached extension is not available.');
}
@ -20,7 +22,8 @@ class Memcached extends Cache {
}
}
public function setUp() {
protected function setUp() {
parent::setUp();
$this->instance = new \OC\Memcache\Memcached(uniqid());
}
}

View File

@ -10,7 +10,9 @@
namespace Test\Memcache;
class XCache extends Cache {
public function setUp() {
protected function setUp() {
parent::setUp();
if (!\OC\Memcache\XCache::isAvailable()) {
$this->markTestSkipped('The xcache extension is not available.');
return;

View File

@ -20,19 +20,15 @@
*
*/
class Test_OC_OCS_Privatedata extends PHPUnit_Framework_TestCase
{
class Test_OC_OCS_Privatedata extends \Test\TestCase {
private $appKey;
public function setUp() {
protected function setUp() {
parent::setUp();
\OC::$server->getSession()->set('user_id', 'user1');
$this->appKey = uniqid('app');
}
public function tearDown() {
}
public function testGetEmptyOne() {
$params = array('app' => $this->appKey, 'key' => '123');
$result = OC_OCS_Privatedata::get($params);

View File

@ -19,17 +19,12 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
class Test_Contacts extends PHPUnit_Framework_TestCase
{
public function setUp() {
class Test_Contacts extends \Test\TestCase {
protected function setUp() {
parent::setUp();
OCP\Contacts::clear();
}
public function tearDown() {
}
public function testDisabledIfEmpty() {
// pretty simple
$this->assertFalse(OCP\Contacts::isEnabled());

View File

@ -19,12 +19,11 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
class Test_OCPConfig extends PHPUnit_Framework_TestCase
{
class Test_OCPConfig extends \Test\TestCase {
public function testSetAppValueIfSetToNull() {
$key = uniqid("key-");
$key = $this->getUniqueID('key-');
$result = \OCP\Config::setAppValue('unit-test', $key, null);
$this->assertTrue($result);

View File

@ -21,7 +21,7 @@ class TestCollationRepair extends \OC\Repair\Collation {
*
* @see \OC\Repair\RepairMimeTypes
*/
class TestRepairCollation extends PHPUnit_Framework_TestCase {
class TestRepairCollation extends \Test\TestCase {
/**
* @var TestCollationRepair
@ -43,7 +43,9 @@ class TestRepairCollation extends PHPUnit_Framework_TestCase {
*/
private $config;
public function setUp() {
protected function setUp() {
parent::setUp();
$this->connection = \OC_DB::getConnection();
$this->config = \OC::$server->getConfig();
if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
@ -57,8 +59,9 @@ class TestRepairCollation extends PHPUnit_Framework_TestCase {
$this->repair = new TestCollationRepair($this->config, $this->connection);
}
public function tearDown() {
protected function tearDown() {
$this->connection->getSchemaManager()->dropTable($this->tableName);
parent::tearDown();
}
public function testCollationConvert() {

View File

@ -11,7 +11,7 @@
*
* @see \OC\Repair\RepairMimeTypes
*/
class TestRepairInnoDB extends PHPUnit_Framework_TestCase {
class TestRepairInnoDB extends \Test\TestCase {
/** @var \OC\RepairStep */
private $repair;
@ -22,7 +22,9 @@ class TestRepairInnoDB extends PHPUnit_Framework_TestCase {
/** @var string */
private $tableName;
public function setUp() {
protected function setUp() {
parent::setUp();
$this->connection = \OC_DB::getConnection();
if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
$this->markTestSkipped("Test only relevant on MySql");
@ -35,8 +37,9 @@ class TestRepairInnoDB extends PHPUnit_Framework_TestCase {
$this->repair = new \OC\Repair\InnoDB();
}
public function tearDown() {
protected function tearDown() {
$this->connection->getSchemaManager()->dropTable($this->tableName);
parent::tearDown();
}
public function testInnoDBConvert() {

View File

@ -11,7 +11,7 @@
*
* @see \OC\Repair\RepairLegacyStorages
*/
class TestRepairLegacyStorages extends PHPUnit_Framework_TestCase {
class TestRepairLegacyStorages extends \Test\TestCase {
private $user;
private $repair;
@ -22,7 +22,9 @@ class TestRepairLegacyStorages extends PHPUnit_Framework_TestCase {
private $legacyStorageId;
private $newStorageId;
public function setUp() {
protected function setUp() {
parent::setUp();
$this->config = \OC::$server->getConfig();
$this->connection = \OC_DB::getConnection();
$this->oldDataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/');
@ -30,7 +32,7 @@ class TestRepairLegacyStorages extends PHPUnit_Framework_TestCase {
$this->repair = new \OC\Repair\RepairLegacyStorages($this->config, $this->connection);
}
public function tearDown() {
protected function tearDown() {
\OC_User::deleteUser($this->user);
$sql = 'DELETE FROM `*PREFIX*storages`';
@ -39,6 +41,8 @@ class TestRepairLegacyStorages extends PHPUnit_Framework_TestCase {
$this->connection->executeQuery($sql);
\OCP\Config::setSystemValue('datadirectory', $this->oldDataDir);
$this->config->setAppValue('core', 'repairlegacystoragesdone', 'no');
parent::tearDown();
}
function prepareSettings($dataDir, $userId) {

View File

@ -11,26 +11,29 @@
*
* @see \OC\Repair\RepairMimeTypes
*/
class TestRepairMimeTypes extends PHPUnit_Framework_TestCase {
class TestRepairMimeTypes extends \Test\TestCase {
/** @var \OC\RepairStep */
private $repair;
private $storage;
public function setUp() {
protected function setUp() {
parent::setUp();
$this->storage = new \OC\Files\Storage\Temporary(array());
$this->repair = new \OC\Repair\RepairMimeTypes();
}
public function tearDown() {
protected function tearDown() {
$this->storage->getCache()->clear();
$sql = 'DELETE FROM `*PREFIX*storages` WHERE `id` = ?';
\OC_DB::executeAudited($sql, array($this->storage->getId()));
$this->clearMimeTypes();
DummyFileCache::clearCachedMimeTypes();
parent::tearDown();
}
private function clearMimeTypes() {

View File

@ -8,7 +8,7 @@
use \OC\Security\Certificate;
class CertificateTest extends \PHPUnit_Framework_TestCase {
class CertificateTest extends \Test\TestCase {
/** @var Certificate That contains a valid certificate */
protected $goodCertificate;
@ -17,7 +17,9 @@ class CertificateTest extends \PHPUnit_Framework_TestCase {
/** @var Certificate That contains an expired certificate */
protected $expiredCertificate;
function setUp() {
protected function setUp() {
parent::setUp();
$goodCertificate = file_get_contents(__DIR__ . '/../../data/certificates/goodCertificate.crt');
$this->goodCertificate = new Certificate($goodCertificate, 'GoodCertificate');
$badCertificate = file_get_contents(__DIR__ . '/../../data/certificates/badCertificate.crt');

View File

@ -17,7 +17,9 @@ class CertificateManagerTest extends \Test\TestCase {
/** @var \OC\User\User */
private $user;
function setUp() {
protected function setUp() {
parent::setUp();
$this->username = $this->getUniqueID('', 20);
OC_User::createUser($this->username, $this->getUniqueID('', 20));
@ -31,8 +33,9 @@ class CertificateManagerTest extends \Test\TestCase {
$this->certificateManager = new CertificateManager($this->user);
}
function tearDown() {
protected function tearDown() {
\OC_User::deleteUser($this->username);
parent::tearDown();
}
protected function assertEqualsArrays($expected, $actual) {

View File

@ -8,7 +8,7 @@
use \OC\Security\Crypto;
class CryptoTest extends \PHPUnit_Framework_TestCase {
class CryptoTest extends \Test\TestCase {
public function defaultEncryptionProvider()
{
@ -23,6 +23,7 @@ class CryptoTest extends \PHPUnit_Framework_TestCase {
protected $crypto;
protected function setUp() {
parent::setUp();
$this->crypto = new Crypto(\OC::$server->getConfig(), \OC::$server->getSecureRandom());
}

View File

@ -8,7 +8,7 @@
use \OC\Security\SecureRandom;
class SecureRandomTest extends \PHPUnit_Framework_TestCase {
class SecureRandomTest extends \Test\TestCase {
public function stringGenerationProvider() {
return array(
@ -34,6 +34,7 @@ class SecureRandomTest extends \PHPUnit_Framework_TestCase {
protected $rng;
protected function setUp() {
parent::setUp();
$this->rng = new \OC\Security\SecureRandom();
}

View File

@ -8,7 +8,7 @@
use \OC\Security\StringUtils;
class StringUtilsTest extends \PHPUnit_Framework_TestCase {
class StringUtilsTest extends \Test\TestCase {
public function dataProvider()
{

View File

@ -10,7 +10,8 @@
namespace Test\Session;
class Memory extends Session {
public function setUp() {
protected function setUp() {
parent::setUp();
$this->instance = new \OC\Session\Memory(uniqid());
}
}

View File

@ -9,14 +9,15 @@
namespace Test\Session;
abstract class Session extends \PHPUnit_Framework_TestCase {
abstract class Session extends \Test\TestCase {
/**
* @var \OC\Session\Session
*/
protected $instance;
public function tearDown() {
protected function tearDown() {
$this->instance->clear();
parent::tearDown();
}
public function testNotExistsEmpty() {

View File

@ -19,7 +19,7 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
class Test_Share_Helper extends PHPUnit_Framework_TestCase {
class Test_Share_Helper extends \Test\TestCase {
public function expireDateProvider() {
return array(

View File

@ -19,7 +19,7 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
class Test_Share_Search extends \PHPUnit_Framework_TestCase {
class Test_Share_Search extends \Test\TestCase {
public function testSort() {
$search = 'lin';
$sorter = new \OC\Share\SearchResultSorter($search, 'foobar');

View File

@ -19,7 +19,7 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
class Test_Share extends Test\TestCase {
class Test_Share extends \Test\TestCase {
protected $itemType;
protected $userBackend;
@ -37,6 +37,7 @@ class Test_Share extends Test\TestCase {
protected function setUp() {
parent::setUp();
OC_User::clearBackends();
OC_User::useBackend('dummy');
$this->user1 = $this->getUniqueID('user1_');
@ -81,6 +82,7 @@ class Test_Share extends Test\TestCase {
$query = OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `item_type` = ?');
$query->execute(array('test'));
OC_Appconfig::setValue('core', 'shareapi_allow_resharing', $this->resharing);
parent::tearDown();
}

View File

@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
class Test_ResourceLocator extends PHPUnit_Framework_TestCase {
class Test_ResourceLocator extends \Test\TestCase {
/**
* @param string $theme

View File

@ -9,7 +9,7 @@
namespace Test\User;
class Manager extends \PHPUnit_Framework_TestCase {
class Manager extends \Test\TestCase {
public function testUserExistsSingleBackendExists() {
/**
* @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend

View File

@ -12,7 +12,7 @@ namespace Test\User;
use OC\Session\Memory;
use OC\User\User;
class Session extends \PHPUnit_Framework_TestCase {
class Session extends \Test\TestCase {
public function testGetUser() {
$session = $this->getMock('\OC\Session\Memory', array(), array(''));
$session->expects($this->once())

View File

@ -12,7 +12,7 @@ namespace Test\User;
use OC\AllConfig;
use OC\Hooks\PublicEmitter;
class User extends \PHPUnit_Framework_TestCase {
class User extends \Test\TestCase {
public function testDisplayName() {
/**
* @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend