Browse Source

fix unit tests

tags/v8.0.0alpha1
Bjoern Schiessle 10 years ago
parent
commit
72319bbc98
2 changed files with 22 additions and 5 deletions
  1. 20
    3
      tests/lib/share/backend.php
  2. 2
    2
      tests/lib/share/share.php

+ 20
- 3
tests/lib/share/backend.php View File

@@ -38,19 +38,36 @@ class Test_Share_Backend implements OCP\Share_Backend {

public function generateTarget($itemSource, $shareWith, $exclude = null) {
// Always make target be test.txt to cause conflicts
$target = 'test.txt';
if (isset($exclude)) {

if (substr($itemSource, 0, strlen('test')) !== 'test') {
$target = "test.txt";
} else {
$target = $itemSource;
}


$shares = \OCP\Share::getItemsSharedWithUser('test', $shareWith);

$knownTargets = array();
foreach ($shares as $share) {
$knownTargets[] = $share['item_target'];
}


if (in_array($target, $knownTargets)) {
$pos = strrpos($target, '.');
$name = substr($target, 0, $pos);
$ext = substr($target, $pos);
$append = '';
$i = 1;
while (in_array($name.$append.$ext, $exclude)) {
while (in_array($name.$append.$ext, $knownTargets)) {
$append = $i;
$i++;
}
$target = $name.$append.$ext;

}

return $target;
}


+ 2
- 2
tests/lib/share/share.php View File

@@ -48,8 +48,8 @@ class Test_Share extends PHPUnit_Framework_TestCase {
OC_User::setUserId($this->user1);
OC_Group::clearBackends();
OC_Group::useBackend(new OC_Group_Dummy);
$this->group1 = uniqid('group_');
$this->group2 = uniqid('group_');
$this->group1 = uniqid('group1_');
$this->group2 = uniqid('group2_');
OC_Group::createGroup($this->group1);
OC_Group::createGroup($this->group2);
OC_Group::addToGroup($this->user1, $this->group1);

Loading…
Cancel
Save