Merge pull request #19574 from owncloud/fix-sharing-tests-assuming-empty-share-table

Clear the shares after the test like storages and files
This commit is contained in:
Thomas Müller 2015-10-05 11:00:34 +02:00
commit 34951efed6
1 changed files with 23 additions and 12 deletions

View File

@ -24,6 +24,7 @@ namespace Test;
use OC\Command\QueueBus; use OC\Command\QueueBus;
use OC\Files\Filesystem; use OC\Files\Filesystem;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Security\ISecureRandom; use OCP\Security\ISecureRandom;
abstract class TestCase extends \PHPUnit_Framework_TestCase { abstract class TestCase extends \PHPUnit_Framework_TestCase {
@ -129,9 +130,11 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase {
public static function tearDownAfterClass() { public static function tearDownAfterClass() {
$dataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data-autotest'); $dataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data-autotest');
$queryBuilder = \OC::$server->getDatabaseConnection()->getQueryBuilder();
self::tearDownAfterClassCleanStorages(); self::tearDownAfterClassCleanShares($queryBuilder);
self::tearDownAfterClassCleanFileCache(); self::tearDownAfterClassCleanStorages($queryBuilder);
self::tearDownAfterClassCleanFileCache($queryBuilder);
self::tearDownAfterClassCleanStrayDataFiles($dataDir); self::tearDownAfterClassCleanStrayDataFiles($dataDir);
self::tearDownAfterClassCleanStrayHooks(); self::tearDownAfterClassCleanStrayHooks();
self::tearDownAfterClassCleanStrayLocks(); self::tearDownAfterClassCleanStrayLocks();
@ -139,26 +142,34 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase {
parent::tearDownAfterClass(); parent::tearDownAfterClass();
} }
/**
* Remove all entries from the share table
*
* @param IQueryBuilder $queryBuilder
*/
static protected function tearDownAfterClassCleanShares(IQueryBuilder $queryBuilder) {
$queryBuilder->delete('share')
->execute();
}
/** /**
* Remove all entries from the storages table * Remove all entries from the storages table
* *
* @throws \OC\DatabaseException * @param IQueryBuilder $queryBuilder
*/ */
static protected function tearDownAfterClassCleanStorages() { static protected function tearDownAfterClassCleanStorages(IQueryBuilder $queryBuilder) {
$sql = 'DELETE FROM `*PREFIX*storages`'; $queryBuilder->delete('storages')
$query = \OC_DB::prepare($sql); ->execute();
$query->execute();
} }
/** /**
* Remove all entries from the filecache table * Remove all entries from the filecache table
* *
* @throws \OC\DatabaseException * @param IQueryBuilder $queryBuilder
*/ */
static protected function tearDownAfterClassCleanFileCache() { static protected function tearDownAfterClassCleanFileCache(IQueryBuilder $queryBuilder) {
$sql = 'DELETE FROM `*PREFIX*filecache`'; $queryBuilder->delete('filecache')
$query = \OC_DB::prepare($sql); ->execute();
$query->execute();
} }
/** /**