summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-05-19 15:31:43 +0200
committerVincent Petry <pvince81@owncloud.com>2016-05-19 15:31:43 +0200
commit61b3260ebdf9e5756719485416381fdcf4b2f589 (patch)
tree979e9dd9166368b5c95cf28713955cfa455e6c95
parent6ace14b6ad34821c8cf51b4854aa624c116c3c9e (diff)
parentbae4118b4fe08c22cf3a12236705d09423a37b8b (diff)
downloadnextcloud-server-61b3260ebdf9e5756719485416381fdcf4b2f589.tar.gz
nextcloud-server-61b3260ebdf9e5756719485416381fdcf4b2f589.zip
Merge pull request #24716 from owncloud/fix-test-namespaces-2
Fix test namespaces [files-]
-rw-r--r--apps/files_sharing/tests/deleteorphanedsharesjobtest.php2
-rw-r--r--apps/files_sharing/tests/server2server.php2
-rw-r--r--tests/lib/APITest.php (renamed from tests/lib/api.php)14
-rw-r--r--tests/lib/AllConfigTest.php (renamed from tests/lib/allconfig.php)4
-rw-r--r--tests/lib/AppTest.php (renamed from tests/lib/app.php)15
-rw-r--r--tests/lib/CapabilitiesManagerTest.php (renamed from tests/lib/capabilitiesmanager.php)2
-rw-r--r--tests/lib/ConfigTest.php (renamed from tests/lib/configtests.php)2
-rw-r--r--tests/lib/ContactsManagerTest.php (renamed from tests/lib/contactsmanager.php)5
-rw-r--r--tests/lib/ErrorHandlerTest.php (renamed from tests/lib/errorHandler.php)4
-rw-r--r--tests/lib/HTTPHelperTest.php (renamed from tests/lib/httphelper.php)4
-rw-r--r--tests/lib/HelperStorageTest.php (renamed from tests/lib/helperstorage.php)4
-rw-r--r--tests/lib/ImageTest.php (renamed from tests/lib/image.php)6
-rw-r--r--tests/lib/LegacyHelperTest.php (renamed from tests/lib/helper.php)6
-rw-r--r--tests/lib/NaturalSortTest.php (renamed from tests/lib/naturalsort.php)4
-rw-r--r--tests/lib/RepairStepTest.php (renamed from tests/lib/RepairTest.php)2
-rw-r--r--tests/lib/SetupTest.php (renamed from tests/lib/setup.php)18
-rw-r--r--tests/lib/StreamWrappersTest.php (renamed from tests/lib/streamwrappers.php)8
-rw-r--r--tests/lib/TagsTest.php (renamed from tests/lib/tags.php)36
-rw-r--r--tests/lib/TemplateFunctionsTest.php (renamed from tests/lib/template.php)8
-rw-r--r--tests/lib/UpdaterTest.php (renamed from tests/lib/updater.php)3
-rw-r--r--tests/lib/UrlGeneratorTest.php (renamed from tests/lib/urlGenerator.php)6
-rw-r--r--tests/lib/UtilCheckServerTest.php (renamed from tests/lib/utilcheckserver.php)6
-rw-r--r--tests/lib/UtilTest.php (renamed from tests/lib/util.php)12
-rw-r--r--tests/lib/appconfig.php6
-rw-r--r--tests/lib/avatarmanagertest.php5
-rw-r--r--tests/lib/avatartest.php19
-rw-r--r--tests/lib/db/DBSchemaTest.php (renamed from tests/lib/dbschema.php)12
-rw-r--r--tests/lib/db/LegacyDBTest.php (renamed from tests/lib/db.php)10
-rw-r--r--tests/lib/files/cache/cache.php3
-rw-r--r--tests/lib/files/node/IntegrationTest.php (renamed from tests/lib/files/node/integration.php)2
-rw-r--r--tests/lib/files/objectstore/SwiftTest.php (renamed from tests/lib/files/objectstore/swift.php)14
-rw-r--r--tests/lib/files/objectstore/noopscanner.php2
-rw-r--r--tests/lib/files/pathverificationtest.php2
-rw-r--r--tests/lib/files/storage/wrapper/availability.php1
-rw-r--r--tests/lib/files/type/DetectionTest.php (renamed from tests/lib/files/type/detection.php)0
-rw-r--r--tests/lib/files/type/loadertest.php2
-rw-r--r--tests/lib/files/view.php4
-rw-r--r--tests/lib/group/LegacyGroupTest.php (renamed from tests/lib/group.php)7
-rw-r--r--tests/lib/group/backend.php4
-rw-r--r--tests/lib/group/database.php6
-rw-r--r--tests/lib/group/dummy.php6
-rw-r--r--tests/lib/group/metadatatest.php (renamed from tests/lib/group/metadata.php)2
-rw-r--r--tests/lib/http/client/clientservicetest.php4
-rw-r--r--tests/lib/http/client/clienttest.php3
-rw-r--r--tests/lib/http/client/responsetest.php3
-rw-r--r--tests/lib/integritycheck/checkertest.php1
-rw-r--r--tests/lib/integritycheck/helpers/EnvironmentHelperTest.php2
-rw-r--r--tests/lib/log/OwncloudTest.php (renamed from tests/lib/log/owncloud.php)0
-rw-r--r--tests/lib/mail/MailerTest.php (renamed from tests/lib/mail/mailer.php)4
-rw-r--r--tests/lib/mail/MessageTest.php (renamed from tests/lib/mail/message.php)3
-rw-r--r--tests/lib/memcache/FactoryTest.php (renamed from tests/lib/memcache/factory.php)2
-rw-r--r--tests/lib/ocs/PrivatedataTest.php (renamed from tests/lib/ocs/privatedata.php)8
-rw-r--r--tests/lib/ocsclienttest.php2
-rw-r--r--tests/lib/publicnamespace/ContactsTest.php (renamed from tests/lib/public/contacts.php)30
-rw-r--r--tests/lib/publicnamespace/OCPConfigTest.php (renamed from tests/lib/public/ocpconfig.php)4
-rw-r--r--tests/lib/publicnamespace/UtilTest.php (renamed from tests/lib/public/util.php)7
-rw-r--r--tests/lib/repair/RepairCollationTest.php (renamed from tests/lib/repair/repaircollation.php)5
-rw-r--r--tests/lib/security/CertificateManagerTest.php (renamed from tests/lib/security/certificatemanager.php)2
-rw-r--r--tests/lib/security/CertificateTest.php (renamed from tests/lib/security/certificate.php)12
-rw-r--r--tests/lib/security/CredentialsManagerTest.php (renamed from tests/lib/security/credentialsmanager.php)2
-rw-r--r--tests/lib/security/CryptoTest.php (renamed from tests/lib/security/crypto.php)2
-rw-r--r--tests/lib/security/HasherTest.php (renamed from tests/lib/security/hasher.php)2
-rw-r--r--tests/lib/security/SecureRandomTest.php (renamed from tests/lib/security/securerandom.php)2
-rw-r--r--tests/lib/security/TrustedDomainHelperTest.php (renamed from tests/lib/security/trusteddomainhelper.php)2
-rw-r--r--tests/lib/security/csp/ContentSecurityPolicyManagerTest.php3
-rw-r--r--tests/lib/security/csrf/CsrfTokenGeneratorTest.php2
-rw-r--r--tests/lib/security/csrf/CsrfTokenManagerTest.php2
-rw-r--r--tests/lib/security/csrf/CsrfTokenTest.php2
-rw-r--r--tests/lib/security/csrf/tokenstorage/SessionStorageTest.php2
-rw-r--r--tests/lib/share/MailNotificationsTest.php14
-rw-r--r--tests/lib/share/backend.php4
-rw-r--r--tests/lib/share/helper.php6
-rw-r--r--tests/lib/share/searchresultsorter.php4
-rw-r--r--tests/lib/share/share.php490
-rw-r--r--tests/lib/updater/VersionCheckTest.php (renamed from tests/lib/updater/versioncheck.php)2
-rw-r--r--tests/lib/user/avataruserdummy.php6
-rw-r--r--tests/lib/user/backend.php4
-rw-r--r--tests/lib/user/database.php4
-rw-r--r--tests/lib/user/dummy.php4
-rw-r--r--tests/lib/user/user.php6
80 files changed, 529 insertions, 408 deletions
diff --git a/apps/files_sharing/tests/deleteorphanedsharesjobtest.php b/apps/files_sharing/tests/deleteorphanedsharesjobtest.php
index 353520bd604..c9aea60d255 100644
--- a/apps/files_sharing/tests/deleteorphanedsharesjobtest.php
+++ b/apps/files_sharing/tests/deleteorphanedsharesjobtest.php
@@ -154,7 +154,7 @@ class DeleteOrphanedSharesJobTest extends \Test\TestCase {
public function testKeepNonFileShares() {
$this->loginAsUser($this->user1);
- \OCP\Share::registerBackend('test', 'Test_Share_Backend');
+ \OCP\Share::registerBackend('test', 'Test\Share\Backend');
$this->assertTrue(
\OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ),
diff --git a/apps/files_sharing/tests/server2server.php b/apps/files_sharing/tests/server2server.php
index 1d047916ca9..1c8b5ed7a17 100644
--- a/apps/files_sharing/tests/server2server.php
+++ b/apps/files_sharing/tests/server2server.php
@@ -51,7 +51,7 @@ class Test_Files_Sharing_S2S_OCS_API extends TestCase {
parent::setUp();
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- \OCP\Share::registerBackend('test', 'Test_Share_Backend');
+ \OCP\Share::registerBackend('test', 'Test\Share\Backend');
$config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()->getMock();
diff --git a/tests/lib/api.php b/tests/lib/APITest.php
index 1d1f97c4942..d3ab6db9e4b 100644
--- a/tests/lib/api.php
+++ b/tests/lib/APITest.php
@@ -6,7 +6,9 @@
* See the COPYING-README file.
*/
-class Test_API extends \Test\TestCase {
+namespace Test;
+
+class APITest extends \Test\TestCase {
// Helps build a response variable
@@ -14,7 +16,7 @@ class Test_API extends \Test\TestCase {
* @param string $message
*/
function buildResponse($shipped, $data, $code, $message=null) {
- $resp = new OC_OCS_Result($data, $code, $message);
+ $resp = new \OC_OCS_Result($data, $code, $message);
$resp->addHeader('KEY', 'VALUE');
return [
'shipped' => $shipped,
@@ -26,13 +28,13 @@ class Test_API extends \Test\TestCase {
// Validate details of the result
/**
- * @param OC_OCS_Result $result
+ * @param \OC_OCS_Result $result
*/
function checkResult($result, $success) {
// Check response is of correct type
$this->assertInstanceOf('OC_OCS_Result', $result);
// Check if it succeeded
- /** @var $result OC_OCS_Result */
+ /** @var $result \OC_OCS_Result */
$this->assertEquals($success, $result->succeeded());
}
@@ -108,7 +110,7 @@ class Test_API extends \Test\TestCase {
// Test merging one success result
$response = $this->buildResponse(true, $data1, $statusCode);
- $result = OC_API::mergeResponses([$response]);
+ $result = \OC_API::mergeResponses([$response]);
$this->assertEquals($response['response'], $result);
$this->checkResult($result, $succeeded);
}
@@ -170,7 +172,7 @@ class Test_API extends \Test\TestCase {
));
// Two shipped success results
- $result = OC_API::mergeResponses(array(
+ $result = \OC_API::mergeResponses(array(
$this->buildResponse($shipped1, $data1, $statusCode1, "message1"),
$this->buildResponse($shipped2, $data2, $statusCode2, "message2"),
));
diff --git a/tests/lib/allconfig.php b/tests/lib/AllConfigTest.php
index 869bf9b8d66..4f8b0658b80 100644
--- a/tests/lib/allconfig.php
+++ b/tests/lib/AllConfigTest.php
@@ -9,13 +9,13 @@
namespace Test;
/**
- * Class TestAllConfig
+ * Class AllConfigTest
*
* @group DB
*
* @package Test
*/
-class TestAllConfig extends \Test\TestCase {
+class AllConfigTest extends \Test\TestCase {
/** @var \OCP\IDBConnection */
protected $connection;
diff --git a/tests/lib/app.php b/tests/lib/AppTest.php
index e7255ad955a..2e5b6f74ab7 100644
--- a/tests/lib/app.php
+++ b/tests/lib/AppTest.php
@@ -7,12 +7,15 @@
* See the COPYING-README file.
*/
+namespace Test;
+use OCP\IAppConfig;
+
/**
- * Class Test_App
+ * Class AppTest
*
* @group DB
*/
-class Test_App extends \Test\TestCase {
+class AppTest extends \Test\TestCase {
const TEST_USER1 = 'user1';
const TEST_USER2 = 'user2';
@@ -267,7 +270,7 @@ class Test_App extends \Test\TestCase {
* @dataProvider appVersionsProvider
*/
public function testIsAppCompatible($ocVersion, $appInfo, $expectedResult) {
- $this->assertEquals($expectedResult, OC_App::isAppCompatible($ocVersion, $appInfo));
+ $this->assertEquals($expectedResult, \OC_App::isAppCompatible($ocVersion, $appInfo));
}
/**
@@ -280,7 +283,7 @@ class Test_App extends \Test\TestCase {
'requiremin' => '6',
'requiremax' => '6',
);
- $this->assertTrue(OC_App::isAppCompatible($ocVersion, $appInfo));
+ $this->assertTrue(\OC_App::isAppCompatible($ocVersion, $appInfo));
}
/**
@@ -478,9 +481,9 @@ class Test_App extends \Test\TestCase {
/**
* Register an app config mock for testing purposes.
*
- * @param $appConfig app config mock
+ * @param IAppConfig $appConfig app config mock
*/
- private function registerAppConfig($appConfig) {
+ private function registerAppConfig(IAppConfig $appConfig) {
\OC::$server->registerService('AppConfig', function ($c) use ($appConfig) {
return $appConfig;
});
diff --git a/tests/lib/capabilitiesmanager.php b/tests/lib/CapabilitiesManagerTest.php
index b5dac80ee51..d4dd52d07f1 100644
--- a/tests/lib/capabilitiesmanager.php
+++ b/tests/lib/CapabilitiesManagerTest.php
@@ -21,8 +21,6 @@
namespace Test;
-use OC\CapabilitiesManager;
-
class CapabilitiesManagerTest extends TestCase {
/**
diff --git a/tests/lib/configtests.php b/tests/lib/ConfigTest.php
index c0251e693c6..74dcdc192ce 100644
--- a/tests/lib/configtests.php
+++ b/tests/lib/ConfigTest.php
@@ -8,7 +8,7 @@
namespace Test;
-class ConfigTests extends TestCase {
+class ConfigTest extends TestCase {
const TESTCONTENT = '<?php $CONFIG=array("foo"=>"bar", "beers" => array("Appenzeller", "Guinness", "Kölsch"), "alcohol_free" => false);';
/** @var array */
diff --git a/tests/lib/contactsmanager.php b/tests/lib/ContactsManagerTest.php
index 39e44cc6302..89a9cb95b97 100644
--- a/tests/lib/contactsmanager.php
+++ b/tests/lib/ContactsManagerTest.php
@@ -1,7 +1,8 @@
<?php
+namespace Test;
-class Test_ContactsManager extends \Test\TestCase {
+class ContactsManagerTest extends \Test\TestCase {
/** @var \OC\ContactsManager */
private $cm;
@@ -206,4 +207,4 @@ class Test_ContactsManager extends \Test\TestCase {
$this->assertTrue($result);
}
-} \ No newline at end of file
+}
diff --git a/tests/lib/errorHandler.php b/tests/lib/ErrorHandlerTest.php
index 726529e83f4..aece7f146f6 100644
--- a/tests/lib/errorHandler.php
+++ b/tests/lib/ErrorHandlerTest.php
@@ -20,7 +20,9 @@
*
*/
-class Test_ErrorHandler extends \Test\TestCase {
+namespace Test;
+
+class ErrorHandlerTest extends \Test\TestCase {
/**
* provide username, password combinations for testRemovePassword
diff --git a/tests/lib/httphelper.php b/tests/lib/HTTPHelperTest.php
index 1d0981ba51b..6d9c4788735 100644
--- a/tests/lib/httphelper.php
+++ b/tests/lib/HTTPHelperTest.php
@@ -6,7 +6,9 @@
* See the COPYING-README file.
*/
-class TestHTTPHelper extends \Test\TestCase {
+namespace Test;
+
+class HTTPHelperTest extends \Test\TestCase {
/** @var \OCP\IConfig*/
private $config;
diff --git a/tests/lib/helperstorage.php b/tests/lib/HelperStorageTest.php
index 3109b509549..e841dbfce18 100644
--- a/tests/lib/helperstorage.php
+++ b/tests/lib/HelperStorageTest.php
@@ -6,12 +6,14 @@
* See the COPYING-README file.
*/
+namespace Test;
+
/**
* Test the storage functions of OC_Helper
*
* @group DB
*/
-class Test_Helper_Storage extends \Test\TestCase {
+class HelperStorageTest extends \Test\TestCase {
/** @var string */
private $user;
/** @var \OC\Files\Storage\Storage */
diff --git a/tests/lib/image.php b/tests/lib/ImageTest.php
index e74c75b48cf..9dba7e3739b 100644
--- a/tests/lib/image.php
+++ b/tests/lib/ImageTest.php
@@ -6,7 +6,11 @@
* See the COPYING-README file.
*/
-class Test_Image extends \Test\TestCase {
+namespace Test;
+
+use OC;
+
+class ImageTest extends \Test\TestCase {
public static function tearDownAfterClass() {
@unlink(OC::$SERVERROOT.'/tests/data/testimage2.png');
@unlink(OC::$SERVERROOT.'/tests/data/testimage2.jpg');
diff --git a/tests/lib/helper.php b/tests/lib/LegacyHelperTest.php
index 89a981e6e23..d8b1a82c271 100644
--- a/tests/lib/helper.php
+++ b/tests/lib/LegacyHelperTest.php
@@ -6,7 +6,11 @@
* See the COPYING-README file.
*/
-class Test_Helper extends \Test\TestCase {
+namespace Test;
+
+use OC_Helper;
+
+class LegacyHelperTest extends \Test\TestCase {
/**
* @dataProvider humanFileSizeProvider
diff --git a/tests/lib/naturalsort.php b/tests/lib/NaturalSortTest.php
index 8fcbc6f5fd3..50c2d0be9f0 100644
--- a/tests/lib/naturalsort.php
+++ b/tests/lib/NaturalSortTest.php
@@ -6,7 +6,9 @@
* See the COPYING-README file.
*/
-class Test_NaturalSort extends \Test\TestCase {
+namespace Test;
+
+class NaturalSortTest extends \Test\TestCase {
/**
* @dataProvider naturalSortDataProvider
diff --git a/tests/lib/RepairTest.php b/tests/lib/RepairStepTest.php
index 9ae1318eb32..3f7a0ce064b 100644
--- a/tests/lib/RepairTest.php
+++ b/tests/lib/RepairStepTest.php
@@ -11,7 +11,7 @@ namespace Test;
use OCP\Migration\IRepairStep;
use Symfony\Component\EventDispatcher\EventDispatcher;
-class TestRepairStep implements IRepairStep {
+class RepairStepTest implements IRepairStep {
private $warning;
public function __construct($warning = false) {
diff --git a/tests/lib/setup.php b/tests/lib/SetupTest.php
index bc78c14008f..e2723efd76a 100644
--- a/tests/lib/setup.php
+++ b/tests/lib/SetupTest.php
@@ -6,23 +6,25 @@
* See the COPYING-README file.
*/
+namespace Test;
+
use OCP\IConfig;
-class Test_OC_Setup extends \Test\TestCase {
+class SetupTest extends \Test\TestCase {
- /** @var IConfig | PHPUnit_Framework_MockObject_MockObject */
+ /** @var IConfig | \PHPUnit_Framework_MockObject_MockObject */
protected $config;
- /** @var \bantu\IniGetWrapper\IniGetWrapper | PHPUnit_Framework_MockObject_MockObject */
+ /** @var \bantu\IniGetWrapper\IniGetWrapper | \PHPUnit_Framework_MockObject_MockObject */
private $iniWrapper;
- /** @var \OCP\IL10N | PHPUnit_Framework_MockObject_MockObject */
+ /** @var \OCP\IL10N | \PHPUnit_Framework_MockObject_MockObject */
private $l10n;
- /** @var \OC_Defaults | PHPUnit_Framework_MockObject_MockObject */
+ /** @var \OC_Defaults | \PHPUnit_Framework_MockObject_MockObject */
private $defaults;
- /** @var \OC\Setup | PHPUnit_Framework_MockObject_MockObject */
+ /** @var \OC\Setup | \PHPUnit_Framework_MockObject_MockObject */
protected $setupClass;
- /** @var \OCP\ILogger | PHPUnit_Framework_MockObject_MockObject */
+ /** @var \OCP\ILogger | \PHPUnit_Framework_MockObject_MockObject */
protected $logger;
- /** @var \OCP\Security\ISecureRandom | PHPUnit_Framework_MockObject_MockObject */
+ /** @var \OCP\Security\ISecureRandom | \PHPUnit_Framework_MockObject_MockObject */
protected $random;
protected function setUp() {
diff --git a/tests/lib/streamwrappers.php b/tests/lib/StreamWrappersTest.php
index 7175683a60b..a378f975fde 100644
--- a/tests/lib/streamwrappers.php
+++ b/tests/lib/StreamWrappersTest.php
@@ -20,12 +20,14 @@
*
*/
+namespace Test;
+
/**
- * Class Test_StreamWrappers
+ * Class StreamWrappersTest
*
* @group DB
*/
-class Test_StreamWrappers extends \Test\TestCase {
+class StreamWrappersTest extends \Test\TestCase {
private static $trashBinStatus;
@@ -54,7 +56,7 @@ class Test_StreamWrappers extends \Test\TestCase {
public function testCloseStream() {
//ensure all basic stream stuff works
- $sourceFile = OC::$SERVERROOT . '/tests/data/lorem.txt';
+ $sourceFile = \OC::$SERVERROOT . '/tests/data/lorem.txt';
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile('.txt');
$file = 'close://' . $tmpFile;
$this->assertTrue(file_exists($file));
diff --git a/tests/lib/tags.php b/tests/lib/TagsTest.php
index 91472d5ceb8..2662c209d2c 100644
--- a/tests/lib/tags.php
+++ b/tests/lib/TagsTest.php
@@ -20,12 +20,14 @@
*
*/
+namespace Test;
+
/**
- * Class Test_Tags
+ * Class TagsTest
*
* @group DB
*/
-class Test_Tags extends \Test\TestCase {
+class TagsTest extends \Test\TestCase {
protected $objectType;
/** @var \OCP\IUser */
@@ -41,12 +43,12 @@ class Test_Tags extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- OC_User::clearBackends();
- OC_User::useBackend('dummy');
+ \OC_User::clearBackends();
+ \OC_User::useBackend('dummy');
$userId = $this->getUniqueID('user_');
\OC::$server->getUserManager()->createUser($userId, 'pass');
- OC_User::setUserId($userId);
- $this->user = new OC\User\User($userId, null);
+ \OC_User::setUserId($userId);
+ $this->user = new \OC\User\User($userId, null);
$this->userSession = $this->getMock('\OCP\IUserSession');
$this->userSession
->expects($this->any())
@@ -54,8 +56,8 @@ class Test_Tags extends \Test\TestCase {
->will($this->returnValue($this->user));
$this->objectType = $this->getUniqueID('type_');
- $this->tagMapper = new OC\Tagging\TagMapper(\OC::$server->getDatabaseConnection());
- $this->tagMgr = new OC\TagManager($this->tagMapper, $this->userSession);
+ $this->tagMapper = new \OC\Tagging\TagMapper(\OC::$server->getDatabaseConnection());
+ $this->tagMgr = new \OC\TagManager($this->tagMapper, $this->userSession);
}
@@ -73,7 +75,7 @@ class Test_Tags extends \Test\TestCase {
->expects($this->any())
->method('getUser')
->will($this->returnValue(null));
- $this->tagMgr = new OC\TagManager($this->tagMapper, $this->userSession);
+ $this->tagMgr = new \OC\TagManager($this->tagMapper, $this->userSession);
$this->assertNull($this->tagMgr->load($this->objectType));
}
@@ -236,7 +238,7 @@ class Test_Tags extends \Test\TestCase {
$this->assertTrue($tagger->rename('Wrok', 'Work'));
$this->assertTrue($tagger->hasTag('Work'));
- $this->assertFalse($tagger->hastag('Wrok'));
+ $this->assertFalse($tagger->hasTag('Wrok'));
$this->assertFalse($tagger->rename('Wrok', 'Work')); // Rename non-existant tag.
$this->assertFalse($tagger->rename('Work', 'Family')); // Collide with existing tag.
}
@@ -284,28 +286,28 @@ class Test_Tags extends \Test\TestCase {
public function testShareTags() {
$testTag = 'TestTag';
- OCP\Share::registerBackend('test', 'Test_Share_Backend');
+ \OCP\Share::registerBackend('test', 'Test\Share\Backend');
$tagger = $this->tagMgr->load('test');
$tagger->tagAs(1, $testTag);
$otherUserId = $this->getUniqueID('user2_');
\OC::$server->getUserManager()->createUser($otherUserId, 'pass');
- OC_User::setUserId($otherUserId);
+ \OC_User::setUserId($otherUserId);
$otherUserSession = $this->getMock('\OCP\IUserSession');
$otherUserSession
->expects($this->any())
->method('getUser')
- ->will($this->returnValue(new OC\User\User($otherUserId, null)));
+ ->will($this->returnValue(new \OC\User\User($otherUserId, null)));
- $otherTagMgr = new OC\TagManager($this->tagMapper, $otherUserSession);
+ $otherTagMgr = new \OC\TagManager($this->tagMapper, $otherUserSession);
$otherTagger = $otherTagMgr->load('test');
$this->assertFalse($otherTagger->hasTag($testTag));
- OC_User::setUserId($this->user->getUID());
- OCP\Share::shareItem('test', 1, OCP\Share::SHARE_TYPE_USER, $otherUserId, \OCP\Constants::PERMISSION_READ);
+ \OC_User::setUserId($this->user->getUID());
+ \OCP\Share::shareItem('test', 1, \OCP\Share::SHARE_TYPE_USER, $otherUserId, \OCP\Constants::PERMISSION_READ);
- OC_User::setUserId($otherUserId);
+ \OC_User::setUserId($otherUserId);
$otherTagger = $otherTagMgr->load('test', array(), true); // Update tags, load shared ones.
$this->assertTrue($otherTagger->hasTag($testTag));
$this->assertContains(1, $otherTagger->getIdsForTag($testTag));
diff --git a/tests/lib/template.php b/tests/lib/TemplateFunctionsTest.php
index 6e62d3955f1..aa3c73d4743 100644
--- a/tests/lib/template.php
+++ b/tests/lib/TemplateFunctionsTest.php
@@ -1,5 +1,4 @@
<?php
-
/**
* ownCloud
*
@@ -20,12 +19,15 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
-class Test_TemplateFunctions extends \Test\TestCase {
+
+namespace Test;
+
+class TemplateFunctionsTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $loader = new \OC\Autoloader([OC::$SERVERROOT . '/lib']);
+ $loader = new \OC\Autoloader([\OC::$SERVERROOT . '/lib']);
$loader->load('OC_Template');
}
diff --git a/tests/lib/updater.php b/tests/lib/UpdaterTest.php
index f97eb3ac139..643a18cc714 100644
--- a/tests/lib/updater.php
+++ b/tests/lib/UpdaterTest.php
@@ -20,8 +20,9 @@
*
*/
-namespace OC;
+namespace Test;
+use OC\Updater;
use OCP\IConfig;
use OCP\ILogger;
use OC\IntegrityCheck\Checker;
diff --git a/tests/lib/urlGenerator.php b/tests/lib/UrlGeneratorTest.php
index 07103225baa..7186c8fad80 100644
--- a/tests/lib/urlGenerator.php
+++ b/tests/lib/UrlGeneratorTest.php
@@ -6,12 +6,14 @@
* See the COPYING-README file.
*/
+namespace Test;
+
/**
- * Class Test_UrlGenerator
+ * Class UrlGeneratorTest
*
* @group DB
*/
-class Test_UrlGenerator extends \Test\TestCase {
+class UrlGeneratorTest extends \Test\TestCase {
/**
* @small
diff --git a/tests/lib/utilcheckserver.php b/tests/lib/UtilCheckServerTest.php
index 94e7fd2f779..b864af6888a 100644
--- a/tests/lib/utilcheckserver.php
+++ b/tests/lib/UtilCheckServerTest.php
@@ -6,18 +6,20 @@
* See the COPYING-README file.
*/
+namespace Test;
+
/**
* Tests for server check functions
*
* @group DB
*/
-class Test_Util_CheckServer extends \Test\TestCase {
+class UtilCheckServerTest extends \Test\TestCase {
private $datadir;
/**
* @param array $systemOptions
- * @return \OCP\IConfig | PHPUnit_Framework_MockObject_MockObject
+ * @return \OCP\IConfig | \PHPUnit_Framework_MockObject_MockObject
*/
protected function getConfig($systemOptions) {
$systemOptions['datadirectory'] = $this->datadir;
diff --git a/tests/lib/util.php b/tests/lib/UtilTest.php
index 4d788353881..7da7db0291c 100644
--- a/tests/lib/util.php
+++ b/tests/lib/UtilTest.php
@@ -1,12 +1,16 @@
<?php
-
/**
* Copyright (c) 2012 Lukas Reschke <lukas@statuscode.ch>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
-class Test_Util extends \Test\TestCase {
+
+namespace Test;
+
+use OC_Util;
+
+class UtilTest extends \Test\TestCase {
public function testGetVersion() {
$version = \OCP\Util::getVersion();
$this->assertTrue(is_array($version));
@@ -46,7 +50,7 @@ class Test_Util extends \Test\TestCase {
}
/**
- * @expectedException Exception
+ * @expectedException \Exception
*/
function testFormatDateWithInvalidTZ() {
OC_Util::formatDate(1350129205, false, 'Mordor/Barad-dûr');
@@ -283,7 +287,7 @@ class Test_Util extends \Test\TestCase {
* @dataProvider defaultAppsProvider
*/
function testDefaultApps($defaultAppConfig, $expectedPath, $enabledApps) {
- $oldDefaultApps = \OCP\Config::getSystemValue('core', 'defaultapp', '');
+ $oldDefaultApps = \OCP\Config::getSystemValue('defaultapp', '');
// CLI is doing messy stuff with the webroot, so need to work it around
$oldWebRoot = \OC::$WEBROOT;
\OC::$WEBROOT = '';
diff --git a/tests/lib/appconfig.php b/tests/lib/appconfig.php
index 64f0f80e045..12d9728c868 100644
--- a/tests/lib/appconfig.php
+++ b/tests/lib/appconfig.php
@@ -7,16 +7,14 @@
* See the COPYING-README file.
*/
-namespace Test\Lib;
-
-use Test\TestCase;
+namespace Test;
/**
* Class AppConfig
*
* @group DB
*
- * @package Test\Lib
+ * @package Test
*/
class AppConfig extends TestCase {
/** @var \OCP\IAppConfig */
diff --git a/tests/lib/avatarmanagertest.php b/tests/lib/avatarmanagertest.php
index f5cdd99176d..2dd6ff34923 100644
--- a/tests/lib/avatarmanagertest.php
+++ b/tests/lib/avatarmanagertest.php
@@ -18,6 +18,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
+
+namespace Test;
+
use OC\AvatarManager;
use Test\Traits\UserTrait;
use Test\Traits\MountProviderTrait;
@@ -48,7 +51,7 @@ class AvatarManagerTest extends \Test\TestCase {
}
/**
- * @expectedException Exception
+ * @expectedException \Exception
* @expectedExceptionMessage user does not exist
*/
public function testGetAvatarInvalidUser() {
diff --git a/tests/lib/avatartest.php b/tests/lib/avatartest.php
index b0ab4cb8b5c..0a00f5d5614 100644
--- a/tests/lib/avatartest.php
+++ b/tests/lib/avatartest.php
@@ -1,5 +1,4 @@
<?php
-
/**
* Copyright (c) 2013 Christopher Schäpers <christopher@schaepers.it>
* This file is licensed under the Affero General Public License version 3 or
@@ -7,23 +6,25 @@
* See the COPYING-README file.
*/
+namespace Test;
+
use OCP\Files\Folder;
class AvatarTest extends \Test\TestCase {
- /** @var Folder | PHPUnit_Framework_MockObject_MockObject */
+ /** @var Folder | \PHPUnit_Framework_MockObject_MockObject */
private $folder;
/** @var \OC\Avatar */
private $avatar;
- /** @var \OC\User\User | PHPUnit_Framework_MockObject_MockObject $user */
+ /** @var \OC\User\User | \PHPUnit_Framework_MockObject_MockObject $user */
private $user;
public function setUp() {
parent::setUp();
$this->folder = $this->getMock('\OCP\Files\Folder');
- /** @var \OCP\IL10N | PHPUnit_Framework_MockObject_MockObject $l */
+ /** @var \OCP\IL10N | \PHPUnit_Framework_MockObject_MockObject $l */
$l = $this->getMock('\OCP\IL10N');
$l->method('t')->will($this->returnArgument(0));
$this->user = $this->getMockBuilder('\OC\User\User')->disableOriginalConstructor()->getMock();
@@ -41,7 +42,7 @@ class AvatarTest extends \Test\TestCase {
['avatar.128.jpg', true],
]));
- $expected = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
+ $expected = new \OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
$file = $this->getMock('\OCP\Files\File');
$file->method('getContent')->willReturn($expected->data());
@@ -56,7 +57,7 @@ class AvatarTest extends \Test\TestCase {
['avatar.jpg', true],
]));
- $expected = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
+ $expected = new \OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
$file = $this->getMock('\OCP\Files\File');
$file->method('getContent')->willReturn($expected->data());
@@ -72,8 +73,8 @@ class AvatarTest extends \Test\TestCase {
['avatar.32.png', false],
]));
- $expected = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
- $expected2 = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
+ $expected = new \OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
+ $expected2 = new \OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
$expected2->resize(32);
$file = $this->getMock('\OCP\Files\File');
@@ -157,7 +158,7 @@ class AvatarTest extends \Test\TestCase {
->with('avatar.png')
->willReturn($newFile);
- $image = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
+ $image = new \OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
$newFile->expects($this->once())
->method('putContent')
->with($image->data());
diff --git a/tests/lib/dbschema.php b/tests/lib/db/DBSchemaTest.php
index 11eacbf397f..284fc532c2a 100644
--- a/tests/lib/dbschema.php
+++ b/tests/lib/db/DBSchemaTest.php
@@ -1,5 +1,4 @@
<?php
-
/**
* Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
@@ -7,14 +6,17 @@
* See the COPYING-README file.
*/
+namespace Test\DB;
+
+use OC_DB;
use OCP\Security\ISecureRandom;
/**
- * Class Test_DBSchema
+ * Class DBSchemaTest
*
* @group DB
*/
-class Test_DBSchema extends \Test\TestCase {
+class DBSchemaTest extends \Test\TestCase {
protected $schema_file = 'static://test_db_scheme';
protected $schema_file2 = 'static://test_db_scheme2';
protected $table1;
@@ -23,8 +25,8 @@ class Test_DBSchema extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $dbfile = OC::$SERVERROOT.'/tests/data/db_structure.xml';
- $dbfile2 = OC::$SERVERROOT.'/tests/data/db_structure2.xml';
+ $dbfile = \OC::$SERVERROOT.'/tests/data/db_structure.xml';
+ $dbfile2 = \OC::$SERVERROOT.'/tests/data/db_structure2.xml';
$r = '_' . \OC::$server->getSecureRandom()->
generate(4, ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS) . '_';
diff --git a/tests/lib/db.php b/tests/lib/db/LegacyDBTest.php
index 88c9ee75b3b..7aeeb3dd1f9 100644
--- a/tests/lib/db.php
+++ b/tests/lib/db/LegacyDBTest.php
@@ -6,12 +6,16 @@
* See the COPYING-README file.
*/
+namespace Test\DB;
+
+use OC_DB;
+
/**
- * Class Test_DB
+ * Class LegacyDBTest
*
* @group DB
*/
-class Test_DB extends \Test\TestCase {
+class LegacyDBTest extends \Test\TestCase {
protected $backupGlobals = FALSE;
protected static $schema_file = 'static://test_db_scheme';
@@ -45,7 +49,7 @@ class Test_DB extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $dbFile = OC::$SERVERROOT.'/tests/data/db_structure.xml';
+ $dbFile = \OC::$SERVERROOT.'/tests/data/db_structure.xml';
$r = $this->getUniqueID('_', 4).'_';
$content = file_get_contents( $dbFile );
diff --git a/tests/lib/files/cache/cache.php b/tests/lib/files/cache/cache.php
index 54aa7ad789a..3201e2d03fe 100644
--- a/tests/lib/files/cache/cache.php
+++ b/tests/lib/files/cache/cache.php
@@ -8,7 +8,6 @@
namespace Test\Files\Cache;
-use PHPUnit_Framework_MockObject_MockObject;
class LongId extends \OC\Files\Storage\Temporary {
public function getId() {
@@ -491,7 +490,7 @@ class Cache extends \Test\TestCase {
$folderWith0308 = "\x53\x63\x68\x6f\xcc\x88\x6e";
/**
- * @var \OC\Files\Cache\Cache | PHPUnit_Framework_MockObject_MockObject $cacheMock
+ * @var \OC\Files\Cache\Cache | \PHPUnit_Framework_MockObject_MockObject $cacheMock
*/
$cacheMock = $this->getMock('\OC\Files\Cache\Cache', array('normalize'), array($this->storage), '', true);
diff --git a/tests/lib/files/node/integration.php b/tests/lib/files/node/IntegrationTest.php
index addc7e98f48..e11f9bca4ea 100644
--- a/tests/lib/files/node/integration.php
+++ b/tests/lib/files/node/IntegrationTest.php
@@ -20,7 +20,7 @@ use OC\User\User;
*
* @package Test\Files\Node
*/
-class IntegrationTests extends \Test\TestCase {
+class IntegrationTest extends \Test\TestCase {
/**
* @var \OC\Files\Node\Root $root
*/
diff --git a/tests/lib/files/objectstore/swift.php b/tests/lib/files/objectstore/SwiftTest.php
index a63f5844145..4731936627d 100644
--- a/tests/lib/files/objectstore/swift.php
+++ b/tests/lib/files/objectstore/SwiftTest.php
@@ -18,22 +18,22 @@
*
*/
-namespace OCA\ObjectStore\Tests\Unit;
+namespace Test\Files\Cache\ObjectStore;
use OC\Files\ObjectStore\ObjectStoreStorage;
-use OC\Files\ObjectStore\Swift as ObjectStoreToTest;
+use OC\Files\ObjectStore\Swift;
/**
- * Class Swift
+ * Class SwiftTest
*
* @group DB
*
- * @package OCA\ObjectStore\Tests\Unit
+ * @package Test\Files\Cache\ObjectStore
*/
-class Swift extends \Test\Files\Storage\Storage {
+class SwiftTest extends \Test\Files\Storage\Storage {
/**
- * @var ObjectStoreToTest
+ * @var Swift
*/
private $objectStorage;
@@ -63,7 +63,7 @@ class Swift extends \Test\Files\Storage\Storage {
\OC_User::setUserId('test');
$config = \OC::$server->getConfig()->getSystemValue('objectstore');
- $this->objectStorage = new ObjectStoreToTest($config['arguments']);
+ $this->objectStorage = new Swift($config['arguments']);
$config['objectstore'] = $this->objectStorage;
$this->instance = new ObjectStoreStorage($config);
}
diff --git a/tests/lib/files/objectstore/noopscanner.php b/tests/lib/files/objectstore/noopscanner.php
index f860c03cb18..fba6619d42b 100644
--- a/tests/lib/files/objectstore/noopscanner.php
+++ b/tests/lib/files/objectstore/noopscanner.php
@@ -9,7 +9,7 @@
* later.
* See the COPYING-README file.
*/
-namespace Test\Files\Cache;
+namespace Test\Files\Cache\ObjectStore;
class NoopScanner extends \Test\TestCase {
/** @var \OC\Files\Storage\Storage $storage */
diff --git a/tests/lib/files/pathverificationtest.php b/tests/lib/files/pathverificationtest.php
index db393ce5e51..ea9859c862c 100644
--- a/tests/lib/files/pathverificationtest.php
+++ b/tests/lib/files/pathverificationtest.php
@@ -17,7 +17,7 @@ use OC\Files\View;
*
* @package Test\Files
*/
-class PathVerification extends \Test\TestCase {
+class PathVerificationTest extends \Test\TestCase {
/**
* @var \OC\Files\View
diff --git a/tests/lib/files/storage/wrapper/availability.php b/tests/lib/files/storage/wrapper/availability.php
index 99d6f7dbe5c..311334a80a3 100644
--- a/tests/lib/files/storage/wrapper/availability.php
+++ b/tests/lib/files/storage/wrapper/availability.php
@@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
+
namespace Test\Files\Storage\Wrapper;
class Availability extends \Test\TestCase {
diff --git a/tests/lib/files/type/detection.php b/tests/lib/files/type/DetectionTest.php
index 5800f4eb8e3..5800f4eb8e3 100644
--- a/tests/lib/files/type/detection.php
+++ b/tests/lib/files/type/DetectionTest.php
diff --git a/tests/lib/files/type/loadertest.php b/tests/lib/files/type/loadertest.php
index 7f87afd2f4d..a77d672f667 100644
--- a/tests/lib/files/type/loadertest.php
+++ b/tests/lib/files/type/loadertest.php
@@ -19,7 +19,7 @@
*
*/
-namespace OC\Files\Type;
+namespace Test\Files\Type;
use \OC\Files\Type\Loader;
use \OCP\IDBConnection;
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 86413c61aa1..d33c9f31503 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -1508,7 +1508,7 @@ class View extends \Test\TestCase {
$defaultView = new \OC\Files\View('/foo/files');
$defaultRootValue->setValue($defaultView);
$view = new \OC\Files\View($root);
- $result = \Test_Helper::invokePrivate($view, 'shouldEmitHooks', [$path]);
+ $result = $this->invokePrivate($view, 'shouldEmitHooks', [$path]);
$defaultRootValue->setValue($oldRoot);
$this->assertEquals($shouldEmit, $result);
}
@@ -1872,7 +1872,7 @@ class View extends \Test\TestCase {
$this->assertEquals(ILockingProvider::LOCK_SHARED, $lockTypePre, 'File locked properly during pre-hook');
$this->assertEquals(ILockingProvider::LOCK_EXCLUSIVE, $lockTypeDuring, 'File locked properly during operation');
- $this->assertNull(null, $lockTypePost, 'No post hook, no lock check possible');
+ $this->assertNull($lockTypePost, 'No post hook, no lock check possible');
$this->assertEquals(ILockingProvider::LOCK_EXCLUSIVE, $lockTypeDuring, 'File still locked after fopen');
diff --git a/tests/lib/group.php b/tests/lib/group/LegacyGroupTest.php
index d3ac6d8d69e..12bcfdddf15 100644
--- a/tests/lib/group.php
+++ b/tests/lib/group/LegacyGroupTest.php
@@ -22,7 +22,12 @@
*
*/
-class Test_Group extends \Test\TestCase {
+namespace Test\Group;
+
+use OC_Group;
+use OC_User;
+
+class LegacyGroupTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
OC_Group::clearBackends();
diff --git a/tests/lib/group/backend.php b/tests/lib/group/backend.php
index 3b06a3eb3a9..53a13e6c62f 100644
--- a/tests/lib/group/backend.php
+++ b/tests/lib/group/backend.php
@@ -24,12 +24,14 @@
*
*/
+namespace Test\Group;
+
/**
* Class Test_Group_Backend
*
* @group DB
*/
-abstract class Test_Group_Backend extends \Test\TestCase {
+abstract class Backend extends \Test\TestCase {
/**
* @var \OC\Group\Backend $backend
*/
diff --git a/tests/lib/group/database.php b/tests/lib/group/database.php
index aae9f8bf1de..bf9d9c35b0b 100644
--- a/tests/lib/group/database.php
+++ b/tests/lib/group/database.php
@@ -23,12 +23,14 @@
*
*/
+namespace Test\Group;
+
/**
- * Class Test_Group_Database
+ * Class Database
*
* @group DB
*/
-class Test_Group_Database extends Test_Group_Backend {
+class Database extends Backend {
private $groups = array();
/**
diff --git a/tests/lib/group/dummy.php b/tests/lib/group/dummy.php
index eaa299c39af..5504cd63a0a 100644
--- a/tests/lib/group/dummy.php
+++ b/tests/lib/group/dummy.php
@@ -20,12 +20,14 @@
*
*/
+namespace Test\Group;
+
/**
- * Class Test_Group_Dummy
+ * Class Dummy
*
* @group DB
*/
-class Test_Group_Dummy extends Test_Group_Backend {
+class Dummy extends Backend {
protected function setUp() {
parent::setUp();
$this->backend=new \Test\Util\Group\Dummy();
diff --git a/tests/lib/group/metadata.php b/tests/lib/group/metadatatest.php
index 233463c71eb..593bbcb48db 100644
--- a/tests/lib/group/metadata.php
+++ b/tests/lib/group/metadatatest.php
@@ -22,7 +22,7 @@
namespace Test\Group;
-class Test_MetaData extends \Test\TestCase {
+class MetaDataTest extends \Test\TestCase {
/** @var \OC\Group\Manager */
private $groupManager;
/** @var \OCP\IUserSession */
diff --git a/tests/lib/http/client/clientservicetest.php b/tests/lib/http/client/clientservicetest.php
index 6d7acea0be7..3c406f30111 100644
--- a/tests/lib/http/client/clientservicetest.php
+++ b/tests/lib/http/client/clientservicetest.php
@@ -6,9 +6,11 @@
* See the COPYING-README file.
*/
-namespace OC\Http\Client;
+namespace Test\Http\Client;
use GuzzleHttp\Client as GuzzleClient;
+use OC\Http\Client\Client;
+use OC\Http\Client\ClientService;
/**
* Class ClientServiceTest
diff --git a/tests/lib/http/client/clienttest.php b/tests/lib/http/client/clienttest.php
index c76fe0532a7..705e1eeddea 100644
--- a/tests/lib/http/client/clienttest.php
+++ b/tests/lib/http/client/clienttest.php
@@ -6,9 +6,10 @@
* See the COPYING-README file.
*/
-namespace OC\Http\Client;
+namespace Test\Http\Client;
use GuzzleHttp\Message\Response;
+use OC\Http\Client\Client;
use OCP\IConfig;
/**
diff --git a/tests/lib/http/client/responsetest.php b/tests/lib/http/client/responsetest.php
index d9b181a8e28..685f34a0baf 100644
--- a/tests/lib/http/client/responsetest.php
+++ b/tests/lib/http/client/responsetest.php
@@ -6,10 +6,11 @@
* See the COPYING-README file.
*/
-namespace OC\Http\Client;
+namespace Test\Http\Client;
use Guzzle\Stream\Stream;
use GuzzleHttp\Message\Response as GuzzleResponse;
+use OC\Http\Client\Response;
/**
* Class ResponseTest
diff --git a/tests/lib/integritycheck/checkertest.php b/tests/lib/integritycheck/checkertest.php
index 0910c543a7a..6e6095668b0 100644
--- a/tests/lib/integritycheck/checkertest.php
+++ b/tests/lib/integritycheck/checkertest.php
@@ -23,7 +23,6 @@ namespace Test\IntegrityCheck;
use OC\IntegrityCheck\Checker;
use OC\Memcache\NullCache;
-use OCP\ICache;
use phpseclib\Crypt\RSA;
use phpseclib\File\X509;
use Test\TestCase;
diff --git a/tests/lib/integritycheck/helpers/EnvironmentHelperTest.php b/tests/lib/integritycheck/helpers/EnvironmentHelperTest.php
index a1d1f671b07..9dc9214a779 100644
--- a/tests/lib/integritycheck/helpers/EnvironmentHelperTest.php
+++ b/tests/lib/integritycheck/helpers/EnvironmentHelperTest.php
@@ -19,7 +19,7 @@
*
*/
-namespace Test\IntegrityCheck\Factories;
+namespace Test\IntegrityCheck\Helpers;
use OC\IntegrityCheck\Helpers\EnvironmentHelper;
use Test\TestCase;
diff --git a/tests/lib/log/owncloud.php b/tests/lib/log/OwncloudTest.php
index e19063a83f5..e19063a83f5 100644
--- a/tests/lib/log/owncloud.php
+++ b/tests/lib/log/OwncloudTest.php
diff --git a/tests/lib/mail/mailer.php b/tests/lib/mail/MailerTest.php
index 8023cda820e..c63ceb5982a 100644
--- a/tests/lib/mail/mailer.php
+++ b/tests/lib/mail/MailerTest.php
@@ -6,11 +6,13 @@
* See the COPYING-README file.
*/
-namespace Test;
+namespace Test\Mail;
+
use OC\Mail\Mailer;
use OCP\IConfig;
use OC_Defaults;
use OCP\ILogger;
+use Test\TestCase;
class MailerTest extends TestCase {
/** @var IConfig */
diff --git a/tests/lib/mail/message.php b/tests/lib/mail/MessageTest.php
index 339677c0a7c..691168ce24c 100644
--- a/tests/lib/mail/message.php
+++ b/tests/lib/mail/MessageTest.php
@@ -6,10 +6,11 @@
* See the COPYING-README file.
*/
-namespace Test;
+namespace Test\Mail;
use OC\Mail\Message;
use Swift_Message;
+use Test\TestCase;
class MessageTest extends TestCase {
/** @var Swift_Message */
diff --git a/tests/lib/memcache/factory.php b/tests/lib/memcache/FactoryTest.php
index 33a27a42113..8607ea7de9b 100644
--- a/tests/lib/memcache/factory.php
+++ b/tests/lib/memcache/FactoryTest.php
@@ -56,7 +56,7 @@ class Test_Factory_Unavailable_Cache2 {
}
}
-class Test_Factory extends \Test\TestCase {
+class FactoryTest extends \Test\TestCase {
const AVAILABLE1 = '\\Test\\Memcache\\Test_Factory_Available_Cache1';
const AVAILABLE2 = '\\Test\\Memcache\\Test_Factory_Available_Cache2';
const UNAVAILABLE1 = '\\Test\\Memcache\\Test_Factory_Unavailable_Cache1';
diff --git a/tests/lib/ocs/privatedata.php b/tests/lib/ocs/PrivatedataTest.php
index ce153bf07d6..0b3b23b8804 100644
--- a/tests/lib/ocs/privatedata.php
+++ b/tests/lib/ocs/PrivatedataTest.php
@@ -20,12 +20,16 @@
*
*/
+namespace Test\OCS;
+
+use OC_OCS_Privatedata;
+
/**
- * Class Test_OC_OCS_Privatedata
+ * Class PrivatedataTest
*
* @group DB
*/
-class Test_OC_OCS_Privatedata extends \Test\TestCase {
+class PrivatedataTest extends \Test\TestCase {
private $appKey;
protected function setUp() {
diff --git a/tests/lib/ocsclienttest.php b/tests/lib/ocsclienttest.php
index 7555562d124..4ae6fb62e0e 100644
--- a/tests/lib/ocsclienttest.php
+++ b/tests/lib/ocsclienttest.php
@@ -19,6 +19,8 @@
*
*/
+namespace Test;
+
use OC\OCSClient;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
diff --git a/tests/lib/public/contacts.php b/tests/lib/publicnamespace/ContactsTest.php
index 151e98d3905..8b07c4831b6 100644
--- a/tests/lib/public/contacts.php
+++ b/tests/lib/publicnamespace/ContactsTest.php
@@ -19,15 +19,17 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
-class Test_Contacts extends \Test\TestCase {
+namespace Test\PublicNamespace;
+
+class ContactsTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- OCP\Contacts::clear();
+ \OCP\Contacts::clear();
}
public function testDisabledIfEmpty() {
// pretty simple
- $this->assertFalse(OCP\Contacts::isEnabled());
+ $this->assertFalse(\OCP\Contacts::isEnabled());
}
public function testEnabledAfterRegister() {
@@ -41,19 +43,19 @@ class Test_Contacts extends \Test\TestCase {
->method('getKey');
// not enabled before register
- $this->assertFalse(OCP\Contacts::isEnabled());
+ $this->assertFalse(\OCP\Contacts::isEnabled());
// register the address book
- OCP\Contacts::registerAddressBook($stub);
+ \OCP\Contacts::registerAddressBook($stub);
// contacts api shall be enabled
- $this->assertTrue(OCP\Contacts::isEnabled());
+ $this->assertTrue(\OCP\Contacts::isEnabled());
// unregister the address book
- OCP\Contacts::unregisterAddressBook($stub);
+ \OCP\Contacts::unregisterAddressBook($stub);
// not enabled after register
- $this->assertFalse(OCP\Contacts::isEnabled());
+ $this->assertFalse(\OCP\Contacts::isEnabled());
}
public function testAddressBookEnumeration() {
@@ -69,8 +71,8 @@ class Test_Contacts extends \Test\TestCase {
->will($this->returnValue('A very simple Addressbook'));
// register the address book
- OCP\Contacts::registerAddressBook($stub);
- $all_books = OCP\Contacts::getAddressBooks();
+ \OCP\Contacts::registerAddressBook($stub);
+ $all_books = \OCP\Contacts::getAddressBooks();
$this->assertEquals(1, count($all_books));
$this->assertEquals('A very simple Addressbook', $all_books['SIMPLE_ADDRESS_BOOK']);
@@ -101,15 +103,15 @@ class Test_Contacts extends \Test\TestCase {
$stub2->expects($this->any())->method('search')->will($this->returnValue($searchResult2));
// register the address books
- OCP\Contacts::registerAddressBook($stub1);
- OCP\Contacts::registerAddressBook($stub2);
- $all_books = OCP\Contacts::getAddressBooks();
+ \OCP\Contacts::registerAddressBook($stub1);
+ \OCP\Contacts::registerAddressBook($stub2);
+ $all_books = \OCP\Contacts::getAddressBooks();
// assert the count - doesn't hurt
$this->assertEquals(2, count($all_books));
// perform the search
- $result = OCP\Contacts::search('x', array());
+ $result = \OCP\Contacts::search('x', array());
// we expect 4 hits
$this->assertEquals(4, count($result));
diff --git a/tests/lib/public/ocpconfig.php b/tests/lib/publicnamespace/OCPConfigTest.php
index 947d2b3c9ef..44fd234735e 100644
--- a/tests/lib/public/ocpconfig.php
+++ b/tests/lib/publicnamespace/OCPConfigTest.php
@@ -19,7 +19,9 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
-class Test_OCPConfig extends \Test\TestCase {
+namespace Test\PublicNamespace;
+
+class OCPConfigTest extends \Test\TestCase {
public function testSetAppValueIfSetToNull() {
diff --git a/tests/lib/public/util.php b/tests/lib/publicnamespace/UtilTest.php
index ebc4f70079b..31d1f9fb0ee 100644
--- a/tests/lib/public/util.php
+++ b/tests/lib/publicnamespace/UtilTest.php
@@ -19,10 +19,13 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
-class Test_Public_Util extends \Test\TestCase {
+namespace Test\PublicNamespace;
+
+
+class UtilTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- OCP\Contacts::clear();
+ \OCP\Contacts::clear();
}
/**
diff --git a/tests/lib/repair/repaircollation.php b/tests/lib/repair/RepairCollationTest.php
index 4efa8ccc552..2e304a74abc 100644
--- a/tests/lib/repair/repaircollation.php
+++ b/tests/lib/repair/RepairCollationTest.php
@@ -1,4 +1,7 @@
<?php
+
+namespace Test\Repair;
+
use OCP\Migration\IOutput;
/**
@@ -25,7 +28,7 @@ class TestCollationRepair extends \OC\Repair\Collation {
*
* @see \OC\Repair\RepairMimeTypes
*/
-class TestRepairCollation extends \Test\TestCase {
+class RepairCollationTest extends \Test\TestCase {
/**
* @var TestCollationRepair
diff --git a/tests/lib/security/certificatemanager.php b/tests/lib/security/CertificateManagerTest.php
index e9ccea39efe..43206569cf4 100644
--- a/tests/lib/security/certificatemanager.php
+++ b/tests/lib/security/CertificateManagerTest.php
@@ -6,6 +6,8 @@
* See the COPYING-README file.
*/
+namespace Test\Security;
+
use \OC\Security\CertificateManager;
/**
diff --git a/tests/lib/security/certificate.php b/tests/lib/security/CertificateTest.php
index 82e91c71733..6f7d7d4a37f 100644
--- a/tests/lib/security/certificate.php
+++ b/tests/lib/security/CertificateTest.php
@@ -19,6 +19,8 @@
*
*/
+namespace Test\Security;
+
use \OC\Security\Certificate;
class CertificateTest extends \Test\TestCase {
@@ -74,18 +76,18 @@ class CertificateTest extends \Test\TestCase {
}
public function testGetIssueDate() {
- $expected = new DateTime('2015-08-27 20:03:42 GMT');
+ $expected = new \DateTime('2015-08-27 20:03:42 GMT');
$this->assertEquals($expected->getTimestamp(), $this->goodCertificate->getIssueDate()->getTimestamp());
- $expected = new DateTime('2015-08-27 20:19:13 GMT');
+ $expected = new \DateTime('2015-08-27 20:19:13 GMT');
$this->assertEquals($expected->getTimestamp(), $this->invalidCertificate->getIssueDate()->getTimestamp());
}
public function testGetExpireDate() {
- $expected = new DateTime('2025-08-24 20:03:42 GMT');
+ $expected = new \DateTime('2025-08-24 20:03:42 GMT');
$this->assertEquals($expected->getTimestamp(), $this->goodCertificate->getExpireDate()->getTimestamp());
- $expected = new DateTime('2025-08-24 20:19:13 GMT');
+ $expected = new \DateTime('2025-08-24 20:19:13 GMT');
$this->assertEquals($expected->getTimestamp(), $this->invalidCertificate->getExpireDate()->getTimestamp());
- $expected = new DateTime('2014-08-28 09:12:43 GMT');
+ $expected = new \DateTime('2014-08-28 09:12:43 GMT');
$this->assertEquals($expected->getTimestamp(), $this->expiredCertificate->getExpireDate()->getTimestamp());
}
diff --git a/tests/lib/security/credentialsmanager.php b/tests/lib/security/CredentialsManagerTest.php
index 72f061e05bb..7eb4e4d7b1a 100644
--- a/tests/lib/security/credentialsmanager.php
+++ b/tests/lib/security/CredentialsManagerTest.php
@@ -19,6 +19,8 @@
*
*/
+namespace Test\Security;
+
use \OCP\Security\ICrypto;
use \OCP\IDBConnection;
use \OC\Security\CredentialsManager;
diff --git a/tests/lib/security/crypto.php b/tests/lib/security/CryptoTest.php
index 1571cf89248..356d504f4b3 100644
--- a/tests/lib/security/crypto.php
+++ b/tests/lib/security/CryptoTest.php
@@ -6,6 +6,8 @@
* See the COPYING-README file.
*/
+namespace Test\Security;
+
use \OC\Security\Crypto;
class CryptoTest extends \Test\TestCase {
diff --git a/tests/lib/security/hasher.php b/tests/lib/security/HasherTest.php
index a6f7df5b79f..913f4d703e8 100644
--- a/tests/lib/security/hasher.php
+++ b/tests/lib/security/HasherTest.php
@@ -6,6 +6,8 @@
* See the COPYING-README file.
*/
+namespace Test\Security;
+
use OC\Security\Hasher;
/**
diff --git a/tests/lib/security/securerandom.php b/tests/lib/security/SecureRandomTest.php
index 526066d92ee..40431c89795 100644
--- a/tests/lib/security/securerandom.php
+++ b/tests/lib/security/SecureRandomTest.php
@@ -6,6 +6,8 @@
* See the COPYING-README file.
*/
+namespace Test\Security;
+
use \OC\Security\SecureRandom;
class SecureRandomTest extends \Test\TestCase {
diff --git a/tests/lib/security/trusteddomainhelper.php b/tests/lib/security/TrustedDomainHelperTest.php
index 3581211ce61..dfd51167cca 100644
--- a/tests/lib/security/trusteddomainhelper.php
+++ b/tests/lib/security/TrustedDomainHelperTest.php
@@ -6,6 +6,8 @@
* See the COPYING-README file.
*/
+namespace Test\Security;
+
use \OC\Security\TrustedDomainHelper;
use OCP\IConfig;
diff --git a/tests/lib/security/csp/ContentSecurityPolicyManagerTest.php b/tests/lib/security/csp/ContentSecurityPolicyManagerTest.php
index 975c35d3780..d463e7c648c 100644
--- a/tests/lib/security/csp/ContentSecurityPolicyManagerTest.php
+++ b/tests/lib/security/csp/ContentSecurityPolicyManagerTest.php
@@ -19,6 +19,9 @@
*
*/
+namespace Test\Security\CSP;
+
+
use OC\Security\CSP\ContentSecurityPolicyManager;
class ContentSecurityPolicyManagerTest extends \Test\TestCase {
diff --git a/tests/lib/security/csrf/CsrfTokenGeneratorTest.php b/tests/lib/security/csrf/CsrfTokenGeneratorTest.php
index be7434f514f..28b85c3951f 100644
--- a/tests/lib/security/csrf/CsrfTokenGeneratorTest.php
+++ b/tests/lib/security/csrf/CsrfTokenGeneratorTest.php
@@ -19,6 +19,8 @@
*
*/
+namespace Test\Security\CSRF;
+
class CsrfTokenGeneratorTest extends \Test\TestCase {
/** @var \OCP\Security\ISecureRandom */
private $random;
diff --git a/tests/lib/security/csrf/CsrfTokenManagerTest.php b/tests/lib/security/csrf/CsrfTokenManagerTest.php
index 145fc03c51e..ab19a43e91e 100644
--- a/tests/lib/security/csrf/CsrfTokenManagerTest.php
+++ b/tests/lib/security/csrf/CsrfTokenManagerTest.php
@@ -19,6 +19,8 @@
*
*/
+namespace Test\Security\CSRF;
+
class CsrfTokenManagerTest extends \Test\TestCase {
/** @var \OC\Security\CSRF\CsrfTokenManager */
private $csrfTokenManager;
diff --git a/tests/lib/security/csrf/CsrfTokenTest.php b/tests/lib/security/csrf/CsrfTokenTest.php
index 62e6ad112e7..da640ce5052 100644
--- a/tests/lib/security/csrf/CsrfTokenTest.php
+++ b/tests/lib/security/csrf/CsrfTokenTest.php
@@ -19,6 +19,8 @@
*
*/
+namespace Test\Security\CSRF;
+
class CsrfTokenTest extends \Test\TestCase {
public function testGetEncryptedValue() {
$csrfToken = new \OC\Security\CSRF\CsrfToken('MyCsrfToken');
diff --git a/tests/lib/security/csrf/tokenstorage/SessionStorageTest.php b/tests/lib/security/csrf/tokenstorage/SessionStorageTest.php
index 3a83f6a8c00..550fa49e1b2 100644
--- a/tests/lib/security/csrf/tokenstorage/SessionStorageTest.php
+++ b/tests/lib/security/csrf/tokenstorage/SessionStorageTest.php
@@ -19,6 +19,8 @@
*
*/
+namespace Test\Security\CSRF\TokenStorage;
+
class SessionStorageTest extends \Test\TestCase {
/** @var \OCP\ISession */
private $session;
diff --git a/tests/lib/share/MailNotificationsTest.php b/tests/lib/share/MailNotificationsTest.php
index f160fed57ae..0c951d11f88 100644
--- a/tests/lib/share/MailNotificationsTest.php
+++ b/tests/lib/share/MailNotificationsTest.php
@@ -19,6 +19,8 @@
*
*/
+namespace Test\Share;
+
use OC\Share\MailNotifications;
use OCP\IL10N;
use OCP\IUser;
@@ -33,15 +35,15 @@ use OCP\IURLGenerator;
class MailNotificationsTest extends \Test\TestCase {
/** @var IL10N */
private $l10n;
- /** @var IMailer | PHPUnit_Framework_MockObject_MockObject */
+ /** @var IMailer | \PHPUnit_Framework_MockObject_MockObject */
private $mailer;
/** @var ILogger */
private $logger;
- /** @var Defaults | PHPUnit_Framework_MockObject_MockObject */
+ /** @var Defaults | \PHPUnit_Framework_MockObject_MockObject */
private $defaults;
- /** @var IUser | PHPUnit_Framework_MockObject_MockObject */
+ /** @var IUser | \PHPUnit_Framework_MockObject_MockObject */
private $user;
- /** @var IURLGenerator | PHPUnit_Framework_MockObject_MockObject */
+ /** @var IURLGenerator | \PHPUnit_Framework_MockObject_MockObject */
private $urlGenerator;
@@ -209,7 +211,7 @@ class MailNotificationsTest extends \Test\TestCase {
public function testSendInternalShareMail() {
$this->setupMailerMock('TestUser shared »welcome.txt« with you', ['recipient@owncloud.com' => 'Recipient'], false);
- /** @var MailNotifications | PHPUnit_Framework_MockObject_MockObject $mailNotifications */
+ /** @var MailNotifications | \PHPUnit_Framework_MockObject_MockObject $mailNotifications */
$mailNotifications = $this->getMock('OC\Share\MailNotifications',['getItemSharedWithUser'], [
$this->user,
$this->l10n,
@@ -286,7 +288,7 @@ class MailNotificationsTest extends \Test\TestCase {
->expects($this->once())
->method('send')
->with($message)
- ->will($this->throwException(new Exception('Some Exception Message')));
+ ->will($this->throwException(new \Exception('Some Exception Message')));
}
}
}
diff --git a/tests/lib/share/backend.php b/tests/lib/share/backend.php
index 9c0d7fcb020..c5007d1583b 100644
--- a/tests/lib/share/backend.php
+++ b/tests/lib/share/backend.php
@@ -19,7 +19,9 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
-class Test_Share_Backend implements OCP\Share_Backend {
+namespace Test\Share;
+
+class Backend implements \OCP\Share_Backend {
const FORMAT_SOURCE = 0;
const FORMAT_TARGET = 1;
diff --git a/tests/lib/share/helper.php b/tests/lib/share/helper.php
index eaa29c8cb90..3fe6389c408 100644
--- a/tests/lib/share/helper.php
+++ b/tests/lib/share/helper.php
@@ -19,11 +19,13 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+namespace Test\Share;
+
/**
* @group DB
- * Class Test_Share_Helper
+ * Class Helper
*/
-class Test_Share_Helper extends \Test\TestCase {
+class Helper extends \Test\TestCase {
public function expireDateProvider() {
return array(
diff --git a/tests/lib/share/searchresultsorter.php b/tests/lib/share/searchresultsorter.php
index d91110f7a9a..6bee5dfe7f0 100644
--- a/tests/lib/share/searchresultsorter.php
+++ b/tests/lib/share/searchresultsorter.php
@@ -19,7 +19,9 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
-class Test_Share_Search extends \Test\TestCase {
+namespace Test\Share;
+
+class SearchResultSorter extends \Test\TestCase {
public function testSort() {
$search = 'lin';
$sorter = new \OC\Share\SearchResultSorter($search, 'foobar');
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index a07e90effc3..355005bb586 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -19,12 +19,14 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+namespace Test\Share;
+
/**
* Class Test_Share
*
* @group DB
*/
-class Test_Share extends \Test\TestCase {
+class Share extends \Test\TestCase {
protected $itemType;
protected $userBackend;
@@ -45,8 +47,8 @@ class Test_Share extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- OC_User::clearBackends();
- OC_User::useBackend('dummy');
+ \OC_User::clearBackends();
+ \OC_User::useBackend('dummy');
$this->user1 = $this->getUniqueID('user1_');
$this->user2 = $this->getUniqueID('user2_');
$this->user3 = $this->getUniqueID('user3_');
@@ -61,24 +63,24 @@ class Test_Share extends \Test\TestCase {
\OC::$server->getUserManager()->createUser($this->user5, 'pass');
\OC::$server->getUserManager()->createUser($this->user6, 'pass'); // no group
\OC::$server->getUserManager()->createUser($this->groupAndUser, 'pass');
- OC_User::setUserId($this->user1);
- OC_Group::clearBackends();
- OC_Group::useBackend(new \Test\Util\Group\Dummy());
+ \OC_User::setUserId($this->user1);
+ \OC_Group::clearBackends();
+ \OC_Group::useBackend(new \Test\Util\Group\Dummy());
$this->group1 = $this->getUniqueID('group1_');
$this->group2 = $this->getUniqueID('group2_');
- OC_Group::createGroup($this->group1);
- OC_Group::createGroup($this->group2);
- OC_Group::createGroup($this->groupAndUser);
- OC_Group::addToGroup($this->user1, $this->group1);
- OC_Group::addToGroup($this->user2, $this->group1);
- OC_Group::addToGroup($this->user3, $this->group1);
- OC_Group::addToGroup($this->user2, $this->group2);
- OC_Group::addToGroup($this->user4, $this->group2);
- OC_Group::addToGroup($this->user2, $this->groupAndUser);
- OC_Group::addToGroup($this->user3, $this->groupAndUser);
- OCP\Share::registerBackend('test', 'Test_Share_Backend');
- OC_Hook::clear('OCP\\Share');
- OC::registerShareHooks();
+ \OC_Group::createGroup($this->group1);
+ \OC_Group::createGroup($this->group2);
+ \OC_Group::createGroup($this->groupAndUser);
+ \OC_Group::addToGroup($this->user1, $this->group1);
+ \OC_Group::addToGroup($this->user2, $this->group1);
+ \OC_Group::addToGroup($this->user3, $this->group1);
+ \OC_Group::addToGroup($this->user2, $this->group2);
+ \OC_Group::addToGroup($this->user4, $this->group2);
+ \OC_Group::addToGroup($this->user2, $this->groupAndUser);
+ \OC_Group::addToGroup($this->user3, $this->groupAndUser);
+ \OCP\Share::registerBackend('test', 'Test\Share\Backend');
+ \OC_Hook::clear('OCP\\Share');
+ \OC::registerShareHooks();
$this->resharing = \OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_resharing', 'yes');
\OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', 'yes');
@@ -90,7 +92,7 @@ class Test_Share extends \Test\TestCase {
}
protected function tearDown() {
- $query = OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `item_type` = ?');
+ $query = \OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `item_type` = ?');
$query->execute(array('test'));
\OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', $this->resharing);
@@ -109,9 +111,9 @@ class Test_Share extends \Test\TestCase {
$user = \OC::$server->getUserManager()->get($this->groupAndUser);
if ($user !== null) { $user->delete(); }
- OC_Group::deleteGroup($this->group1);
- OC_Group::deleteGroup($this->group2);
- OC_Group::deleteGroup($this->groupAndUser);
+ \OC_Group::deleteGroup($this->group1);
+ \OC_Group::deleteGroup($this->group2);
+ \OC_Group::deleteGroup($this->groupAndUser);
$this->logout();
parent::tearDown();
@@ -126,8 +128,8 @@ class Test_Share extends \Test\TestCase {
public function testShareInvalidShareType() {
$message = 'Share type foobar is not valid for test.txt';
try {
- OCP\Share::shareItem('test', 'test.txt', 'foobar', $this->user2, \OCP\Constants::PERMISSION_READ);
- } catch (Exception $exception) {
+ \OCP\Share::shareItem('test', 'test.txt', 'foobar', $this->user2, \OCP\Constants::PERMISSION_READ);
+ } catch (\Exception $exception) {
$this->assertEquals($message, $exception->getMessage());
}
}
@@ -135,72 +137,72 @@ class Test_Share extends \Test\TestCase {
public function testInvalidItemType() {
$message = 'Sharing backend for foobar not found';
try {
- OCP\Share::shareItem('foobar', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ);
+ \OCP\Share::shareItem('foobar', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ);
$this->fail('Exception was expected: '.$message);
- } catch (Exception $exception) {
+ } catch (\Exception $exception) {
$this->assertEquals($message, $exception->getMessage());
}
try {
- OCP\Share::getItemsSharedWith('foobar');
+ \OCP\Share::getItemsSharedWith('foobar');
$this->fail('Exception was expected: '.$message);
- } catch (Exception $exception) {
+ } catch (\Exception $exception) {
$this->assertEquals($message, $exception->getMessage());
}
try {
- OCP\Share::getItemSharedWith('foobar', 'test.txt');
+ \OCP\Share::getItemSharedWith('foobar', 'test.txt');
$this->fail('Exception was expected: '.$message);
- } catch (Exception $exception) {
+ } catch (\Exception $exception) {
$this->assertEquals($message, $exception->getMessage());
}
try {
- OCP\Share::getItemSharedWithBySource('foobar', 'test.txt');
+ \OCP\Share::getItemSharedWithBySource('foobar', 'test.txt');
$this->fail('Exception was expected: '.$message);
- } catch (Exception $exception) {
+ } catch (\Exception $exception) {
$this->assertEquals($message, $exception->getMessage());
}
try {
- OCP\Share::getItemShared('foobar', 'test.txt');
+ \OCP\Share::getItemShared('foobar', 'test.txt');
$this->fail('Exception was expected: '.$message);
- } catch (Exception $exception) {
+ } catch (\Exception $exception) {
$this->assertEquals($message, $exception->getMessage());
}
try {
- OCP\Share::unshare('foobar', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2);
+ \OCP\Share::unshare('foobar', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2);
$this->fail('Exception was expected: '.$message);
- } catch (Exception $exception) {
+ } catch (\Exception $exception) {
$this->assertEquals($message, $exception->getMessage());
}
try {
- OCP\Share::setPermissions('foobar', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_UPDATE);
+ \OCP\Share::setPermissions('foobar', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_UPDATE);
$this->fail('Exception was expected: '.$message);
- } catch (Exception $exception) {
+ } catch (\Exception $exception) {
$this->assertEquals($message, $exception->getMessage());
}
}
protected function shareUserOneTestFileWithUserTwo() {
- OC_User::setUserId($this->user1);
+ \OC_User::setUserId($this->user1);
$this->assertTrue(
- OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ),
+ \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ),
'Failed asserting that user 1 successfully shared text.txt with user 2.'
);
$this->assertContains(
'test.txt',
- OCP\Share::getItemShared('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
+ \OCP\Share::getItemShared('test', 'test.txt', Backend::FORMAT_SOURCE),
'Failed asserting that test.txt is a shared file of user 1.'
);
- OC_User::setUserId($this->user2);
+ \OC_User::setUserId($this->user2);
$this->assertContains(
'test.txt',
- OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
+ \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_SOURCE),
'Failed asserting that user 2 has access to test.txt after initial sharing.'
);
}
protected function shareUserTestFileAsLink() {
- OC_User::setUserId($this->user1);
- $result = OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ);
+ \OC_User::setUserId($this->user1);
+ $result = \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ);
$this->assertTrue(is_string($result));
}
@@ -209,21 +211,21 @@ class Test_Share extends \Test\TestCase {
* @param string $receiver
*/
protected function shareUserTestFileWithUser($sharer, $receiver) {
- OC_User::setUserId($sharer);
+ \OC_User::setUserId($sharer);
$this->assertTrue(
- OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $receiver, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE),
+ \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $receiver, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE),
'Failed asserting that ' . $sharer . ' successfully shared text.txt with ' . $receiver . '.'
);
$this->assertContains(
'test.txt',
- OCP\Share::getItemShared('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
+ \OCP\Share::getItemShared('test', 'test.txt', Backend::FORMAT_SOURCE),
'Failed asserting that test.txt is a shared file of ' . $sharer . '.'
);
- OC_User::setUserId($receiver);
+ \OC_User::setUserId($receiver);
$this->assertContains(
'test.txt',
- OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
+ \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_SOURCE),
'Failed asserting that ' . $receiver . ' has access to test.txt after initial sharing.'
);
}
@@ -232,23 +234,23 @@ class Test_Share extends \Test\TestCase {
// Invalid shares
$message = 'Sharing test.txt failed, because you can not share with yourself';
try {
- OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user1, \OCP\Constants::PERMISSION_READ);
+ \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user1, \OCP\Constants::PERMISSION_READ);
$this->fail('Exception was expected: '.$message);
- } catch (Exception $exception) {
+ } catch (\Exception $exception) {
$this->assertEquals($message, $exception->getMessage());
}
$message = 'Sharing test.txt failed, because the user foobar does not exist';
try {
- OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, 'foobar', \OCP\Constants::PERMISSION_READ);
+ \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, 'foobar', \OCP\Constants::PERMISSION_READ);
$this->fail('Exception was expected: '.$message);
- } catch (Exception $exception) {
+ } catch (\Exception $exception) {
$this->assertEquals($message, $exception->getMessage());
}
$message = 'Sharing foobar failed, because the sharing backend for test could not find its source';
try {
- OCP\Share::shareItem('test', 'foobar', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ);
+ \OCP\Share::shareItem('test', 'foobar', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ);
$this->fail('Exception was expected: '.$message);
- } catch (Exception $exception) {
+ } catch (\Exception $exception) {
$this->assertEquals($message, $exception->getMessage());
}
@@ -256,140 +258,140 @@ class Test_Share extends \Test\TestCase {
$this->shareUserOneTestFileWithUserTwo();
// Attempt to share again
- OC_User::setUserId($this->user1);
+ \OC_User::setUserId($this->user1);
$message = 'Sharing test.txt failed, because this item is already shared with '.$this->user2;
try {
- OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ);
+ \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ);
$this->fail('Exception was expected: '.$message);
- } catch (Exception $exception) {
+ } catch (\Exception $exception) {
$this->assertEquals($message, $exception->getMessage());
}
// Attempt to share back
- OC_User::setUserId($this->user2);
+ \OC_User::setUserId($this->user2);
$message = 'Sharing failed, because the user '.$this->user1.' is the original sharer';
try {
- OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user1, \OCP\Constants::PERMISSION_READ);
+ \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user1, \OCP\Constants::PERMISSION_READ);
$this->fail('Exception was expected: '.$message);
- } catch (Exception $exception) {
+ } catch (\Exception $exception) {
$this->assertEquals($message, $exception->getMessage());
}
// Unshare
- OC_User::setUserId($this->user1);
- $this->assertTrue(OCP\Share::unshare('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2));
+ \OC_User::setUserId($this->user1);
+ $this->assertTrue(\OCP\Share::unshare('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2));
// Attempt reshare without share permission
- $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ));
- OC_User::setUserId($this->user2);
+ $this->assertTrue(\OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ));
+ \OC_User::setUserId($this->user2);
$message = 'Sharing test.txt failed, because resharing is not allowed';
try {
- OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ);
+ \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ);
$this->fail('Exception was expected: '.$message);
- } catch (Exception $exception) {
+ } catch (\Exception $exception) {
$this->assertEquals($message, $exception->getMessage());
}
// Owner grants share and update permission
- OC_User::setUserId($this->user1);
- $this->assertTrue(OCP\Share::setPermissions('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE));
+ \OC_User::setUserId($this->user1);
+ $this->assertTrue(\OCP\Share::setPermissions('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE));
// Attempt reshare with escalated permissions
- OC_User::setUserId($this->user2);
+ \OC_User::setUserId($this->user2);
$message = 'Sharing test.txt failed, because the permissions exceed permissions granted to '.$this->user2;
try {
- OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE);
+ \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE);
$this->fail('Exception was expected: '.$message);
- } catch (Exception $exception) {
+ } catch (\Exception $exception) {
$this->assertEquals($message, $exception->getMessage());
}
// Valid reshare
- $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE));
- $this->assertEquals(array('test.txt'), OCP\Share::getItemShared('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE));
- OC_User::setUserId($this->user3);
- $this->assertEquals(array('test.txt'), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE));
- $this->assertEquals(array(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS));
+ $this->assertTrue(\OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE));
+ $this->assertEquals(array('test.txt'), \OCP\Share::getItemShared('test', 'test.txt', Backend::FORMAT_SOURCE));
+ \OC_User::setUserId($this->user3);
+ $this->assertEquals(array('test.txt'), \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_SOURCE));
+ $this->assertEquals(array(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE), \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_PERMISSIONS));
// Attempt to escalate permissions
- OC_User::setUserId($this->user2);
+ \OC_User::setUserId($this->user2);
$message = 'Setting permissions for test.txt failed, because the permissions exceed permissions granted to '.$this->user2;
try {
- OCP\Share::setPermissions('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE);
+ \OCP\Share::setPermissions('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE);
$this->fail('Exception was expected: '.$message);
- } catch (Exception $exception) {
+ } catch (\Exception $exception) {
$this->assertEquals($message, $exception->getMessage());
}
// Remove update permission
- OC_User::setUserId($this->user1);
- $this->assertTrue(OCP\Share::setPermissions('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE));
- OC_User::setUserId($this->user2);
- $this->assertEquals(array(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS));
- OC_User::setUserId($this->user3);
- $this->assertEquals(array(\OCP\Constants::PERMISSION_READ), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS));
+ \OC_User::setUserId($this->user1);
+ $this->assertTrue(\OCP\Share::setPermissions('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE));
+ \OC_User::setUserId($this->user2);
+ $this->assertEquals(array(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE), \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_PERMISSIONS));
+ \OC_User::setUserId($this->user3);
+ $this->assertEquals(array(\OCP\Constants::PERMISSION_READ), \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_PERMISSIONS));
// Remove share permission
- OC_User::setUserId($this->user1);
- $this->assertTrue(OCP\Share::setPermissions('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ));
- OC_User::setUserId($this->user2);
- $this->assertEquals(array(\OCP\Constants::PERMISSION_READ), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_PERMISSIONS));
- OC_User::setUserId($this->user3);
- $this->assertSame(array(), OCP\Share::getItemSharedWith('test', 'test.txt'));
+ \OC_User::setUserId($this->user1);
+ $this->assertTrue(\OCP\Share::setPermissions('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ));
+ \OC_User::setUserId($this->user2);
+ $this->assertEquals(array(\OCP\Constants::PERMISSION_READ), \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_PERMISSIONS));
+ \OC_User::setUserId($this->user3);
+ $this->assertSame(array(), \OCP\Share::getItemSharedWith('test', 'test.txt'));
// Reshare again, and then have owner unshare
- OC_User::setUserId($this->user1);
- $this->assertTrue(OCP\Share::setPermissions('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE));
- OC_User::setUserId($this->user2);
- $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ));
- OC_User::setUserId($this->user1);
- $this->assertTrue(OCP\Share::unshare('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2));
- OC_User::setUserId($this->user2);
- $this->assertSame(array(), OCP\Share::getItemSharedWith('test', 'test.txt'));
- OC_User::setUserId($this->user3);
- $this->assertSame(array(), OCP\Share::getItemSharedWith('test', 'test.txt'));
+ \OC_User::setUserId($this->user1);
+ $this->assertTrue(\OCP\Share::setPermissions('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE));
+ \OC_User::setUserId($this->user2);
+ $this->assertTrue(\OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ));
+ \OC_User::setUserId($this->user1);
+ $this->assertTrue(\OCP\Share::unshare('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2));
+ \OC_User::setUserId($this->user2);
+ $this->assertSame(array(), \OCP\Share::getItemSharedWith('test', 'test.txt'));
+ \OC_User::setUserId($this->user3);
+ $this->assertSame(array(), \OCP\Share::getItemSharedWith('test', 'test.txt'));
// Attempt target conflict
- OC_User::setUserId($this->user1);
- $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ));
- OC_User::setUserId($this->user3);
- $this->assertTrue(OCP\Share::shareItem('test', 'share.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ));
+ \OC_User::setUserId($this->user1);
+ $this->assertTrue(\OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ));
+ \OC_User::setUserId($this->user3);
+ $this->assertTrue(\OCP\Share::shareItem('test', 'share.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ));
- OC_User::setUserId($this->user2);
- $to_test = OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET);
+ \OC_User::setUserId($this->user2);
+ $to_test = \OCP\Share::getItemsSharedWith('test', Backend::FORMAT_TARGET);
$this->assertEquals(2, count($to_test));
$this->assertTrue(in_array('test.txt', $to_test));
$this->assertTrue(in_array('test1.txt', $to_test));
// Unshare from self
- $this->assertTrue(OCP\Share::unshareFromSelf('test', 'test.txt'));
- $this->assertEquals(array('test1.txt'), OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET));
+ $this->assertTrue(\OCP\Share::unshareFromSelf('test', 'test.txt'));
+ $this->assertEquals(array('test1.txt'), \OCP\Share::getItemsSharedWith('test', Backend::FORMAT_TARGET));
// Unshare from self via source
- $this->assertTrue(OCP\Share::unshareFromSelf('test', 'share.txt', true));
- $this->assertEquals(array(), OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET));
+ $this->assertTrue(\OCP\Share::unshareFromSelf('test', 'share.txt', true));
+ $this->assertEquals(array(), \OCP\Share::getItemsSharedWith('test', Backend::FORMAT_TARGET));
- OC_User::setUserId($this->user1);
- $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ));
- OC_User::setUserId($this->user3);
- $this->assertTrue(OCP\Share::shareItem('test', 'share.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ));
+ \OC_User::setUserId($this->user1);
+ $this->assertTrue(\OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ));
+ \OC_User::setUserId($this->user3);
+ $this->assertTrue(\OCP\Share::shareItem('test', 'share.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ));
- OC_User::setUserId($this->user2);
- $to_test = OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET);
+ \OC_User::setUserId($this->user2);
+ $to_test = \OCP\Share::getItemsSharedWith('test', Backend::FORMAT_TARGET);
$this->assertEquals(2, count($to_test));
$this->assertTrue(in_array('test.txt', $to_test));
$this->assertTrue(in_array('test1.txt', $to_test));
// Remove user
- OC_User::setUserId($this->user1);
+ \OC_User::setUserId($this->user1);
$user = \OC::$server->getUserManager()->get($this->user1);
if ($user !== null) { $user->delete(); }
- OC_User::setUserId($this->user2);
- $this->assertEquals(array('test1.txt'), OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET));
+ \OC_User::setUserId($this->user2);
+ $this->assertEquals(array('test1.txt'), \OCP\Share::getItemsSharedWith('test', Backend::FORMAT_TARGET));
}
public function testShareWithUserExpirationExpired() {
- OC_User::setUserId($this->user1);
+ \OC_User::setUserId($this->user1);
$this->shareUserOneTestFileWithUserTwo();
$this->shareUserTestFileAsLink();
@@ -402,14 +404,14 @@ class Test_Share extends \Test\TestCase {
$query->bindValue(5, \OCP\Share::SHARE_TYPE_LINK);
$query->execute();
- $shares = OCP\Share::getItemsShared('test');
+ $shares = \OCP\Share::getItemsShared('test');
$this->assertSame(1, count($shares));
$share = reset($shares);
$this->assertSame(\OCP\Share::SHARE_TYPE_USER, $share['share_type']);
}
public function testGetShareFromOutsideFilesFolder() {
- OC_User::setUserId($this->user1);
+ \OC_User::setUserId($this->user1);
$view = new \OC\Files\View('/' . $this->user1 . '/');
$view->mkdir('files/test');
$view->mkdir('files/test/sub');
@@ -422,41 +424,41 @@ class Test_Share extends \Test\TestCase {
$fileId = $fileInfo->getId();
$this->assertTrue(
- OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ),
+ \OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ),
'Failed asserting that user 1 successfully shared "test/sub" with user 2.'
);
- $result = OCP\Share::getItemShared('folder', $fileId, Test_Share_Backend::FORMAT_SOURCE);
+ $result = \OCP\Share::getItemShared('folder', $fileId, Backend::FORMAT_SOURCE);
$this->assertNotEmpty($result);
- $result = OCP\Share::getItemSharedWithUser('folder', $fileId, $this->user2);
+ $result = \OCP\Share::getItemSharedWithUser('folder', $fileId, $this->user2);
$this->assertNotEmpty($result);
- $result = OCP\Share::getItemsSharedWithUser('folder', $this->user2);
+ $result = \OCP\Share::getItemsSharedWithUser('folder', $this->user2);
$this->assertNotEmpty($result);
// move to trash (keeps file id)
$view->rename('files/test', 'files_trashbin/files/test');
- $result = OCP\Share::getItemShared('folder', $fileId, Test_Share_Backend::FORMAT_SOURCE);
+ $result = \OCP\Share::getItemShared('folder', $fileId, Backend::FORMAT_SOURCE);
$this->assertEmpty($result, 'Share must not be returned for files outside of "files"');
- $result = OCP\Share::getItemSharedWithUser('folder', $fileId, $this->user2);
+ $result = \OCP\Share::getItemSharedWithUser('folder', $fileId, $this->user2);
$this->assertEmpty($result, 'Share must not be returned for files outside of "files"');
- $result = OCP\Share::getItemsSharedWithUser('folder', $this->user2);
+ $result = \OCP\Share::getItemsSharedWithUser('folder', $this->user2);
$this->assertEmpty($result, 'Share must not be returned for files outside of "files"');
}
public function testSetExpireDateInPast() {
- OC_User::setUserId($this->user1);
+ \OC_User::setUserId($this->user1);
$this->shareUserOneTestFileWithUserTwo();
$this->shareUserTestFileAsLink();
$setExpireDateFailed = false;
try {
$this->assertTrue(
- OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInPast, ''),
+ \OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInPast, ''),
'Failed asserting that user 1 successfully set an expiration date for the test.txt share.'
);
} catch (\Exception $e) {
@@ -467,17 +469,17 @@ class Test_Share extends \Test\TestCase {
}
public function testShareWithUserExpirationValid() {
- OC_User::setUserId($this->user1);
+ \OC_User::setUserId($this->user1);
$this->shareUserOneTestFileWithUserTwo();
$this->shareUserTestFileAsLink();
$this->assertTrue(
- OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInFuture, ''),
+ \OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInFuture, ''),
'Failed asserting that user 1 successfully set an expiration date for the test.txt share.'
);
- $shares = OCP\Share::getItemsShared('test');
+ $shares = \OCP\Share::getItemsShared('test');
$this->assertSame(2, count($shares));
}
@@ -488,14 +490,14 @@ class Test_Share extends \Test\TestCase {
*/
public function testShareWithUserAndUserIsExcludedFromResharing() {
- OC_User::setUserId($this->user1);
+ \OC_User::setUserId($this->user1);
$this->assertTrue(
- OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user4, \OCP\Constants::PERMISSION_ALL),
+ \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user4, \OCP\Constants::PERMISSION_ALL),
'Failed asserting that user 1 successfully shared text.txt with user 4.'
);
$this->assertContains(
'test.txt',
- OCP\Share::getItemShared('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
+ \OCP\Share::getItemShared('test', 'test.txt', Backend::FORMAT_SOURCE),
'Failed asserting that test.txt is a shared file of user 1.'
);
@@ -503,9 +505,9 @@ class Test_Share extends \Test\TestCase {
\OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups_list', $this->group2);
\OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups', "yes");
- OC_User::setUserId($this->user4);
+ \OC_User::setUserId($this->user4);
- $share = OCP\Share::getItemSharedWith('test', 'test.txt');
+ $share = \OCP\Share::getItemSharedWith('test', 'test.txt');
$this->assertSame(\OCP\Constants::PERMISSION_ALL & ~\OCP\Constants::PERMISSION_SHARE, $share['permissions'],
'Failed asserting that user 4 is excluded from re-sharing');
@@ -516,7 +518,7 @@ class Test_Share extends \Test\TestCase {
}
public function testSharingAFolderThatIsSharedWithAGroupOfTheOwner() {
- OC_User::setUserId($this->user1);
+ \OC_User::setUserId($this->user1);
$view = new \OC\Files\View('/' . $this->user1 . '/');
$view->mkdir('files/test');
$view->mkdir('files/test/sub1');
@@ -527,11 +529,11 @@ class Test_Share extends \Test\TestCase {
$fileId = $fileInfo->getId();
$this->assertTrue(
- OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_GROUP, $this->group1, \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_CREATE),
+ \OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_GROUP, $this->group1, \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_CREATE),
'Failed asserting that user 1 successfully shared "test/sub1" with group 1.'
);
- $result = OCP\Share::getItemShared('folder', $fileId, Test_Share_Backend::FORMAT_SOURCE);
+ $result = \OCP\Share::getItemShared('folder', $fileId, Backend::FORMAT_SOURCE);
$this->assertNotEmpty($result);
$this->assertEquals(\OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_CREATE, $result['permissions']);
@@ -540,17 +542,17 @@ class Test_Share extends \Test\TestCase {
$fileId = $fileInfo->getId();
$this->assertTrue(
- OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user4, \OCP\Constants::PERMISSION_READ),
+ \OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user4, \OCP\Constants::PERMISSION_READ),
'Failed asserting that user 1 successfully shared "test/sub1/sub2" with user 4.'
);
- $result = OCP\Share::getItemShared('folder', $fileId, Test_Share_Backend::FORMAT_SOURCE);
+ $result = \OCP\Share::getItemShared('folder', $fileId, Backend::FORMAT_SOURCE);
$this->assertNotEmpty($result);
$this->assertEquals(\OCP\Constants::PERMISSION_READ, $result['permissions']);
}
public function testSharingAFileInsideAFolderThatIsAlreadyShared() {
- OC_User::setUserId($this->user1);
+ \OC_User::setUserId($this->user1);
$view = new \OC\Files\View('/' . $this->user1 . '/');
$view->mkdir('files/test');
$view->mkdir('files/test/sub1');
@@ -565,12 +567,12 @@ class Test_Share extends \Test\TestCase {
$fileId = $fileInfo->getId();
$this->assertTrue(
- OCP\Share::shareItem('folder', $folderId, OCP\Share::SHARE_TYPE_GROUP, $this->group2, \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_UPDATE),
+ \OCP\Share::shareItem('folder', $folderId, \OCP\Share::SHARE_TYPE_GROUP, $this->group2, \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_UPDATE),
'Failed asserting that user 1 successfully shared "test/sub1" with group 2.'
);
$this->assertTrue(
- OCP\Share::shareItem('file', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ),
+ \OCP\Share::shareItem('file', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ),
'Failed asserting that user 1 successfully shared "test/sub1/file.txt" with user 2.'
);
@@ -585,28 +587,28 @@ class Test_Share extends \Test\TestCase {
}
protected function shareUserOneTestFileWithGroupOne() {
- OC_User::setUserId($this->user1);
+ \OC_User::setUserId($this->user1);
$this->assertTrue(
- OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group1, \OCP\Constants::PERMISSION_READ),
+ \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_GROUP, $this->group1, \OCP\Constants::PERMISSION_READ),
'Failed asserting that user 1 successfully shared text.txt with group 1.'
);
$this->assertContains(
'test.txt',
- OCP\Share::getItemShared('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
+ \OCP\Share::getItemShared('test', 'test.txt', Backend::FORMAT_SOURCE),
'Failed asserting that test.txt is a shared file of user 1.'
);
- OC_User::setUserId($this->user2);
+ \OC_User::setUserId($this->user2);
$this->assertContains(
'test.txt',
- OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
+ \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_SOURCE),
'Failed asserting that user 2 has access to test.txt after initial sharing.'
);
- OC_User::setUserId($this->user3);
+ \OC_User::setUserId($this->user3);
$this->assertContains(
'test.txt',
- OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
+ \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_SOURCE),
'Failed asserting that user 3 has access to test.txt after initial sharing.'
);
}
@@ -616,11 +618,11 @@ class Test_Share extends \Test\TestCase {
* child entries
*/
public function testShareWithGroupThenUnshare() {
- OC_User::setUserId($this->user5);
- OCP\Share::shareItem(
+ \OC_User::setUserId($this->user5);
+ \OCP\Share::shareItem(
'test',
'test.txt',
- OCP\Share::SHARE_TYPE_GROUP,
+ \OCP\Share::SHARE_TYPE_GROUP,
$this->group1,
\OCP\Constants::PERMISSION_ALL
);
@@ -628,30 +630,30 @@ class Test_Share extends \Test\TestCase {
$targetUsers = array($this->user1, $this->user2, $this->user3);
foreach($targetUsers as $targetUser) {
- OC_User::setUserId($targetUser);
- $items = OCP\Share::getItemsSharedWithUser(
+ \OC_User::setUserId($targetUser);
+ $items = \OCP\Share::getItemsSharedWithUser(
'test',
$targetUser,
- Test_Share_Backend::FORMAT_TARGET
+ Backend::FORMAT_TARGET
);
$this->assertEquals(1, count($items));
}
- OC_User::setUserId($this->user5);
- OCP\Share::unshare(
+ \OC_User::setUserId($this->user5);
+ \OCP\Share::unshare(
'test',
'test.txt',
- OCP\Share::SHARE_TYPE_GROUP,
+ \OCP\Share::SHARE_TYPE_GROUP,
$this->group1
);
// verify that all were deleted
foreach($targetUsers as $targetUser) {
- OC_User::setUserId($targetUser);
- $items = OCP\Share::getItemsSharedWithUser(
+ \OC_User::setUserId($targetUser);
+ $items = \OCP\Share::getItemsSharedWithUser(
'test',
$targetUser,
- Test_Share_Backend::FORMAT_TARGET
+ Backend::FORMAT_TARGET
);
$this->assertEquals(0, count($items));
}
@@ -661,33 +663,33 @@ class Test_Share extends \Test\TestCase {
$this->shareUserTestFileWithUser($this->user1, $this->groupAndUser);
- OC_User::setUserId($this->groupAndUser);
+ \OC_User::setUserId($this->groupAndUser);
- $this->assertEquals(array('test.txt'), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
+ $this->assertEquals(array('test.txt'), \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_SOURCE),
'"groupAndUser"-User does not see the file but it was shared with him');
- OC_User::setUserId($this->user2);
- $this->assertEquals(array(), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
+ \OC_User::setUserId($this->user2);
+ $this->assertEquals(array(), \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_SOURCE),
'User2 sees test.txt but it was only shared with the user "groupAndUser" and not with group');
- OC_User::setUserId($this->user1);
- $this->assertTrue(OCP\Share::unshareAll('test', 'test.txt'));
+ \OC_User::setUserId($this->user1);
+ $this->assertTrue(\OCP\Share::unshareAll('test', 'test.txt'));
$this->assertTrue(
- OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->groupAndUser, \OCP\Constants::PERMISSION_READ),
+ \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_GROUP, $this->groupAndUser, \OCP\Constants::PERMISSION_READ),
'Failed asserting that user 1 successfully shared text.txt with group 1.'
);
- OC_User::setUserId($this->groupAndUser);
- $this->assertEquals(array(), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
+ \OC_User::setUserId($this->groupAndUser);
+ $this->assertEquals(array(), \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_SOURCE),
'"groupAndUser"-User sees test.txt but it was only shared with the group "groupAndUser" and not with the user');
- OC_User::setUserId($this->user2);
- $this->assertEquals(array('test.txt'), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
+ \OC_User::setUserId($this->user2);
+ $this->assertEquals(array('test.txt'), \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_SOURCE),
'User2 does not see test.txt but it was shared with the group "groupAndUser"');
- OC_User::setUserId($this->user1);
- $this->assertTrue(OCP\Share::unshareAll('test', 'test.txt'));
+ \OC_User::setUserId($this->user1);
+ $this->assertTrue(\OCP\Share::unshareAll('test', 'test.txt'));
}
@@ -696,7 +698,7 @@ class Test_Share extends \Test\TestCase {
* @return array
*/
protected function getShareByValidToken($token) {
- $row = OCP\Share::getShareByToken($token);
+ $row = \OCP\Share::getShareByToken($token);
$this->assertInternalType(
'array',
$row,
@@ -706,21 +708,21 @@ class Test_Share extends \Test\TestCase {
}
public function testGetItemSharedWithUser() {
- OC_User::setUserId($this->user1);
+ \OC_User::setUserId($this->user1);
//add dummy values to the share table
$query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` ('
.' `item_type`, `item_source`, `item_target`, `share_type`,'
.' `share_with`, `uid_owner`) VALUES (?,?,?,?,?,?)');
- $args = array('test', 99, 'target1', OCP\Share::SHARE_TYPE_USER, $this->user2, $this->user1);
+ $args = array('test', 99, 'target1', \OCP\Share::SHARE_TYPE_USER, $this->user2, $this->user1);
$query->execute($args);
- $args = array('test', 99, 'target2', OCP\Share::SHARE_TYPE_USER, $this->user4, $this->user1);
+ $args = array('test', 99, 'target2', \OCP\Share::SHARE_TYPE_USER, $this->user4, $this->user1);
$query->execute($args);
- $args = array('test', 99, 'target3', OCP\Share::SHARE_TYPE_USER, $this->user3, $this->user2);
+ $args = array('test', 99, 'target3', \OCP\Share::SHARE_TYPE_USER, $this->user3, $this->user2);
$query->execute($args);
- $args = array('test', 99, 'target4', OCP\Share::SHARE_TYPE_USER, $this->user3, $this->user4);
+ $args = array('test', 99, 'target4', \OCP\Share::SHARE_TYPE_USER, $this->user3, $this->user4);
$query->execute($args);
- $args = array('test', 99, 'target4', OCP\Share::SHARE_TYPE_USER, $this->user6, $this->user4);
+ $args = array('test', 99, 'target4', \OCP\Share::SHARE_TYPE_USER, $this->user6, $this->user4);
$query->execute($args);
@@ -746,19 +748,19 @@ class Test_Share extends \Test\TestCase {
}
public function testGetItemSharedWithUserFromGroupShare() {
- OC_User::setUserId($this->user1);
+ \OC_User::setUserId($this->user1);
//add dummy values to the share table
$query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` ('
.' `item_type`, `item_source`, `item_target`, `share_type`,'
.' `share_with`, `uid_owner`) VALUES (?,?,?,?,?,?)');
- $args = array('test', 99, 'target1', OCP\Share::SHARE_TYPE_GROUP, $this->group1, $this->user1);
+ $args = array('test', 99, 'target1', \OCP\Share::SHARE_TYPE_GROUP, $this->group1, $this->user1);
$query->execute($args);
- $args = array('test', 99, 'target2', OCP\Share::SHARE_TYPE_GROUP, $this->group2, $this->user1);
+ $args = array('test', 99, 'target2', \OCP\Share::SHARE_TYPE_GROUP, $this->group2, $this->user1);
$query->execute($args);
- $args = array('test', 99, 'target3', OCP\Share::SHARE_TYPE_GROUP, $this->group1, $this->user2);
+ $args = array('test', 99, 'target3', \OCP\Share::SHARE_TYPE_GROUP, $this->group1, $this->user2);
$query->execute($args);
- $args = array('test', 99, 'target4', OCP\Share::SHARE_TYPE_GROUP, $this->group1, $this->user4);
+ $args = array('test', 99, 'target4', \OCP\Share::SHARE_TYPE_GROUP, $this->group1, $this->user4);
$query->execute($args);
// user2 is in group1 and group2
@@ -794,7 +796,7 @@ class Test_Share extends \Test\TestCase {
}
public function testGetShareSubItemsWhenUserNotInGroup() {
- OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group1, \OCP\Constants::PERMISSION_READ);
+ \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_GROUP, $this->group1, \OCP\Constants::PERMISSION_READ);
$result = \OCP\Share::getItemsSharedWithUser('test', $this->user2);
$this->assertCount(1, $result);
@@ -831,8 +833,8 @@ class Test_Share extends \Test\TestCase {
}
public function testShareItemWithLink() {
- OC_User::setUserId($this->user1);
- $token = OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ);
+ \OC_User::setUserId($this->user1);
+ $token = \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ);
$this->assertInternalType(
'string',
$token,
@@ -848,7 +850,7 @@ class Test_Share extends \Test\TestCase {
// testGetShareByTokenExpirationValid
$this->assertTrue(
- OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInFuture, ''),
+ \OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInFuture, ''),
'Failed asserting that user 1 successfully set a future expiration date for the test.txt share.'
);
$row = $this->getShareByValidToken($token);
@@ -867,20 +869,20 @@ class Test_Share extends \Test\TestCase {
$query->execute();
$this->assertFalse(
- OCP\Share::getShareByToken($token),
+ \OCP\Share::getShareByToken($token),
'Failed asserting that an expired share could not be found.'
);
}
public function testShareItemWithLinkAndDefaultExpireDate() {
- OC_User::setUserId($this->user1);
+ \OC_User::setUserId($this->user1);
$config = \OC::$server->getConfig();
$config->setAppValue('core', 'shareapi_default_expire_date', 'yes');
$config->setAppValue('core', 'shareapi_expire_after_n_days', '2');
- $token = OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ);
+ $token = \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ);
$this->assertInternalType(
'string',
$token,
@@ -925,8 +927,8 @@ class Test_Share extends \Test\TestCase {
* @expectedException \OC\HintException
*/
public function testShareWithRemoteUserAndRemoteIsInvalid($remoteId) {
- OC_User::setUserId($this->user1);
- OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_REMOTE, $remoteId, \OCP\Constants::PERMISSION_ALL);
+ \OC_User::setUserId($this->user1);
+ \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, $remoteId, \OCP\Constants::PERMISSION_ALL);
}
public function testUnshareAll() {
@@ -935,49 +937,49 @@ class Test_Share extends \Test\TestCase {
$this->shareUserTestFileWithUser($this->user3, $this->user4);
$this->shareUserOneTestFileWithGroupOne();
- OC_User::setUserId($this->user1);
+ \OC_User::setUserId($this->user1);
$this->assertEquals(
array('test.txt', 'test.txt'),
- OCP\Share::getItemsShared('test', Test_Share_Backend::FORMAT_SOURCE),
+ \OCP\Share::getItemsShared('test', Backend::FORMAT_SOURCE),
'Failed asserting that the test.txt file is shared exactly two times by user1.'
);
- OC_User::setUserId($this->user2);
+ \OC_User::setUserId($this->user2);
$this->assertEquals(
array('test.txt'),
- OCP\Share::getItemsShared('test', Test_Share_Backend::FORMAT_SOURCE),
+ \OCP\Share::getItemsShared('test', Backend::FORMAT_SOURCE),
'Failed asserting that the test.txt file is shared exactly once by user2.'
);
- OC_User::setUserId($this->user3);
+ \OC_User::setUserId($this->user3);
$this->assertEquals(
array('test.txt'),
- OCP\Share::getItemsShared('test', Test_Share_Backend::FORMAT_SOURCE),
+ \OCP\Share::getItemsShared('test', Backend::FORMAT_SOURCE),
'Failed asserting that the test.txt file is shared exactly once by user3.'
);
$this->assertTrue(
- OCP\Share::unshareAll('test', 'test.txt'),
+ \OCP\Share::unshareAll('test', 'test.txt'),
'Failed asserting that user 3 successfully unshared all shares of the test.txt share.'
);
$this->assertEquals(
array(),
- OCP\Share::getItemsShared('test'),
+ \OCP\Share::getItemsShared('test'),
'Failed asserting that the share of the test.txt file by user 3 has been removed.'
);
- OC_User::setUserId($this->user1);
+ \OC_User::setUserId($this->user1);
$this->assertEquals(
array(),
- OCP\Share::getItemsShared('test'),
+ \OCP\Share::getItemsShared('test'),
'Failed asserting that both shares of the test.txt file by user 1 have been removed.'
);
- OC_User::setUserId($this->user2);
+ \OC_User::setUserId($this->user2);
$this->assertEquals(
array(),
- OCP\Share::getItemsShared('test'),
+ \OCP\Share::getItemsShared('test'),
'Failed asserting that the share of the test.txt file by user 2 has been removed.'
);
}
@@ -1154,13 +1156,13 @@ class Test_Share extends \Test\TestCase {
* is enforced by the settings.
*/
public function testClearExpireDateWhileEnforced() {
- OC_User::setUserId($this->user1);
+ \OC_User::setUserId($this->user1);
\OC::$server->getAppConfig()->setValue('core', 'shareapi_default_expire_date', 'yes');
\OC::$server->getAppConfig()->setValue('core', 'shareapi_expire_after_n_days', '2');
\OC::$server->getAppConfig()->setValue('core', 'shareapi_enforce_expire_date', 'yes');
- $token = OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ);
+ $token = \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ);
$this->assertInternalType(
'string',
$token,
@@ -1170,7 +1172,7 @@ class Test_Share extends \Test\TestCase {
$setExpireDateFailed = false;
try {
$this->assertTrue(
- OCP\Share::setExpirationDate('test', 'test.txt', '', ''),
+ \OCP\Share::setExpirationDate('test', 'test.txt', '', ''),
'Failed asserting that user 1 successfully set an expiration date for the test.txt share.'
);
} catch (\Exception $e) {
@@ -1187,7 +1189,7 @@ class Test_Share extends \Test\TestCase {
/**
* Cannot set password is there is no user
*
- * @expectedException Exception
+ * @expectedException \Exception
* @expectedExceptionMessage User not logged in
*/
public function testSetPasswordNoUser() {
@@ -1305,7 +1307,7 @@ class Test_Share extends \Test\TestCase {
}
/**
- * @expectedException Exception
+ * @expectedException \Exception
* @expectedExceptionMessage Cannot remove password
*
* Test removing a password when password is enforced
@@ -1358,7 +1360,7 @@ class Test_Share extends \Test\TestCase {
}
/**
- * @expectedException Exception
+ * @expectedException \Exception
* @expectedExceptionMessage Share not found
*
* Test modification of invaid share
@@ -1411,7 +1413,7 @@ class Test_Share extends \Test\TestCase {
}
/**
- * @expectedException Exception
+ * @expectedException \Exception
* @expectedExceptionMessage Cannot update share of a different user
*
* Test modification of share of another user
@@ -1509,7 +1511,7 @@ class Test_Share extends \Test\TestCase {
// Expiration date
$expireAt = time() + 2 * 24*60*60;
- $date = new DateTime();
+ $date = new \DateTime();
$date->setTimestamp($expireAt);
$date->setTime(0, 0, 0);
@@ -1517,20 +1519,20 @@ class Test_Share extends \Test\TestCase {
$this->shareUserTestFileWithUser($this->user1, $this->user2);
//User 2 shares as link
- OC_User::setUserId($this->user2);
- $result = OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ);
+ \OC_User::setUserId($this->user2);
+ $result = \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ);
$this->assertTrue(is_string($result));
//Check if expire date is correct
- $result = OCP\Share::getItemShared('test', 'test.txt');
+ $result = \OCP\Share::getItemShared('test', 'test.txt');
$this->assertCount(1, $result);
$result = reset($result);
$this->assertNotEmpty($result['expiration']);
- $expireDate = new DateTime($result['expiration']);
+ $expireDate = new \DateTime($result['expiration']);
$this->assertEquals($date, $expireDate);
//Unshare
- $this->assertTrue(OCP\Share::unshareAll('test', 'test.txt'));
+ $this->assertTrue(\OCP\Share::unshareAll('test', 'test.txt'));
//Reset config
$config->deleteAppValue('core', 'shareapi_default_expire_date');
@@ -1541,7 +1543,7 @@ class Test_Share extends \Test\TestCase {
* Test case for #17560
*/
public function testAccesToSharedSubFolder() {
- OC_User::setUserId($this->user1);
+ \OC_User::setUserId($this->user1);
$view = new \OC\Files\View('/' . $this->user1 . '/');
$view->mkdir('files/folder1');
@@ -1550,11 +1552,11 @@ class Test_Share extends \Test\TestCase {
$fileId = $fileInfo->getId();
$this->assertTrue(
- OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_ALL),
+ \OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_ALL),
'Failed asserting that user 1 successfully shared "test" with user 2.'
);
$this->assertTrue(
- OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_ALL),
+ \OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_ALL),
'Failed asserting that user 1 successfully shared "test" with user 3.'
);
@@ -1565,28 +1567,28 @@ class Test_Share extends \Test\TestCase {
$fileId = $fileInfo->getId();
$this->assertTrue(
- OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user4, \OCP\Constants::PERMISSION_ALL),
+ \OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user4, \OCP\Constants::PERMISSION_ALL),
'Failed asserting that user 1 successfully shared "test" with user 4.'
);
- $res = OCP\Share::getItemShared(
+ $res = \OCP\Share::getItemShared(
'folder',
$fileId,
- OCP\Share::FORMAT_NONE,
+ \OCP\Share::FORMAT_NONE,
null,
true
);
$this->assertCount(3, $res);
$this->assertTrue(
- OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user5, \OCP\Constants::PERMISSION_ALL),
+ \OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user5, \OCP\Constants::PERMISSION_ALL),
'Failed asserting that user 1 successfully shared "test" with user 5.'
);
- $res = OCP\Share::getItemShared(
+ $res = \OCP\Share::getItemShared(
'folder',
$fileId,
- OCP\Share::FORMAT_NONE,
+ \OCP\Share::FORMAT_NONE,
null,
true
);
@@ -1594,7 +1596,7 @@ class Test_Share extends \Test\TestCase {
}
public function testShareWithSelfError() {
- OC_User::setUserId($this->user1);
+ \OC_User::setUserId($this->user1);
$view = new \OC\Files\View('/' . $this->user1 . '/');
$view->mkdir('files/folder1');
@@ -1603,7 +1605,7 @@ class Test_Share extends \Test\TestCase {
$fileId = $fileInfo->getId();
try {
- OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user1, \OCP\Constants::PERMISSION_ALL);
+ \OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user1, \OCP\Constants::PERMISSION_ALL);
$this->fail();
} catch (\Exception $e) {
$this->assertEquals('Sharing /folder1 failed, because you can not share with yourself', $e->getMessage());
@@ -1612,7 +1614,7 @@ class Test_Share extends \Test\TestCase {
public function testShareWithOwnerError() {
- OC_User::setUserId($this->user1);
+ \OC_User::setUserId($this->user1);
$view = new \OC\Files\View('/' . $this->user1 . '/');
$view->mkdir('files/folder1');
@@ -1621,13 +1623,13 @@ class Test_Share extends \Test\TestCase {
$fileId = $fileInfo->getId();
$this->assertTrue(
- OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_ALL),
+ \OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_ALL),
'Failed asserting that user 1 successfully shared "test" with user 2.'
);
- OC_User::setUserId($this->user2);
+ \OC_User::setUserId($this->user2);
try {
- OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user1, \OCP\Constants::PERMISSION_ALL);
+ \OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user1, \OCP\Constants::PERMISSION_ALL);
$this->fail();
} catch (\Exception $e) {
$this->assertEquals('Sharing failed, because the user ' . $this->user1 . ' is the original sharer', $e->getMessage());
diff --git a/tests/lib/updater/versioncheck.php b/tests/lib/updater/VersionCheckTest.php
index 2122ca28800..13851338eef 100644
--- a/tests/lib/updater/versioncheck.php
+++ b/tests/lib/updater/VersionCheckTest.php
@@ -20,7 +20,7 @@
*
*/
-namespace OC;
+namespace Test\Update;
use OC\Updater\VersionCheck;
use OCP\IConfig;
diff --git a/tests/lib/user/avataruserdummy.php b/tests/lib/user/avataruserdummy.php
index 086adb6043f..123825de50f 100644
--- a/tests/lib/user/avataruserdummy.php
+++ b/tests/lib/user/avataruserdummy.php
@@ -20,8 +20,10 @@
*
*/
-class Avatar_User_Dummy extends \Test\Util\User\Dummy {
+namespace Test\User;
+
+class AvatarUserDummy extends \Test\Util\User\Dummy {
public function canChangeAvatar($uid) {
return true;
}
-} \ No newline at end of file
+}
diff --git a/tests/lib/user/backend.php b/tests/lib/user/backend.php
index d5bbbe9f406..85ccbac913c 100644
--- a/tests/lib/user/backend.php
+++ b/tests/lib/user/backend.php
@@ -20,6 +20,8 @@
*
*/
+namespace Test\User;
+
/**
* Abstract class to provide the basis of backend-specific unit test classes.
*
@@ -30,7 +32,7 @@
* For an example see /tests/lib/user/dummy.php
*/
-abstract class Test_User_Backend extends \Test\TestCase {
+abstract class Backend extends \Test\TestCase {
/**
* @var \OC\User\Backend $backend
*/
diff --git a/tests/lib/user/database.php b/tests/lib/user/database.php
index 0dea037ad78..76d6226a7fd 100644
--- a/tests/lib/user/database.php
+++ b/tests/lib/user/database.php
@@ -20,12 +20,14 @@
*
*/
+namespace Test\User;
+
/**
* Class Test_User_Database
*
* @group DB
*/
-class Test_User_Database extends Test_User_Backend {
+class Database extends Backend {
/** @var array */
private $users;
diff --git a/tests/lib/user/dummy.php b/tests/lib/user/dummy.php
index c6c79d7a860..50382aa8fe6 100644
--- a/tests/lib/user/dummy.php
+++ b/tests/lib/user/dummy.php
@@ -20,7 +20,9 @@
*
*/
-class Test_User_Dummy extends Test_User_Backend {
+namespace Test\User;
+
+class Dummy extends Backend {
protected function setUp() {
parent::setUp();
$this->backend=new \Test\Util\User\Dummy();
diff --git a/tests/lib/user/user.php b/tests/lib/user/user.php
index 0a972f7bdaa..71be3691003 100644
--- a/tests/lib/user/user.php
+++ b/tests/lib/user/user.php
@@ -121,7 +121,7 @@ class User extends \Test\TestCase {
* @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
require_once 'avataruserdummy.php';
- $backend = $this->getMock('Avatar_User_Dummy');
+ $backend = $this->getMock('Test\User\AvatarUserDummy');
$backend->expects($this->once())
->method('canChangeAvatar')
->with($this->equalTo('foo'))
@@ -146,7 +146,7 @@ class User extends \Test\TestCase {
* @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
require_once 'avataruserdummy.php';
- $backend = $this->getMock('Avatar_User_Dummy');
+ $backend = $this->getMock('Test\User\AvatarUserDummy');
$backend->expects($this->once())
->method('canChangeAvatar')
->with($this->equalTo('foo'))
@@ -171,7 +171,7 @@ class User extends \Test\TestCase {
* @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
require_once 'avataruserdummy.php';
- $backend = $this->getMock('Avatar_User_Dummy');
+ $backend = $this->getMock('Test\User\AvatarUserDummy');
$backend->expects($this->never())
->method('canChangeAvatar');