|
|
|
|
@ -30,21 +30,23 @@ class Test_Files_Sharing_Updater extends \PHPUnit_Framework_TestCase { |
|
|
|
|
// FIXME: DIRTY HACK - TODO: find tests, that don't clean up and fix it there |
|
|
|
|
$this->tearDown(); |
|
|
|
|
|
|
|
|
|
$addShares = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (`file_source`, `id`, `item_type`, `uid_owner`) VALUES (?, ?, \'file\', 1)'); |
|
|
|
|
$shares = array(1, 2, 3); |
|
|
|
|
foreach($shares as $share) { |
|
|
|
|
// the number is used as item_source and id |
|
|
|
|
$addShares->execute(array($share, $share)); |
|
|
|
|
} |
|
|
|
|
// add items except one - because this is the test case for the broken share table |
|
|
|
|
$addItems = \OC_DB::prepare('INSERT INTO `*PREFIX*filecache` (`fileid`, `storage`, `path_hash`, ' . |
|
|
|
|
'`parent`, `mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`) ' . |
|
|
|
|
'VALUES (?, 1, ?, 1, 1, 1, 1, 1, 1)'); |
|
|
|
|
$items = array(1, 3); |
|
|
|
|
$fileIds = array(); |
|
|
|
|
foreach($items as $item) { |
|
|
|
|
// the number is used as file_id and path_hash |
|
|
|
|
$addItems->execute(array($item, $item)); |
|
|
|
|
$fileIds[] = \OC_DB::insertId('*PREFIX*filecache'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$addShares = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (`file_source`, `id`, `item_type`, `uid_owner`) VALUES (?, ?, \'file\', 1)'); |
|
|
|
|
// the number is used as item_source and id |
|
|
|
|
$addShares->execute(array(1, $fileIds[0])); |
|
|
|
|
$addShares->execute(array(2, 200)); // id of "deleted" file |
|
|
|
|
$addShares->execute(array(3, $fileIds[1])); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function tearDown() { |
|
|
|
|
@ -76,8 +78,8 @@ class Test_Files_Sharing_Updater extends \PHPUnit_Framework_TestCase { |
|
|
|
|
$result = $countShares->execute()->fetchOne(); |
|
|
|
|
$this->assertEquals(2, $result); |
|
|
|
|
|
|
|
|
|
// check if the share of file '2' is removed as there is no entry for this in filecache table |
|
|
|
|
$countShares = \OC_DB::prepare('SELECT COUNT(`id`) FROM `*PREFIX*share` WHERE `file_source` = 2'); |
|
|
|
|
// check if the share of file '200' is removed as there is no entry for this in filecache table |
|
|
|
|
$countShares = \OC_DB::prepare('SELECT COUNT(`id`) FROM `*PREFIX*share` WHERE `file_source` = 200'); |
|
|
|
|
$result = $countShares->execute()->fetchOne(); |
|
|
|
|
$this->assertEquals(0, $result); |
|
|
|
|
|
|
|
|
|
|