summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authormbi <knox@users.noreply.github.com>2015-12-30 10:34:42 +0100
committermbi <knox@users.noreply.github.com>2015-12-30 10:34:42 +0100
commit63974992f9a0244df0bbff891956deec7d35904b (patch)
treea4152551e4a4366957e06572cf04e4e0e941f38f /tests
parent1aff941be6ea3c09e86e234b7e2dc77fe4aa3696 (diff)
parent45c41e2b2cefa97c9d8c3bc73cfc088839640d1d (diff)
downloadnextcloud-server-63974992f9a0244df0bbff891956deec7d35904b.tar.gz
nextcloud-server-63974992f9a0244df0bbff891956deec7d35904b.zip
Merge branch 'master' into master
Diffstat (limited to 'tests')
-rw-r--r--tests/core/avatar/avatarcontrollertest.php42
-rw-r--r--tests/lib/allconfig.php16
-rw-r--r--tests/lib/app/dependencyanalyzer.php3
-rw-r--r--tests/lib/app/infoparser.php3
-rw-r--r--tests/lib/app/manager.php3
-rw-r--r--tests/lib/appframework/utility/ControllerMethodReflectorTest.php23
-rw-r--r--tests/lib/avatartest.php15
-rw-r--r--tests/lib/backgroundjob/job.php11
-rw-r--r--tests/lib/backgroundjob/joblist.php13
-rw-r--r--tests/lib/cache/file.php2
-rw-r--r--tests/lib/comments/comment.php112
-rw-r--r--tests/lib/comments/fakefactory.php13
-rw-r--r--tests/lib/comments/fakemanager.php33
-rw-r--r--tests/lib/comments/manager.php564
-rw-r--r--tests/lib/configtests.php2
-rw-r--r--tests/lib/db/querybuilder/querybuildertest.php22
-rw-r--r--tests/lib/files/cache/cache.php5
-rw-r--r--tests/lib/files/cache/homecache.php2
-rw-r--r--tests/lib/files/cache/updaterlegacy.php7
-rw-r--r--tests/lib/files/etagtest.php2
-rw-r--r--tests/lib/files/filesystem.php26
-rw-r--r--tests/lib/files/node/file.php10
-rw-r--r--tests/lib/files/node/folder.php10
-rw-r--r--tests/lib/files/node/node.php10
-rw-r--r--tests/lib/files/objectstore/swift.php8
-rw-r--r--tests/lib/files/storage/commontest.php2
-rw-r--r--tests/lib/files/storage/home.php2
-rw-r--r--tests/lib/files/storage/homestoragequota.php10
-rw-r--r--tests/lib/files/storage/local.php2
-rw-r--r--tests/lib/files/storage/storage.php13
-rw-r--r--tests/lib/files/storage/wrapper/quota.php2
-rw-r--r--tests/lib/files/storage/wrapper/wrapper.php2
-rw-r--r--tests/lib/files/view.php2
-rw-r--r--tests/lib/group.php6
-rw-r--r--tests/lib/helper.php199
-rw-r--r--tests/lib/helperstorage.php5
-rw-r--r--tests/lib/installer.php6
-rw-r--r--tests/lib/lock/dblockingprovider.php8
-rw-r--r--tests/lib/security/certificatemanager.php5
-rw-r--r--tests/lib/security/securerandom.php7
-rw-r--r--tests/lib/security/stringutils.php38
-rw-r--r--tests/lib/server.php16
-rw-r--r--tests/lib/setup.php13
-rw-r--r--tests/lib/share/MailNotificationsTest.php4
-rw-r--r--tests/lib/share/helper.php37
-rw-r--r--tests/lib/share/share.php38
-rw-r--r--tests/lib/streamwrappers.php4
-rw-r--r--tests/lib/tags.php4
-rw-r--r--tests/lib/testcase.php28
-rw-r--r--tests/lib/updater.php2
-rw-r--r--tests/lib/user.php27
-rw-r--r--tests/lib/util.php2
-rw-r--r--tests/lib/utilcheckserver.php10
-rw-r--r--tests/phpunit-autotest-external.xml1
-rw-r--r--tests/startsessionlistener.php3
55 files changed, 1050 insertions, 405 deletions
diff --git a/tests/core/avatar/avatarcontrollertest.php b/tests/core/avatar/avatarcontrollertest.php
index a113add72b9..7f69ba0aadb 100644
--- a/tests/core/avatar/avatarcontrollertest.php
+++ b/tests/core/avatar/avatarcontrollertest.php
@@ -26,8 +26,10 @@ use OCP\AppFramework\IAppContainer;
use OCP\AppFramework\Http;
use OCP\Files\Folder;
use OCP\Files\File;
+use OCP\Files\NotFoundException;
use OCP\IUser;
use OCP\IAvatar;
+use Punic\Exception;
use Test\Traits\UserTrait;
/**
@@ -56,6 +58,8 @@ class AvatarControllerTest extends \Test\TestCase {
private $avatarMock;
/** @var IUser */
private $userMock;
+ /** @var File */
+ private $avatarFile;
protected function setUp() {
parent::setUp();
@@ -88,6 +92,10 @@ class AvatarControllerTest extends \Test\TestCase {
->willReturnMap([['userId', $this->userMock]]);
$this->container['UserSession']->method('getUser')->willReturn($this->userMock);
+ $this->avatarFile = $this->getMock('OCP\Files\File');
+ $this->avatarFile->method('getContnet')->willReturn('image data');
+ $this->avatarFile->method('getMimeType')->willReturn('image type');
+ $this->avatarFile->method('getEtag')->willReturn('my etag');
}
public function tearDown() {
@@ -100,6 +108,7 @@ class AvatarControllerTest extends \Test\TestCase {
*/
public function testGetAvatarNoAvatar() {
$this->container['AvatarManager']->method('getAvatar')->willReturn($this->avatarMock);
+ $this->avatarMock->method('getFile')->will($this->throwException(new NotFoundException()));
$response = $this->avatarController->getAvatar('userId', 32);
//Comment out until JS is fixed
@@ -112,12 +121,8 @@ class AvatarControllerTest extends \Test\TestCase {
* Fetch the user's avatar
*/
public function testGetAvatar() {
- $image = $this->getMock('OCP\IImage');
- $image->method('data')->willReturn('image data');
- $image->method('mimeType')->willReturn('image type');
-
- $this->avatarMock->method('get')->willReturn($image);
- $this->container['AvatarManager']->method('getAvatar')->willReturn($this->avatarMock);
+ $this->avatarMock->method('getFile')->willReturn($this->avatarFile);
+ $this->container['AvatarManager']->method('getAvatar')->with('userId')->willReturn($this->avatarMock);
$response = $this->avatarController->getAvatar('userId', 32);
@@ -125,17 +130,19 @@ class AvatarControllerTest extends \Test\TestCase {
$this->assertArrayHasKey('Content-Type', $response->getHeaders());
$this->assertEquals('image type', $response->getHeaders()['Content-Type']);
- $this->assertEquals(crc32('image data'), $response->getEtag());
+ $this->assertEquals('my etag', $response->getEtag());
}
/**
* Fetch the avatar of a non-existing user
*/
public function testGetAvatarNoUser() {
- $this->avatarMock->method('get')->willReturn(null);
- $this->container['AvatarManager']->method('getAvatar')->willReturn($this->avatarMock);
+ $this->container['AvatarManager']
+ ->method('getAvatar')
+ ->with('userDoesNotExist')
+ ->will($this->throwException(new \Exception('user does not exist')));
- $response = $this->avatarController->getAvatar('userDoesnotexist', 32);
+ $response = $this->avatarController->getAvatar('userDoesNotExist', 32);
//Comment out until JS is fixed
//$this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus());
@@ -148,8 +155,9 @@ class AvatarControllerTest extends \Test\TestCase {
*/
public function testGetAvatarSize() {
$this->avatarMock->expects($this->once())
- ->method('get')
- ->with($this->equalTo(32));
+ ->method('getFile')
+ ->with($this->equalTo(32))
+ ->willReturn($this->avatarFile);
$this->container['AvatarManager']->method('getAvatar')->willReturn($this->avatarMock);
@@ -161,8 +169,9 @@ class AvatarControllerTest extends \Test\TestCase {
*/
public function testGetAvatarSizeMin() {
$this->avatarMock->expects($this->once())
- ->method('get')
- ->with($this->equalTo(64));
+ ->method('getFile')
+ ->with($this->equalTo(64))
+ ->willReturn($this->avatarFile);
$this->container['AvatarManager']->method('getAvatar')->willReturn($this->avatarMock);
@@ -174,8 +183,9 @@ class AvatarControllerTest extends \Test\TestCase {
*/
public function testGetAvatarSizeMax() {
$this->avatarMock->expects($this->once())
- ->method('get')
- ->with($this->equalTo(2048));
+ ->method('getFile')
+ ->with($this->equalTo(2048))
+ ->willReturn($this->avatarFile);
$this->container['AvatarManager']->method('getAvatar')->willReturn($this->avatarMock);
diff --git a/tests/lib/allconfig.php b/tests/lib/allconfig.php
index ca3dce12eaf..0caf8163cfc 100644
--- a/tests/lib/allconfig.php
+++ b/tests/lib/allconfig.php
@@ -28,7 +28,9 @@ class TestAllConfig extends \Test\TestCase {
$connection = $this->connection;
}
if($systemConfig === null) {
- $systemConfig = $this->getMock('\OC\SystemConfig');
+ $systemConfig = $this->getMockBuilder('\OC\SystemConfig')
+ ->disableOriginalConstructor()
+ ->getMock();
}
return new \OC\AllConfig($systemConfig, $connection);
}
@@ -89,7 +91,9 @@ class TestAllConfig extends \Test\TestCase {
public function testSetUserValueWithPreCondition() {
// mock the check for the database to run the correct SQL statements for each database type
- $systemConfig = $this->getMock('\OC\SystemConfig');
+ $systemConfig = $this->getMockBuilder('\OC\SystemConfig')
+ ->disableOriginalConstructor()
+ ->getMock();
$systemConfig->expects($this->once())
->method('getValue')
->with($this->equalTo('dbtype'),
@@ -133,7 +137,9 @@ class TestAllConfig extends \Test\TestCase {
*/
public function testSetUserValueWithPreConditionFailure() {
// mock the check for the database to run the correct SQL statements for each database type
- $systemConfig = $this->getMock('\OC\SystemConfig');
+ $systemConfig = $this->getMockBuilder('\OC\SystemConfig')
+ ->disableOriginalConstructor()
+ ->getMock();
$systemConfig->expects($this->once())
->method('getValue')
->with($this->equalTo('dbtype'),
@@ -394,7 +400,9 @@ class TestAllConfig extends \Test\TestCase {
public function testGetUsersForUserValue() {
// mock the check for the database to run the correct SQL statements for each database type
- $systemConfig = $this->getMock('\OC\SystemConfig');
+ $systemConfig = $this->getMockBuilder('\OC\SystemConfig')
+ ->disableOriginalConstructor()
+ ->getMock();
$systemConfig->expects($this->once())
->method('getValue')
->with($this->equalTo('dbtype'),
diff --git a/tests/lib/app/dependencyanalyzer.php b/tests/lib/app/dependencyanalyzer.php
index 58f1c0a7a99..fecba518856 100644
--- a/tests/lib/app/dependencyanalyzer.php
+++ b/tests/lib/app/dependencyanalyzer.php
@@ -12,8 +12,9 @@ namespace Test\App;
use OC;
use OC\App\Platform;
use OCP\IL10N;
+use Test\TestCase;
-class DependencyAnalyzer extends \PHPUnit_Framework_TestCase {
+class DependencyAnalyzer extends TestCase {
/** @var Platform */
private $platformMock;
diff --git a/tests/lib/app/infoparser.php b/tests/lib/app/infoparser.php
index fb4ffe8af94..1e5257abec3 100644
--- a/tests/lib/app/infoparser.php
+++ b/tests/lib/app/infoparser.php
@@ -10,8 +10,9 @@
namespace Test\App;
use OC;
+use Test\TestCase;
-class InfoParser extends \PHPUnit_Framework_TestCase {
+class InfoParser extends TestCase {
/**
* @var \OC\App\InfoParser
diff --git a/tests/lib/app/manager.php b/tests/lib/app/manager.php
index 38358fd61cf..a3e55c6b890 100644
--- a/tests/lib/app/manager.php
+++ b/tests/lib/app/manager.php
@@ -11,8 +11,9 @@ namespace Test\App;
use OC\Group\Group;
use OC\User\User;
+use Test\TestCase;
-class Manager extends \PHPUnit_Framework_TestCase {
+class Manager extends TestCase {
/**
* @return \OCP\IAppConfig | \PHPUnit_Framework_MockObject_MockObject
*/
diff --git a/tests/lib/appframework/utility/ControllerMethodReflectorTest.php b/tests/lib/appframework/utility/ControllerMethodReflectorTest.php
index a584b5481ba..c643c362a9c 100644
--- a/tests/lib/appframework/utility/ControllerMethodReflectorTest.php
+++ b/tests/lib/appframework/utility/ControllerMethodReflectorTest.php
@@ -104,6 +104,29 @@ class ControllerMethodReflectorTest extends \Test\TestCase {
$this->assertEquals('int', $reader->getType('test'));
}
+ /**
+ * @Annotation
+ * @param int $a
+ * @param int $b
+ */
+ public function arguments3($a, float $b, int $c, $d){}
+
+ /**
+ * @requires PHP 7
+ */
+ public function testReadTypeIntAnnotationsScalarTypes(){
+ $reader = new ControllerMethodReflector();
+ $reader->reflect(
+ '\OC\AppFramework\Utility\ControllerMethodReflectorTest',
+ 'arguments3'
+ );
+
+ $this->assertEquals('int', $reader->getType('a'));
+ $this->assertEquals('float', $reader->getType('b'));
+ $this->assertEquals('int', $reader->getType('c'));
+ $this->assertNull($reader->getType('d'));
+ }
+
/**
* @Annotation
diff --git a/tests/lib/avatartest.php b/tests/lib/avatartest.php
index 49e8be98c83..3d77a282a7d 100644
--- a/tests/lib/avatartest.php
+++ b/tests/lib/avatartest.php
@@ -60,12 +60,25 @@ class AvatarTest extends \Test\TestCase {
$file = $this->getMock('\OCP\Files\File');
$file->method('getContent')->willReturn($expected->data());
- $this->folder->method('get')->with('avatar.png')->willReturn($file);
+
+ $this->folder->method('get')
+ ->will($this->returnCallback(
+ function($path) use ($file) {
+ if ($path === 'avatar.png') {
+ return $file;
+ } else {
+ throw new \OCP\Files\NotFoundException;
+ }
+ }
+ ));
$newFile = $this->getMock('\OCP\Files\File');
$newFile->expects($this->once())
->method('putContent')
->with($expected2->data());
+ $newFile->expects($this->once())
+ ->method('getContent')
+ ->willReturn($expected2->data());
$this->folder->expects($this->once())
->method('newFile')
->with('avatar.32.png')
diff --git a/tests/lib/backgroundjob/job.php b/tests/lib/backgroundjob/job.php
index fec9b0a792d..912e0e13b57 100644
--- a/tests/lib/backgroundjob/job.php
+++ b/tests/lib/backgroundjob/job.php
@@ -23,10 +23,17 @@ class Job extends \Test\TestCase {
});
$jobList->add($job);
+ $logger = $this->getMockBuilder('OCP\ILogger')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $logger->expects($this->once())
+ ->method('error')
+ ->with('Error while running background job: ');
+
$this->assertCount(1, $jobList->getAll());
- $job->execute($jobList);
+ $job->execute($jobList, $logger);
$this->assertTrue($this->run);
- $this->assertCount(0, $jobList->getAll());
+ $this->assertCount(1, $jobList->getAll());
}
public function markRun() {
diff --git a/tests/lib/backgroundjob/joblist.php b/tests/lib/backgroundjob/joblist.php
index 73b3255c079..c0796d8253a 100644
--- a/tests/lib/backgroundjob/joblist.php
+++ b/tests/lib/backgroundjob/joblist.php
@@ -15,26 +15,21 @@ use Test\TestCase;
* Class JobList
*
* @group DB
- *
* @package Test\BackgroundJob
*/
class JobList extends TestCase {
- /**
- * @var \OC\BackgroundJob\JobList
- */
+ /** @var \OC\BackgroundJob\JobList */
protected $instance;
- /**
- * @var \OCP\IConfig | \PHPUnit_Framework_MockObject_MockObject $config
- */
+ /** @var \OCP\IConfig|\PHPUnit_Framework_MockObject_MockObject */
protected $config;
protected function setUp() {
parent::setUp();
- $conn = \OC::$server->getDatabaseConnection();
+ $connection = \OC::$server->getDatabaseConnection();
$this->config = $this->getMock('\OCP\IConfig');
- $this->instance = new \OC\BackgroundJob\JobList($conn, $this->config);
+ $this->instance = new \OC\BackgroundJob\JobList($connection, $this->config);
}
protected function getAllSorted() {
diff --git a/tests/lib/cache/file.php b/tests/lib/cache/file.php
index 7aa969df02c..0880e7e1282 100644
--- a/tests/lib/cache/file.php
+++ b/tests/lib/cache/file.php
@@ -71,7 +71,7 @@ class FileCache extends \Test_Cache {
\OC_User::useBackend(new \Test\Util\User\Dummy());
//login
- \OC_User::createUser('test', 'test');
+ \OC::$server->getUserManager()->createUser('test', 'test');
$this->user = \OC_User::getUser();
\OC_User::setUserId('test');
diff --git a/tests/lib/comments/comment.php b/tests/lib/comments/comment.php
new file mode 100644
index 00000000000..02adea8729e
--- /dev/null
+++ b/tests/lib/comments/comment.php
@@ -0,0 +1,112 @@
+<?php
+
+namespace Test\Comments;
+
+use Test\TestCase;
+
+class Test_Comments_Comment extends TestCase
+{
+
+ public function testSettersValidInput() {
+ $comment = new \OC\Comments\Comment();
+
+ $id = 'comment23';
+ $parentId = 'comment11.5';
+ $childrenCount = 6;
+ $message = 'I like to comment comment';
+ $verb = 'comment';
+ $actor = ['type' => 'user', 'id' => 'alice'];
+ $creationDT = new \DateTime();
+ $latestChildDT = new \DateTime('yesterday');
+ $object = ['type' => 'file', 'id' => 'file64'];
+
+ $comment
+ ->setId($id)
+ ->setParentId($parentId)
+ ->setChildrenCount($childrenCount)
+ ->setMessage($message)
+ ->setVerb($verb)
+ ->setActor($actor['type'], $actor['id'])
+ ->setCreationDateTime($creationDT)
+ ->setLatestChildDateTime($latestChildDT)
+ ->setObject($object['type'], $object['id']);
+
+ $this->assertSame($id, $comment->getId());
+ $this->assertSame($parentId, $comment->getParentId());
+ $this->assertSame($childrenCount, $comment->getChildrenCount());
+ $this->assertSame($message, $comment->getMessage());
+ $this->assertSame($verb, $comment->getVerb());
+ $this->assertSame($actor['type'], $comment->getActorType());
+ $this->assertSame($actor['id'], $comment->getActorId());
+ $this->assertSame($creationDT, $comment->getCreationDateTime());
+ $this->assertSame($latestChildDT, $comment->getLatestChildDateTime());
+ $this->assertSame($object['type'], $comment->getObjectType());
+ $this->assertSame($object['id'], $comment->getObjectId());
+ }
+
+ /**
+ * @expectedException \OCP\Comments\IllegalIDChangeException
+ */
+ public function testSetIdIllegalInput() {
+ $comment = new \OC\Comments\Comment();
+
+ $comment->setId('c23');
+ $comment->setId('c17');
+ }
+
+ public function testResetId() {
+ $comment = new \OC\Comments\Comment();
+ $comment->setId('c23');
+ $comment->setId('');
+
+ $this->assertSame('', $comment->getId());
+ }
+
+ public function simpleSetterProvider() {
+ return [
+ ['Id', true],
+ ['ParentId', true],
+ ['Message', true],
+ ['Verb', true],
+ ['Verb', ''],
+ ['ChildrenCount', true],
+ ];
+ }
+
+ /**
+ * @dataProvider simpleSetterProvider
+ * @expectedException \InvalidArgumentException
+ */
+ public function testSimpleSetterInvalidInput($field, $input) {
+ $comment = new \OC\Comments\Comment();
+ $setter = 'set' . $field;
+
+ $comment->$setter($input);
+ }
+
+ public function roleSetterProvider() {
+ return [
+ ['Actor', true, true],
+ ['Actor', 'user', true],
+ ['Actor', true, 'alice'],
+ ['Actor', ' ', ' '],
+ ['Object', true, true],
+ ['Object', 'file', true],
+ ['Object', true, 'file64'],
+ ['Object', ' ', ' '],
+ ];
+ }
+
+ /**
+ * @dataProvider roleSetterProvider
+ * @expectedException \InvalidArgumentException
+ */
+ public function testSetRoleInvalidInput($role, $type, $id){
+ $comment = new \OC\Comments\Comment();
+ $setter = 'set' . $role;
+ $comment->$setter($type, $id);
+ }
+
+
+
+}
diff --git a/tests/lib/comments/fakefactory.php b/tests/lib/comments/fakefactory.php
new file mode 100644
index 00000000000..837bcb10585
--- /dev/null
+++ b/tests/lib/comments/fakefactory.php
@@ -0,0 +1,13 @@
+<?php
+
+namespace Test\Comments;
+
+/**
+ * Class FakeFactory
+ */
+class FakeFactory implements \OCP\Comments\ICommentsManagerFactory {
+
+ public function getManager() {
+ return new FakeManager();
+ }
+}
diff --git a/tests/lib/comments/fakemanager.php b/tests/lib/comments/fakemanager.php
new file mode 100644
index 00000000000..e5cf58dda4f
--- /dev/null
+++ b/tests/lib/comments/fakemanager.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace Test\Comments;
+
+/**
+ * Class FakeManager
+ */
+class FakeManager implements \OCP\Comments\ICommentsManager {
+
+ public function get($id) {}
+
+ public function getTree($id, $limit = 0, $offset = 0) {}
+
+ public function getForObject(
+ $objectType,
+ $objectId,
+ $limit = 0,
+ $offset = 0,
+ \DateTime $notOlderThan = null
+ ) {}
+
+ public function getNumberOfCommentsForObject($objectType, $objectId) {}
+
+ public function create($actorType, $actorId, $objectType, $objectId) {}
+
+ public function delete($id) {}
+
+ public function save(\OCP\Comments\IComment $comment) {}
+
+ public function deleteReferencesOfActor($actorType, $actorId) {}
+
+ public function deleteCommentsAtObject($objectType, $objectId) {}
+}
diff --git a/tests/lib/comments/manager.php b/tests/lib/comments/manager.php
new file mode 100644
index 00000000000..248de683253
--- /dev/null
+++ b/tests/lib/comments/manager.php
@@ -0,0 +1,564 @@
+<?php
+
+namespace Test\Comments;
+
+use OCP\Comments\ICommentsManager;
+use Test\TestCase;
+
+/**
+ * Class Test_Comments_Manager
+ *
+ * @group DB
+ */
+class Test_Comments_Manager extends TestCase
+{
+
+ public function setUp() {
+ parent::setUp();
+
+ $sql = \OC::$server->getDatabaseConnection()->getDatabasePlatform()->getTruncateTableSQL('`*PREFIX*comments`');
+ \OC::$server->getDatabaseConnection()->prepare($sql)->execute();
+ }
+
+ protected function addDatabaseEntry($parentId, $topmostParentId, $creationDT = null, $latestChildDT = null) {
+ if(is_null($creationDT)) {
+ $creationDT = new \DateTime();
+ }
+ if(is_null($latestChildDT)) {
+ $latestChildDT = new \DateTime('yesterday');
+ }
+
+ $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+ $qb
+ ->insert('comments')
+ ->values([
+ 'parent_id' => $qb->createNamedParameter($parentId),
+ 'topmost_parent_id' => $qb->createNamedParameter($topmostParentId),
+ 'children_count' => $qb->createNamedParameter(2),
+ 'actor_type' => $qb->createNamedParameter('user'),
+ 'actor_id' => $qb->createNamedParameter('alice'),
+ 'message' => $qb->createNamedParameter('nice one'),
+ 'verb' => $qb->createNamedParameter('comment'),
+ 'creation_timestamp' => $qb->createNamedParameter($creationDT, 'datetime'),
+ 'latest_child_timestamp' => $qb->createNamedParameter($latestChildDT, 'datetime'),
+ 'object_type' => $qb->createNamedParameter('file'),
+ 'object_id' => $qb->createNamedParameter('file64'),
+ ])
+ ->execute();
+
+ return $qb->getLastInsertId();
+ }
+
+ protected function getManager() {
+ $factory = new \OC\Comments\ManagerFactory();
+ return $factory->getManager();
+ }
+
+ /**
+ * @expectedException \OCP\Comments\NotFoundException
+ */
+ public function testGetCommentNotFound() {
+ $manager = $this->getManager();
+ $manager->get('22');
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testGetCommentNotFoundInvalidInput() {
+ $manager = $this->getManager();
+ $manager->get('unexisting22');
+ }
+
+ public function testGetComment() {
+ $manager = $this->getManager();
+
+ $creationDT = new \DateTime();
+ $latestChildDT = new \DateTime('yesterday');
+
+ $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+ $qb
+ ->insert('comments')
+ ->values([
+ 'parent_id' => $qb->createNamedParameter('2'),
+ 'topmost_parent_id' => $qb->createNamedParameter('1'),
+ 'children_count' => $qb->createNamedParameter(2),
+ 'actor_type' => $qb->createNamedParameter('user'),
+ 'actor_id' => $qb->createNamedParameter('alice'),
+ 'message' => $qb->createNamedParameter('nice one'),
+ 'verb' => $qb->createNamedParameter('comment'),
+ 'creation_timestamp' => $qb->createNamedParameter($creationDT, 'datetime'),
+ 'latest_child_timestamp' => $qb->createNamedParameter($latestChildDT, 'datetime'),
+ 'object_type' => $qb->createNamedParameter('file'),
+ 'object_id' => $qb->createNamedParameter('file64'),
+ ])
+ ->execute();
+
+ $id = strval($qb->getLastInsertId());
+
+ $comment = $manager->get($id);
+ $this->assertTrue($comment instanceof \OCP\Comments\IComment);
+ $this->assertSame($comment->getId(), $id);
+ $this->assertSame($comment->getParentId(), '2');
+ $this->assertSame($comment->getTopmostParentId(), '1');
+ $this->assertSame($comment->getChildrenCount(), 2);
+ $this->assertSame($comment->getActorType(), 'user');
+ $this->assertSame($comment->getActorId(), 'alice');
+ $this->assertSame($comment->getMessage(), 'nice one');
+ $this->assertSame($comment->getVerb(), 'comment');
+ $this->assertSame($comment->getObjectType(), 'file');
+ $this->assertSame($comment->getObjectId(), 'file64');
+ $this->assertEquals($comment->getCreationDateTime(), $creationDT);
+ $this->assertEquals($comment->getLatestChildDateTime(), $latestChildDT);
+ }
+
+ /**
+ * @expectedException \OCP\Comments\NotFoundException
+ */
+ public function testGetTreeNotFound() {
+ $manager = $this->getManager();
+ $manager->getTree('22');
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testGetTreeNotFoundInvalidIpnut() {
+ $manager = $this->getManager();
+ $manager->getTree('unexisting22');
+ }
+
+ public function testGetTree() {
+ $headId = $this->addDatabaseEntry(0, 0);
+
+ $this->addDatabaseEntry($headId, $headId, new \DateTime('-3 hours'));
+ $this->addDatabaseEntry($headId, $headId, new \DateTime('-2 hours'));
+ $id = $this->addDatabaseEntry($headId, $headId, new \DateTime('-1 hour'));
+
+ $manager = $this->getManager();
+ $tree = $manager->getTree($headId);
+
+ // Verifying the root comment
+ $this->assertTrue(isset($tree['comment']));
+ $this->assertTrue($tree['comment'] instanceof \OCP\Comments\IComment);
+ $this->assertSame($tree['comment']->getId(), strval($headId));
+ $this->assertTrue(isset($tree['replies']));
+ $this->assertSame(count($tree['replies']), 3);
+
+ // one level deep
+ foreach($tree['replies'] as $reply) {
+ $this->assertTrue($reply['comment'] instanceof \OCP\Comments\IComment);
+ $this->assertSame($reply['comment']->getId(), strval($id));
+ $this->assertSame(count($reply['replies']), 0);
+ $id--;
+ }
+ }
+
+ public function testGetTreeNoReplies() {
+ $id = $this->addDatabaseEntry(0, 0);
+
+ $manager = $this->getManager();
+ $tree = $manager->getTree($id);
+
+ // Verifying the root comment
+ $this->assertTrue(isset($tree['comment']));
+ $this->assertTrue($tree['comment'] instanceof \OCP\Comments\IComment);
+ $this->assertSame($tree['comment']->getId(), strval($id));
+ $this->assertTrue(isset($tree['replies']));
+ $this->assertSame(count($tree['replies']), 0);
+
+ // one level deep
+ foreach($tree['replies'] as $reply) {
+ throw new \Exception('This ain`t happen');
+ }
+ }
+
+ public function testGetTreeWithLimitAndOffset() {
+ $headId = $this->addDatabaseEntry(0, 0);
+
+ $this->addDatabaseEntry($headId, $headId, new \DateTime('-3 hours'));
+ $this->addDatabaseEntry($headId, $headId, new \DateTime('-2 hours'));
+ $this->addDatabaseEntry($headId, $headId, new \DateTime('-1 hour'));
+ $idToVerify = $this->addDatabaseEntry($headId, $headId, new \DateTime());
+
+ $manager = $this->getManager();
+
+ for ($offset = 0; $offset < 3; $offset += 2) {
+ $tree = $manager->getTree(strval($headId), 2, $offset);
+
+ // Verifying the root comment
+ $this->assertTrue(isset($tree['comment']));
+ $this->assertTrue($tree['comment'] instanceof \OCP\Comments\IComment);
+ $this->assertSame($tree['comment']->getId(), strval($headId));
+ $this->assertTrue(isset($tree['replies']));
+ $this->assertSame(count($tree['replies']), 2);
+
+ // one level deep
+ foreach ($tree['replies'] as $reply) {
+ $this->assertTrue($reply['comment'] instanceof \OCP\Comments\IComment);
+ $this->assertSame($reply['comment']->getId(), strval($idToVerify));
+ $this->assertSame(count($reply['replies']), 0);
+ $idToVerify--;
+ }
+ }
+ }
+
+ public function testGetForObject() {
+ $this->addDatabaseEntry(0, 0);
+
+ $manager = $this->getManager();
+ $comments = $manager->getForObject('file', 'file64');
+
+ $this->assertTrue(is_array($comments));
+ $this->assertSame(count($comments), 1);
+ $this->assertTrue($comments[0] instanceof \OCP\Comments\IComment);
+ $this->assertSame($comments[0]->getMessage(), 'nice one');
+ }
+
+ public function testGetForObjectWithLimitAndOffset() {
+ $this->addDatabaseEntry(0, 0, new \DateTime('-6 hours'));
+ $this->addDatabaseEntry(0, 0, new \DateTime('-5 hours'));
+ $this->addDatabaseEntry(1, 1, new \DateTime('-4 hours'));
+ $this->addDatabaseEntry(0, 0, new \DateTime('-3 hours'));
+ $this->addDatabaseEntry(2, 2, new \DateTime('-2 hours'));
+ $this->addDatabaseEntry(2, 2, new \DateTime('-1 hours'));
+ $idToVerify = $this->addDatabaseEntry(3, 1, new \DateTime());
+
+ $manager = $this->getManager();
+ $offset = 0;
+ do {
+ $comments = $manager->getForObject('file', 'file64', 3, $offset);
+
+ $this->assertTrue(is_array($comments));
+ foreach($comments as $comment) {
+ $this->assertTrue($comment instanceof \OCP\Comments\IComment);
+ $this->assertSame($comment->getMessage(), 'nice one');
+ $this->assertSame($comment->getId(), strval($idToVerify));
+ $idToVerify--;
+ }
+ $offset += 3;
+ } while(count($comments) > 0);
+ }
+
+ public function testGetForObjectWithDateTimeConstraint() {
+ $this->addDatabaseEntry(0, 0, new \DateTime('-6 hours'));
+ $this->addDatabaseEntry(0, 0, new \DateTime('-5 hours'));
+ $id1 = $this->addDatabaseEntry(0, 0, new \DateTime('-3 hours'));
+ $id2 = $this->addDatabaseEntry(2, 2, new \DateTime('-2 hours'));
+
+ $manager = $this->getManager();
+ $comments = $manager->getForObject('file', 'file64', 0, 0, new \DateTime('-4 hours'));
+
+ $this->assertSame(count($comments), 2);
+ $this->assertSame($comments[0]->getId(), strval($id2));
+ $this->assertSame($comments[1]->getId(), strval($id1));
+ }
+
+ public function testGetForObjectWithLimitAndOffsetAndDateTimeConstraint() {
+ $this->addDatabaseEntry(0, 0, new \DateTime('-7 hours'));
+ $this->addDatabaseEntry(0, 0, new \DateTime('-6 hours'));
+ $this->addDatabaseEntry(1, 1, new \DateTime('-5 hours'));
+ $this->addDatabaseEntry(0, 0, new \DateTime('-3 hours'));
+ $this->addDatabaseEntry(2, 2, new \DateTime('-2 hours'));
+ $this->addDatabaseEntry(2, 2, new \DateTime('-1 hours'));
+ $idToVerify = $this->addDatabaseEntry(3, 1, new \DateTime());
+
+ $manager = $this->getManager();
+ $offset = 0;
+ do {
+ $comments = $manager->getForObject('file', 'file64', 3, $offset, new \DateTime('-4 hours'));
+
+ $this->assertTrue(is_array($comments));
+ foreach($comments as $comment) {
+ $this->assertTrue($comment instanceof \OCP\Comments\IComment);
+ $this->assertSame($comment->getMessage(), 'nice one');
+ $this->assertSame($comment->getId(), strval($idToVerify));
+ $this->assertTrue(intval($comment->getId()) >= 4);
+ $idToVerify--;
+ }
+ $offset += 3;
+ } while(count($comments) > 0);
+ }
+
+ public function testGetNumberOfCommentsForObject() {
+ for($i = 1; $i < 5; $i++) {
+ $this->addDatabaseEntry(0, 0);
+ }
+
+ $manager = $this->getManager();
+
+ $amount = $manager->getNumberOfCommentsForObject('untype', '00');
+ $this->assertSame($amount, 0);
+
+ $amount = $manager->getNumberOfCommentsForObject('file', 'file64');
+ $this->assertSame($amount, 4);
+ }
+
+ public function invalidCreateArgsProvider() {
+ return [
+ ['', 'aId-1', 'oType-1', 'oId-1'],
+ ['aType-1', '', 'oType-1', 'oId-1'],
+ ['aType-1', 'aId-1', '', 'oId-1'],
+ ['aType-1', 'aId-1', 'oType-1', ''],
+ [1, 'aId-1', 'oType-1', 'oId-1'],
+ ['aType-1', 1, 'oType-1', 'oId-1'],
+ ['aType-1', 'aId-1', 1, 'oId-1'],
+ ['aType-1', 'aId-1', 'oType-1', 1],
+ ];
+ }
+
+ /**
+ * @dataProvider invalidCreateArgsProvider
+ * @expectedException \InvalidArgumentException
+ */
+ public function testCreateCommentInvalidArguments($aType, $aId, $oType, $oId) {
+ $manager = $this->getManager();
+ $manager->create($aType, $aId, $oType, $oId);
+ }
+
+ public function testCreateComment() {
+ $actorType = 'bot';
+ $actorId = 'bob';
+ $objectType = 'weather';
+ $objectId = 'bielefeld';
+
+ $comment = $this->getManager()->create($actorType, $actorId, $objectType, $objectId);
+ $this->assertTrue($comment instanceof \OCP\Comments\IComment);
+ $this->assertSame($comment->getActorType(), $actorType);
+ $this->assertSame($comment->getActorId(), $actorId);
+ $this->assertSame($comment->getObjectType(), $objectType);
+ $this->assertSame($comment->getObjectId(), $objectId);
+ }
+
+ /**
+ * @expectedException \OCP\Comments\NotFoundException
+ */
+ public function testDelete() {
+ $manager = $this->getManager();
+
+ $done = $manager->delete('404');
+ $this->assertFalse($done);
+
+ $done = $manager->delete('%');
+ $this->assertFalse($done);
+
+ $done = $manager->delete('');
+ $this->assertFalse($done);
+
+ $id = strval($this->addDatabaseEntry(0, 0));
+ $comment = $manager->get($id);
+ $this->assertTrue($comment instanceof \OCP\Comments\IComment);
+ $done = $manager->delete($id);
+ $this->assertTrue($done);
+ $manager->get($id);
+ }
+
+ public function testSaveNew() {
+ $manager = $this->getManager();
+ $comment = new \OC\Comments\Comment();
+ $comment
+ ->setActor('user', 'alice')
+ ->setObject('file', 'file64')
+ ->setMessage('very beautiful, I am impressed!')
+ ->setVerb('comment');
+
+ $saveSuccessful = $manager->save($comment);
+ $this->assertTrue($saveSuccessful);
+ $this->assertTrue($comment->getId() !== '');
+ $this->assertTrue($comment->getId() !== '0');
+ $this->assertTrue(!is_null($comment->getCreationDateTime()));
+
+ $loadedComment = $manager->get($comment->getId());
+ $this->assertSame($comment->getMessage(), $loadedComment->getMessage());
+ $this->assertEquals($comment->getCreationDateTime(), $loadedComment->getCreationDateTime());
+ }
+
+ public function testSaveUpdate() {
+ $manager = $this->getManager();
+ $comment = new \OC\Comments\Comment();
+ $comment
+ ->setActor('user', 'alice')
+ ->setObject('file', 'file64')
+ ->setMessage('very beautiful, I am impressed!')
+ ->setVerb('comment');
+
+ $manager->save($comment);
+
+ $comment->setMessage('very beautiful, I am really so much impressed!');
+ $manager->save($comment);
+
+ $loadedComment = $manager->get($comment->getId());
+ $this->assertSame($comment->getMessage(), $loadedComment->getMessage());
+ }
+
+ /**
+ * @expectedException \OCP\Comments\NotFoundException
+ */
+ public function testSaveUpdateException() {
+ $manager = $this->getManager();
+ $comment = new \OC\Comments\Comment();
+ $comment
+ ->setActor('user', 'alice')
+ ->setObject('file', 'file64')
+ ->setMessage('very beautiful, I am impressed!')
+ ->setVerb('comment');
+
+ $manager->save($comment);
+
+ $manager->delete($comment->getId());
+ $comment->setMessage('very beautiful, I am really so much impressed!');
+ $manager->save($comment);
+ }
+
+ /**
+ * @expectedException \UnexpectedValueException
+ */
+ public function testSaveIncomplete() {
+ $manager = $this->getManager();
+ $comment = new \OC\Comments\Comment();
+ $comment->setMessage('from no one to nothing');
+ $manager->save($comment);
+ }
+
+ public function testSaveAsChild() {
+ $id = $this->addDatabaseEntry(0, 0);
+
+ $manager = $this->getManager();
+
+ for($i = 0; $i < 3; $i++) {
+ $comment = new \OC\Comments\Comment();
+ $comment
+ ->setActor('user', 'alice')
+ ->setObject('file', 'file64')
+ ->setParentId(strval($id))
+ ->setMessage('full ack')
+ ->setVerb('comment')
+ // setting the creation time avoids using sleep() while making sure to test with different timestamps
+ ->setCreationDateTime(new \DateTime('+' . $i . ' minutes'));
+
+ $manager->save($comment);
+
+ $this->assertSame($comment->getTopmostParentId(), strval($id));
+ $parentComment = $manager->get(strval($id));
+ $this->assertSame($parentComment->getChildrenCount(), $i + 1);
+ $this->assertEquals($parentComment->getLatestChildDateTime(), $comment->getCreationDateTime());
+ }
+ }
+
+ public function invalidActorArgsProvider() {
+ return
+ [
+ ['', ''],
+ [1, 'alice'],
+ ['user', 1],
+ ];
+ }
+
+ /**
+ * @dataProvider invalidActorArgsProvider
+ * @expectedException \InvalidArgumentException
+ */
+ public function testDeleteReferencesOfActorInvalidInput($type, $id) {
+ $manager = $this->getManager();
+ $manager->deleteReferencesOfActor($type, $id);
+ }
+
+ public function testDeleteReferencesOfActor() {
+ $ids = [];
+ $ids[] = $this->addDatabaseEntry(0, 0);
+ $ids[] = $this->addDatabaseEntry(0, 0);
+ $ids[] = $this->addDatabaseEntry(0, 0);
+
+ $manager = $this->getManager();
+
+ // just to make sure they are really set, with correct actor data
+ $comment = $manager->get(strval($ids[1]));
+ $this->assertSame($comment->getActorType(), 'user');
+ $this->assertSame($comment->getActorId(), 'alice');
+
+ $wasSuccessful = $manager->deleteReferencesOfActor('user', 'alice');
+ $this->assertTrue($wasSuccessful);
+
+ foreach($ids as $id) {
+ $comment = $manager->get(strval($id));
+ $this->assertSame($comment->getActorType(), ICommentsManager::DELETED_USER);
+ $this->assertSame($comment->getActorId(), ICommentsManager::DELETED_USER);
+ }
+
+ // actor info is gone from DB, but when database interaction is alright,
+ // we still expect to get true back
+ $wasSuccessful = $manager->deleteReferencesOfActor('user', 'alice');
+ $this->assertTrue($wasSuccessful);
+ }
+
+ public function testDeleteReferencesOfActorWithUserManagement() {
+ $user = \OC::$server->getUserManager()->createUser('xenia', '123456');
+ $this->assertTrue($user instanceof \OCP\IUser);
+
+ $manager = \OC::$server->getCommentsManager();
+ $comment = $manager->create('user', $user->getUID(), 'file', 'file64');
+ $comment
+ ->setMessage('Most important comment I ever left on the Internet.')
+ ->setVerb('comment');
+ $status = $manager->save($comment);
+ $this->assertTrue($status);
+
+ $commentID = $comment->getId();
+ $user->delete();
+
+ $comment = $manager->get($commentID);
+ $this->assertSame($comment->getActorType(), \OCP\Comments\ICommentsManager::DELETED_USER);
+ $this->assertSame($comment->getActorId(), \OCP\Comments\ICommentsManager::DELETED_USER);
+ }
+
+ public function invalidObjectArgsProvider() {
+ return
+ [
+ ['', ''],
+ [1, 'file64'],
+ ['file', 1],
+ ];
+ }
+
+ /**
+ * @dataProvider invalidObjectArgsProvider
+ * @expectedException \InvalidArgumentException
+ */
+ public function testDeleteCommentsAtObjectInvalidInput($type, $id) {
+ $manager = $this->getManager();
+ $manager->deleteCommentsAtObject($type, $id);
+ }
+
+ public function testDeleteCommentsAtObject() {
+ $ids = [];
+ $ids[] = $this->addDatabaseEntry(0, 0);
+ $ids[] = $this->addDatabaseEntry(0, 0);
+ $ids[] = $this->addDatabaseEntry(0, 0);
+
+ $manager = $this->getManager();
+
+ // just to make sure they are really set, with correct actor data
+ $comment = $manager->get(strval($ids[1]));
+ $this->assertSame($comment->getObjectType(), 'file');
+ $this->assertSame($comment->getObjectId(), 'file64');
+
+ $wasSuccessful = $manager->deleteCommentsAtObject('file', 'file64');
+ $this->assertTrue($wasSuccessful);
+
+ $verified = 0;
+ foreach($ids as $id) {
+ try {
+ $manager->get(strval($id));
+ } catch (\OCP\Comments\NotFoundException $e) {
+ $verified++;
+ }
+ }
+ $this->assertSame($verified, 3);
+
+ // actor info is gone from DB, but when database interaction is alright,
+ // we still expect to get true back
+ $wasSuccessful = $manager->deleteCommentsAtObject('file', 'file64');
+ $this->assertTrue($wasSuccessful);
+ }
+
+}
diff --git a/tests/lib/configtests.php b/tests/lib/configtests.php
index 0269ae542f4..c0251e693c6 100644
--- a/tests/lib/configtests.php
+++ b/tests/lib/configtests.php
@@ -23,7 +23,7 @@ class ConfigTests extends TestCase {
protected function setUp() {
parent::setUp();
- $this->randomTmpDir = \OC_Helper::tmpFolder();
+ $this->randomTmpDir = \OC::$server->getTempManager()->getTemporaryFolder();
$this->configFile = $this->randomTmpDir.'testconfig.php';
file_put_contents($this->configFile, self::TESTCONTENT);
$this->config = new \OC\Config($this->randomTmpDir, 'testconfig.php');
diff --git a/tests/lib/db/querybuilder/querybuildertest.php b/tests/lib/db/querybuilder/querybuildertest.php
index c8e029d9e40..de8f84ac345 100644
--- a/tests/lib/db/querybuilder/querybuildertest.php
+++ b/tests/lib/db/querybuilder/querybuildertest.php
@@ -1124,11 +1124,12 @@ class QueryBuilderTest extends \Test\TestCase {
$this->assertTrue(true);
}
- $qB->insert('appconfig')
+ $qB->insert('properties')
->values([
- 'appid' => $qB->expr()->literal('testFirstResult'),
- 'configkey' => $qB->expr()->literal('testing' . 50),
- 'configvalue' => $qB->expr()->literal(100 - 50),
+ 'userid' => $qB->expr()->literal('testFirstResult'),
+ 'propertypath' => $qB->expr()->literal('testing'),
+ 'propertyname' => $qB->expr()->literal('testing'),
+ 'propertyvalue' => $qB->expr()->literal('testing'),
])
->execute();
@@ -1136,7 +1137,18 @@ class QueryBuilderTest extends \Test\TestCase {
$this->assertNotNull($actual);
$this->assertInternalType('int', $actual);
- $this->assertEquals($this->connection->lastInsertId('*PREFIX*appconfig'), $actual);
+ $this->assertEquals($this->connection->lastInsertId('*PREFIX*properties'), $actual);
+
+ $qB->delete('properties')
+ ->where($qB->expr()->eq('userid', $qB->expr()->literal('testFirstResult')))
+ ->execute();
+
+ try {
+ $qB->getLastInsertId();
+ $this->fail('getLastInsertId() should throw an exception, when being called after delete()');
+ } catch (\BadMethodCallException $e) {
+ $this->assertTrue(true);
+ }
}
public function dataGetTableName() {
diff --git a/tests/lib/files/cache/cache.php b/tests/lib/files/cache/cache.php
index 503d25597cd..d674ac27fa1 100644
--- a/tests/lib/files/cache/cache.php
+++ b/tests/lib/files/cache/cache.php
@@ -317,7 +317,7 @@ class Cache extends \Test\TestCase {
function testSearchByTag() {
$userId = $this->getUniqueId('user');
- \OC_User::createUser($userId, $userId);
+ \OC::$server->getUserManager()->createUser($userId, $userId);
$this->loginAsUser($userId);
$user = new \OC\User\User($userId, null);
@@ -373,7 +373,8 @@ class Cache extends \Test\TestCase {
$tagManager->delete('tag2');
$this->logout();
- \OC_User::deleteUser($userId);
+ $user = \OC::$server->getUserManager()->get($userId);
+ if ($user !== null) { $user->delete(); }
}
function testMove() {
diff --git a/tests/lib/files/cache/homecache.php b/tests/lib/files/cache/homecache.php
index 3adb25fa9d4..e133d0afc55 100644
--- a/tests/lib/files/cache/homecache.php
+++ b/tests/lib/files/cache/homecache.php
@@ -69,7 +69,7 @@ class HomeCache extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->user = new DummyUser('foo', \OC_Helper::tmpFolder());
+ $this->user = new DummyUser('foo', \OC::$server->getTempManager()->getTemporaryFolder());
$this->storage = new \OC\Files\Storage\Home(array('user' => $this->user));
$this->cache = $this->storage->getCache();
}
diff --git a/tests/lib/files/cache/updaterlegacy.php b/tests/lib/files/cache/updaterlegacy.php
index 1946913bba4..09688afd465 100644
--- a/tests/lib/files/cache/updaterlegacy.php
+++ b/tests/lib/files/cache/updaterlegacy.php
@@ -57,7 +57,7 @@ class UpdaterLegacy extends \Test\TestCase {
self::$user = $this->getUniqueID();
}
- \OC_User::createUser(self::$user, 'password');
+ \OC::$server->getUserManager()->createUser(self::$user, 'password');
$this->loginAsUser(self::$user);
Filesystem::init(self::$user, '/' . self::$user . '/files');
@@ -72,7 +72,10 @@ class UpdaterLegacy extends \Test\TestCase {
if ($this->cache) {
$this->cache->clear();
}
- $result = \OC_User::deleteUser(self::$user);
+
+ $result = false;
+ $user = \OC::$server->getUserManager()->get(self::$user);
+ if ($user !== null) { $result = $user->delete(); }
$this->assertTrue($result);
$this->logout();
diff --git a/tests/lib/files/etagtest.php b/tests/lib/files/etagtest.php
index c214a3d4da6..d8e44000f9c 100644
--- a/tests/lib/files/etagtest.php
+++ b/tests/lib/files/etagtest.php
@@ -39,7 +39,7 @@ class EtagTest extends \Test\TestCase {
$config = \OC::$server->getConfig();
$this->datadir = $config->getSystemValue('datadirectory');
- $this->tmpDir = \OC_Helper::tmpFolder();
+ $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder();
$config->setSystemValue('datadirectory', $this->tmpDir);
$this->userBackend = new \Test\Util\User\Dummy();
diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php
index c5ebbdd1a2d..db1f22f894a 100644
--- a/tests/lib/files/filesystem.php
+++ b/tests/lib/files/filesystem.php
@@ -72,7 +72,7 @@ class Filesystem extends \Test\TestCase {
* @return array
*/
private function getStorageData() {
- $dir = \OC_Helper::tmpFolder();
+ $dir = \OC::$server->getTempManager()->getTemporaryFolder();
$this->tmpDirs[] = $dir;
return array('datadir' => $dir);
}
@@ -302,7 +302,7 @@ class Filesystem extends \Test\TestCase {
\OC\Files\Filesystem::mkdir('/bar');
// \OC\Files\Filesystem::file_put_contents('/bar//foo', 'foo');
- $tmpFile = \OC_Helper::tmpFile();
+ $tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
file_put_contents($tmpFile, 'foo');
$fh = fopen($tmpFile, 'r');
// \OC\Files\Filesystem::file_put_contents('/bar//foo', $fh);
@@ -325,7 +325,7 @@ class Filesystem extends \Test\TestCase {
public function testHomeMount() {
$userId = $this->getUniqueID('user_');
- \OC_User::createUser($userId, $userId);
+ \OC::$server->getUserManager()->createUser($userId, $userId);
\OC\Files\Filesystem::initMountPoints($userId);
@@ -340,7 +340,8 @@ class Filesystem extends \Test\TestCase {
$this->assertEquals('home::' . $userId, $homeMount->getId());
}
- \OC_User::deleteUser($userId);
+ $user = \OC::$server->getUserManager()->get($userId);
+ if ($user !== null) { $user->delete(); }
}
/**
@@ -360,7 +361,7 @@ class Filesystem extends \Test\TestCase {
// this will trigger the insert
$cache = $localStorage->getCache();
- \OC_User::createUser($userId, $userId);
+ \OC::$server->getUserManager()->createUser($userId, $userId);
\OC\Files\Filesystem::initMountPoints($userId);
$homeMount = \OC\Files\Filesystem::getStorage('/' . $userId . '/');
@@ -368,7 +369,8 @@ class Filesystem extends \Test\TestCase {
$this->assertTrue($homeMount->instanceOfStorage('\OC\Files\Storage\Home'));
$this->assertEquals('local::' . $datadir . '/' . $userId . '/', $homeMount->getId());
- \OC_User::deleteUser($userId);
+ $user = \OC::$server->getUserManager()->get($userId);
+ if ($user !== null) { $user->delete(); }
// delete storage entry
$cache->clear();
}
@@ -388,7 +390,7 @@ class Filesystem extends \Test\TestCase {
// no cache path configured
$config->setSystemValue('cache_path', '');
- \OC_User::createUser($userId, $userId);
+ \OC::$server->getUserManager()->createUser($userId, $userId);
\OC\Files\Filesystem::initMountPoints($userId);
$this->assertEquals(
@@ -398,7 +400,8 @@ class Filesystem extends \Test\TestCase {
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath('/' . $userId . '/cache');
$this->assertTrue($storage->instanceOfStorage('\OCP\Files\IHomeStorage'));
$this->assertEquals('cache', $internalPath);
- \OC_User::deleteUser($userId);
+ $user = \OC::$server->getUserManager()->get($userId);
+ if ($user !== null) { $user->delete(); }
$config->setSystemValue('cache_path', $oldCachePath);
}
@@ -413,10 +416,10 @@ class Filesystem extends \Test\TestCase {
$config = \OC::$server->getConfig();
$oldCachePath = $config->getSystemValue('cache_path', '');
// set cache path to temp dir
- $cachePath = \OC_Helper::tmpFolder() . '/extcache';
+ $cachePath = \OC::$server->getTempManager()->getTemporaryFolder() . '/extcache';
$config->setSystemValue('cache_path', $cachePath);
- \OC_User::createUser($userId, $userId);
+ \OC::$server->getUserManager()->createUser($userId, $userId);
\OC\Files\Filesystem::initMountPoints($userId);
$this->assertEquals(
@@ -426,7 +429,8 @@ class Filesystem extends \Test\TestCase {
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath('/' . $userId . '/cache');
$this->assertTrue($storage->instanceOfStorage('\OC\Files\Storage\Local'));
$this->assertEquals('', $internalPath);
- \OC_User::deleteUser($userId);
+ $user = \OC::$server->getUserManager()->get($userId);
+ if ($user !== null) { $user->delete(); }
$config->setSystemValue('cache_path', $oldCachePath);
}
diff --git a/tests/lib/files/node/file.php b/tests/lib/files/node/file.php
index d0072949c7f..ccc777c499f 100644
--- a/tests/lib/files/node/file.php
+++ b/tests/lib/files/node/file.php
@@ -21,8 +21,16 @@ class File extends \Test\TestCase {
$this->user = new \OC\User\User('', new \Test\Util\User\Dummy);
}
+ protected function getMockStorage() {
+ $storage = $this->getMock('\OCP\Files\Storage');
+ $storage->expects($this->any())
+ ->method('getId')
+ ->will($this->returnValue('home::someuser'));
+ return $storage;
+ }
+
protected function getFileInfo($data) {
- return new FileInfo('', null, '', $data, null);
+ return new FileInfo('', $this->getMockStorage(), '', $data, null);
}
public function testDelete() {
diff --git a/tests/lib/files/node/folder.php b/tests/lib/files/node/folder.php
index d95e1b5d2b2..09bf32561e6 100644
--- a/tests/lib/files/node/folder.php
+++ b/tests/lib/files/node/folder.php
@@ -31,8 +31,16 @@ class Folder extends \Test\TestCase {
$this->user = new \OC\User\User('', new \Test\Util\User\Dummy);
}
+ protected function getMockStorage() {
+ $storage = $this->getMock('\OCP\Files\Storage');
+ $storage->expects($this->any())
+ ->method('getId')
+ ->will($this->returnValue('home::someuser'));
+ return $storage;
+ }
+
protected function getFileInfo($data) {
- return new FileInfo('', null, '', $data, null);
+ return new FileInfo('', $this->getMockStorage(), '', $data, null);
}
public function testDelete() {
diff --git a/tests/lib/files/node/node.php b/tests/lib/files/node/node.php
index afcf4cbabaa..a1693b034fa 100644
--- a/tests/lib/files/node/node.php
+++ b/tests/lib/files/node/node.php
@@ -18,8 +18,16 @@ class Node extends \Test\TestCase {
$this->user = new \OC\User\User('', new \Test\Util\User\Dummy);
}
+ protected function getMockStorage() {
+ $storage = $this->getMock('\OCP\Files\Storage');
+ $storage->expects($this->any())
+ ->method('getId')
+ ->will($this->returnValue('home::someuser'));
+ return $storage;
+ }
+
protected function getFileInfo($data) {
- return new FileInfo('', null, '', $data, null);
+ return new FileInfo('', $this->getMockStorage(), '', $data, null);
}
public function testStat() {
diff --git a/tests/lib/files/objectstore/swift.php b/tests/lib/files/objectstore/swift.php
index 63332af68da..a63f5844145 100644
--- a/tests/lib/files/objectstore/swift.php
+++ b/tests/lib/files/objectstore/swift.php
@@ -51,8 +51,9 @@ class Swift extends \Test\Files\Storage\Storage {
// create users
$users = array('test');
foreach($users as $userName) {
- \OC_User::deleteUser($userName);
- \OC_User::createUser($userName, $userName);
+ $user = \OC::$server->getUserManager()->get($userName);
+ if ($user !== null) { $user->delete(); }
+ \OC::$server->getUserManager()->createUser($userName, $userName);
}
// main test user
@@ -76,7 +77,8 @@ class Swift extends \Test\Files\Storage\Storage {
$users = array('test');
foreach($users as $userName) {
- \OC_User::deleteUser($userName);
+ $user = \OC::$server->getUserManager()->get($userName);
+ if ($user !== null) { $user->delete(); }
}
parent::tearDown();
}
diff --git a/tests/lib/files/storage/commontest.php b/tests/lib/files/storage/commontest.php
index bbe6f2a73e2..38faa9b0b21 100644
--- a/tests/lib/files/storage/commontest.php
+++ b/tests/lib/files/storage/commontest.php
@@ -37,7 +37,7 @@ class CommonTest extends Storage {
protected function setUp() {
parent::setUp();
- $this->tmpDir=\OC_Helper::tmpFolder();
+ $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder();
$this->instance=new \OC\Files\Storage\CommonTest(array('datadir'=>$this->tmpDir));
}
diff --git a/tests/lib/files/storage/home.php b/tests/lib/files/storage/home.php
index a51912ca1b2..7e10f09d554 100644
--- a/tests/lib/files/storage/home.php
+++ b/tests/lib/files/storage/home.php
@@ -70,7 +70,7 @@ class Home extends Storage {
protected function setUp() {
parent::setUp();
- $this->tmpDir = \OC_Helper::tmpFolder();
+ $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder();
$this->userId = $this->getUniqueID('user_');
$this->user = new DummyUser($this->userId, $this->tmpDir);
$this->instance = new \OC\Files\Storage\Home(array('user' => $this->user));
diff --git a/tests/lib/files/storage/homestoragequota.php b/tests/lib/files/storage/homestoragequota.php
index 49e8f499efd..9a3c6b151fc 100644
--- a/tests/lib/files/storage/homestoragequota.php
+++ b/tests/lib/files/storage/homestoragequota.php
@@ -32,7 +32,7 @@ class HomeStorageQuota extends \Test\TestCase {
*/
function testHomeStorageWrapperWithoutQuota() {
$user1 = $this->getUniqueID();
- \OC_User::createUser($user1, 'test');
+ \OC::$server->getUserManager()->createUser($user1, 'test');
\OC::$server->getConfig()->setUserValue($user1, 'files', 'quota', 'none');
\OC_User::setUserId($user1);
@@ -44,7 +44,8 @@ class HomeStorageQuota extends \Test\TestCase {
// clean up
\OC_User::setUserId('');
- \OC_User::deleteUser($user1);
+ $user = \OC::$server->getUserManager()->get($user1);
+ if ($user !== null) { $user->delete(); }
\OC::$server->getConfig()->deleteAllUserValues($user1);
\OC_Util::tearDownFS();
}
@@ -54,7 +55,7 @@ class HomeStorageQuota extends \Test\TestCase {
*/
function testHomeStorageWrapperWithQuota() {
$user1 = $this->getUniqueID();
- \OC_User::createUser($user1, 'test');
+ \OC::$server->getUserManager()->createUser($user1, 'test');
\OC::$server->getConfig()->setUserValue($user1, 'files', 'quota', '1024');
\OC_User::setUserId($user1);
@@ -71,7 +72,8 @@ class HomeStorageQuota extends \Test\TestCase {
// clean up
\OC_User::setUserId('');
- \OC_User::deleteUser($user1);
+ $user = \OC::$server->getUserManager()->get($user1);
+ if ($user !== null) { $user->delete(); }
\OC::$server->getConfig()->deleteAllUserValues($user1);
\OC_Util::tearDownFS();
}
diff --git a/tests/lib/files/storage/local.php b/tests/lib/files/storage/local.php
index 36267dc6605..2583863b554 100644
--- a/tests/lib/files/storage/local.php
+++ b/tests/lib/files/storage/local.php
@@ -38,7 +38,7 @@ class Local extends Storage {
protected function setUp() {
parent::setUp();
- $this->tmpDir = \OC_Helper::tmpFolder();
+ $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder();
$this->instance = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir));
}
diff --git a/tests/lib/files/storage/storage.php b/tests/lib/files/storage/storage.php
index d381b4cdf40..95dd70bfdac 100644
--- a/tests/lib/files/storage/storage.php
+++ b/tests/lib/files/storage/storage.php
@@ -598,4 +598,17 @@ abstract class Storage extends \Test\TestCase {
$this->instance->mkdir('source');
$this->assertTrue($this->instance->isSharable('source'));
}
+
+ public function testStatAfterWrite() {
+ $this->instance->file_put_contents('foo.txt', 'bar');
+ $stat = $this->instance->stat('foo.txt');
+ $this->assertEquals(3, $stat['size']);
+
+ $fh = $this->instance->fopen('foo.txt', 'w');
+ fwrite($fh, 'qwerty');
+ fclose($fh);
+
+ $stat = $this->instance->stat('foo.txt');
+ $this->assertEquals(6, $stat['size']);
+ }
}
diff --git a/tests/lib/files/storage/wrapper/quota.php b/tests/lib/files/storage/wrapper/quota.php
index b0a06b0d898..95bc2ff7a1a 100644
--- a/tests/lib/files/storage/wrapper/quota.php
+++ b/tests/lib/files/storage/wrapper/quota.php
@@ -27,7 +27,7 @@ class Quota extends \Test\Files\Storage\Storage {
protected function setUp() {
parent::setUp();
- $this->tmpDir = \OC_Helper::tmpFolder();
+ $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder();
$storage = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir));
$this->instance = new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => 10000000));
}
diff --git a/tests/lib/files/storage/wrapper/wrapper.php b/tests/lib/files/storage/wrapper/wrapper.php
index 486cd0495c1..a5a678cb9f7 100644
--- a/tests/lib/files/storage/wrapper/wrapper.php
+++ b/tests/lib/files/storage/wrapper/wrapper.php
@@ -17,7 +17,7 @@ class Wrapper extends \Test\Files\Storage\Storage {
protected function setUp() {
parent::setUp();
- $this->tmpDir = \OC_Helper::tmpFolder();
+ $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder();
$storage = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir));
$this->instance = new \OC\Files\Storage\Wrapper\Wrapper(array('storage' => $storage));
}
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 1fc4b9ab684..3e88a5306f8 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -757,7 +757,7 @@ class View extends \Test\TestCase {
* 228 is the max path length in windows
*/
$folderName = 'abcdefghijklmnopqrstuvwxyz012345678901234567890123456789';
- $tmpdirLength = strlen(\OC_Helper::tmpFolder());
+ $tmpdirLength = strlen(\OC::$server->getTempManager()->getTemporaryFolder());
if (\OC_Util::runningOnWindows()) {
$this->markTestSkipped('[Windows] ');
$depth = ((260 - $tmpdirLength) / 57);
diff --git a/tests/lib/group.php b/tests/lib/group.php
index 066dddc738e..4bb888ed725 100644
--- a/tests/lib/group.php
+++ b/tests/lib/group.php
@@ -31,7 +31,7 @@ class Test_Group extends \Test\TestCase {
public function testSingleBackend() {
$userBackend = new \Test\Util\User\Dummy();
- \OC_User::getManager()->registerBackend($userBackend);
+ \OC::$server->getUserManager()->registerBackend($userBackend);
OC_Group::useBackend(new OC_Group_Dummy());
$group1 = $this->getUniqueID();
@@ -113,7 +113,7 @@ class Test_Group extends \Test\TestCase {
public function testUsersInGroup() {
OC_Group::useBackend(new OC_Group_Dummy());
$userBackend = new \Test\Util\User\Dummy();
- \OC_User::getManager()->registerBackend($userBackend);
+ \OC::$server->getUserManager()->registerBackend($userBackend);
$group1 = $this->getUniqueID();
$group2 = $this->getUniqueID();
@@ -142,7 +142,7 @@ class Test_Group extends \Test\TestCase {
public function testMultiBackend() {
$userBackend = new \Test\Util\User\Dummy();
- \OC_User::getManager()->registerBackend($userBackend);
+ \OC::$server->getUserManager()->registerBackend($userBackend);
$backend1 = new OC_Group_Dummy();
$backend2 = new OC_Group_Dummy();
OC_Group::useBackend($backend1);
diff --git a/tests/lib/helper.php b/tests/lib/helper.php
index b7deb3fc13d..c2620896157 100644
--- a/tests/lib/helper.php
+++ b/tests/lib/helper.php
@@ -71,37 +71,6 @@ class Test_Helper extends \Test\TestCase {
];
}
- function testGetSecureMimeType() {
- $dir=OC::$SERVERROOT.'/tests/data';
-
- $result = OC_Helper::getSecureMimeType('image/svg+xml');
- $expected = 'text/plain';
- $this->assertEquals($result, $expected);
-
- $result = OC_Helper::getSecureMimeType('image/png');
- $expected = 'image/png';
- $this->assertEquals($result, $expected);
- }
-
- function testGetFileNameMimeType() {
- $this->assertEquals('text/plain', OC_Helper::getFileNameMimeType('foo.txt'));
- $this->assertEquals('image/png', OC_Helper::getFileNameMimeType('foo.png'));
- $this->assertEquals('image/png', OC_Helper::getFileNameMimeType('foo.bar.png'));
- $this->assertEquals('application/octet-stream', OC_Helper::getFileNameMimeType('.png'));
- $this->assertEquals('application/octet-stream', OC_Helper::getFileNameMimeType('foo'));
- $this->assertEquals('application/octet-stream', OC_Helper::getFileNameMimeType(''));
- }
-
- function testGetStringMimeType() {
- if (\OC_Util::runningOnWindows()) {
- $this->markTestSkipped('[Windows] Strings have mimetype application/octet-stream on Windows');
- }
-
- $result = OC_Helper::getStringMimeType("/data/data.tar.gz");
- $expected = 'text/plain; charset=us-ascii';
- $this->assertEquals($result, $expected);
- }
-
function testIsSubDirectory() {
$result = OC_Helper::isSubDirectory("./data/", "/anotherDirectory/");
$this->assertFalse($result);
@@ -254,172 +223,6 @@ class Test_Helper extends \Test\TestCase {
/**
* @small
- * test absolute URL construction
- * @dataProvider provideDocRootURLs
- */
- function testMakeAbsoluteURLDocRoot($url, $expectedResult) {
- \OC::$WEBROOT = '';
- $result = \OC_Helper::makeURLAbsolute($url);
-
- $this->assertEquals($expectedResult, $result);
- }
-
- /**
- * @small
- * test absolute URL construction
- * @dataProvider provideSubDirURLs
- */
- function testMakeAbsoluteURLSubDir($url, $expectedResult) {
- \OC::$WEBROOT = '/owncloud';
- $result = \OC_Helper::makeURLAbsolute($url);
-
- $this->assertEquals($expectedResult, $result);
- }
-
- public function provideDocRootURLs() {
- return array(
- array('index.php', 'http://localhost/index.php'),
- array('/index.php', 'http://localhost/index.php'),
- array('/apps/index.php', 'http://localhost/apps/index.php'),
- array('apps/index.php', 'http://localhost/apps/index.php'),
- );
- }
-
- public function provideSubDirURLs() {
- return array(
- array('index.php', 'http://localhost/owncloud/index.php'),
- array('/index.php', 'http://localhost/owncloud/index.php'),
- array('/apps/index.php', 'http://localhost/owncloud/apps/index.php'),
- array('apps/index.php', 'http://localhost/owncloud/apps/index.php'),
- );
- }
-
- /**
- * @small
- * test linkTo URL construction
- * @dataProvider provideDocRootAppUrlParts
- */
- public function testLinkToDocRoot($app, $file, $args, $expectedResult) {
- \OC::$WEBROOT = '';
- $result = \OC_Helper::linkTo($app, $file, $args);
-
- $this->assertEquals($expectedResult, $result);
- }
-
- /**
- * @small
- * test linkTo URL construction in sub directory
- * @dataProvider provideSubDirAppUrlParts
- */
- public function testLinkToSubDir($app, $file, $args, $expectedResult) {
- \OC::$WEBROOT = '/owncloud';
- $result = \OC_Helper::linkTo($app, $file, $args);
-
- $this->assertEquals($expectedResult, $result);
- }
-
- /**
- * @return array
- */
- public function provideDocRootAppUrlParts() {
- return array(
- array('files', 'ajax/list.php', array(), '/index.php/apps/files/ajax/list.php'),
- array('files', 'ajax/list.php', array('trut' => 'trat', 'dut' => 'dat'), '/index.php/apps/files/ajax/list.php?trut=trat&dut=dat'),
- array('', 'index.php', array('trut' => 'trat', 'dut' => 'dat'), '/index.php?trut=trat&dut=dat'),
- );
- }
-
- /**
- * @return array
- */
- public function provideSubDirAppUrlParts() {
- return array(
- array('files', 'ajax/list.php', array(), '/owncloud/index.php/apps/files/ajax/list.php'),
- array('files', 'ajax/list.php', array('trut' => 'trat', 'dut' => 'dat'), '/owncloud/index.php/apps/files/ajax/list.php?trut=trat&dut=dat'),
- array('', 'index.php', array('trut' => 'trat', 'dut' => 'dat'), '/owncloud/index.php?trut=trat&dut=dat'),
- );
- }
-
- /**
- * @small
- * test linkToAbsolute URL construction
- * @dataProvider provideDocRootAppAbsoluteUrlParts
- */
- public function testLinkToAbsoluteDocRoot($app, $file, $args, $expectedResult) {
- \OC::$WEBROOT = '';
- $result = \OC_Helper::linkToAbsolute($app, $file, $args);
-
- $this->assertEquals($expectedResult, $result);
- }
-
- /**
- * @small
- * test linkToAbsolute URL construction in sub directory
- * @dataProvider provideSubDirAppAbsoluteUrlParts
- */
- public function testLinkToAbsoluteSubDir($app, $file, $args, $expectedResult) {
- \OC::$WEBROOT = '/owncloud';
- $result = \OC_Helper::linkToAbsolute($app, $file, $args);
-
- $this->assertEquals($expectedResult, $result);
- }
-
- /**
- * @return array
- */
- public function provideDocRootAppAbsoluteUrlParts() {
- return array(
- array('files', 'ajax/list.php', array(), 'http://localhost/index.php/apps/files/ajax/list.php'),
- array('files', 'ajax/list.php', array('trut' => 'trat', 'dut' => 'dat'), 'http://localhost/index.php/apps/files/ajax/list.php?trut=trat&dut=dat'),
- array('', 'index.php', array('trut' => 'trat', 'dut' => 'dat'), 'http://localhost/index.php?trut=trat&dut=dat'),
- );
- }
-
- /**
- * @return array
- */
- public function provideSubDirAppAbsoluteUrlParts() {
- return array(
- array('files', 'ajax/list.php', array(), 'http://localhost/owncloud/index.php/apps/files/ajax/list.php'),
- array('files', 'ajax/list.php', array('trut' => 'trat', 'dut' => 'dat'), 'http://localhost/owncloud/index.php/apps/files/ajax/list.php?trut=trat&dut=dat'),
- array('', 'index.php', array('trut' => 'trat', 'dut' => 'dat'), 'http://localhost/owncloud/index.php?trut=trat&dut=dat'),
- );
- }
-
- /**
- * @small
- * test linkToRemoteBase URL construction
- */
- public function testLinkToRemoteBase() {
- \OC::$WEBROOT = '';
- $result = \OC_Helper::linkToRemoteBase('webdav');
- $this->assertEquals('/remote.php/webdav', $result);
-
- \OC::$WEBROOT = '/owncloud';
- $result = \OC_Helper::linkToRemoteBase('webdav');
- $this->assertEquals('/owncloud/remote.php/webdav', $result);
- }
-
- /**
- * @small
- * test linkToRemote URL construction
- */
- public function testLinkToRemote() {
- \OC::$WEBROOT = '';
- $result = \OC_Helper::linkToRemote('webdav');
- $this->assertEquals('http://localhost/remote.php/webdav/', $result);
- $result = \OC_Helper::linkToRemote('webdav', false);
- $this->assertEquals('http://localhost/remote.php/webdav', $result);
-
- \OC::$WEBROOT = '/owncloud';
- $result = \OC_Helper::linkToRemote('webdav');
- $this->assertEquals('http://localhost/owncloud/remote.php/webdav/', $result);
- $result = \OC_Helper::linkToRemote('webdav', false);
- $this->assertEquals('http://localhost/owncloud/remote.php/webdav', $result);
- }
-
- /**
- * @small
* test linkToPublic URL construction
*/
public function testLinkToPublic() {
@@ -458,7 +261,7 @@ class Test_Helper extends \Test\TestCase {
* Tests recursive folder deletion with rmdirr()
*/
public function testRecursiveFolderDeletion() {
- $baseDir = \OC_Helper::tmpFolder() . '/';
+ $baseDir = \OC::$server->getTempManager()->getTemporaryFolder() . '/';
mkdir($baseDir . 'a/b/c/d/e', 0777, true);
mkdir($baseDir . 'a/b/c1/d/e', 0777, true);
mkdir($baseDir . 'a/b/c2/d/e', 0777, true);
diff --git a/tests/lib/helperstorage.php b/tests/lib/helperstorage.php
index cf022109c27..3109b509549 100644
--- a/tests/lib/helperstorage.php
+++ b/tests/lib/helperstorage.php
@@ -23,7 +23,7 @@ class Test_Helper_Storage extends \Test\TestCase {
parent::setUp();
$this->user = $this->getUniqueID('user_');
- \OC_User::createUser($this->user, $this->user);
+ \OC::$server->getUserManager()->createUser($this->user, $this->user);
$this->storage = \OC\Files\Filesystem::getStorage('/');
\OC\Files\Filesystem::tearDown();
@@ -45,7 +45,8 @@ class Test_Helper_Storage extends \Test\TestCase {
\OC\Files\Filesystem::mount($this->storage, array(), '/');
\OC_User::setUserId('');
- \OC_User::deleteUser($this->user);
+ $user = \OC::$server->getUserManager()->get($this->user);
+ if ($user !== null) { $user->delete(); }
\OC::$server->getConfig()->deleteAllUserValues($this->user);
parent::tearDown();
diff --git a/tests/lib/installer.php b/tests/lib/installer.php
index c3c2f8a275e..cfad4d7f0de 100644
--- a/tests/lib/installer.php
+++ b/tests/lib/installer.php
@@ -32,7 +32,7 @@ class Test_Installer extends \Test\TestCase {
$pathOfTestApp .= '/../data/';
$pathOfTestApp .= 'testapp.zip';
- $tmp = OC_Helper::tmpFile('.zip');
+ $tmp = \OC::$server->getTempManager()->getTemporaryFile('.zip');
OC_Helper::copyr($pathOfTestApp, $tmp);
$data = array(
@@ -51,7 +51,7 @@ class Test_Installer extends \Test\TestCase {
$pathOfOldTestApp .= '/../data/';
$pathOfOldTestApp .= 'testapp.zip';
- $oldTmp = OC_Helper::tmpFile('.zip');
+ $oldTmp = \OC::$server->getTempManager()->getTemporaryFile('.zip');
OC_Helper::copyr($pathOfOldTestApp, $oldTmp);
$oldData = array(
@@ -63,7 +63,7 @@ class Test_Installer extends \Test\TestCase {
$pathOfNewTestApp .= '/../data/';
$pathOfNewTestApp .= 'testapp2.zip';
- $newTmp = OC_Helper::tmpFile('.zip');
+ $newTmp = \OC::$server->getTempManager()->getTemporaryFile('.zip');
OC_Helper::copyr($pathOfNewTestApp, $newTmp);
$newData = array(
diff --git a/tests/lib/lock/dblockingprovider.php b/tests/lib/lock/dblockingprovider.php
index d679b1ea677..2032110f4f0 100644
--- a/tests/lib/lock/dblockingprovider.php
+++ b/tests/lib/lock/dblockingprovider.php
@@ -85,13 +85,7 @@ class DBLockingProvider extends LockingProvider {
$this->assertEquals(3, $this->getLockEntryCount());
- $this->instance->cleanEmptyLocks();
-
- $this->assertEquals(3, $this->getLockEntryCount());
-
- $this->instance->releaseAll();
-
- $this->instance->cleanEmptyLocks();
+ $this->instance->cleanExpiredLocks();
$this->assertEquals(2, $this->getLockEntryCount());
}
diff --git a/tests/lib/security/certificatemanager.php b/tests/lib/security/certificatemanager.php
index 43b2f1cf980..f2e29cab18e 100644
--- a/tests/lib/security/certificatemanager.php
+++ b/tests/lib/security/certificatemanager.php
@@ -24,7 +24,7 @@ class CertificateManagerTest extends \Test\TestCase {
parent::setUp();
$this->username = $this->getUniqueID('', 20);
- OC_User::createUser($this->username, $this->getUniqueID('', 20));
+ \OC::$server->getUserManager()->createUser($this->username, $this->getUniqueID('', 20));
\OC_Util::tearDownFS();
\OC_User::setUserId('');
@@ -39,7 +39,8 @@ class CertificateManagerTest extends \Test\TestCase {
}
protected function tearDown() {
- \OC_User::deleteUser($this->username);
+ $user = \OC::$server->getUserManager()->get($this->username);
+ if ($user !== null) { $user->delete(); }
parent::tearDown();
}
diff --git a/tests/lib/security/securerandom.php b/tests/lib/security/securerandom.php
index d9bbd0e71e5..af437640805 100644
--- a/tests/lib/security/securerandom.php
+++ b/tests/lib/security/securerandom.php
@@ -57,11 +57,10 @@ class SecureRandomTest extends \Test\TestCase {
}
/**
- * @expectedException \Exception
- * @expectedExceptionMessage Generator is not initialized
+ * @dataProvider stringGenerationProvider
*/
- function testUninitializedGenerate() {
- $this->rng->generate(30);
+ function testUninitializedGenerate($length, $expectedLength) {
+ $this->assertEquals($expectedLength, strlen($this->rng->generate($length)));
}
/**
diff --git a/tests/lib/security/stringutils.php b/tests/lib/security/stringutils.php
deleted file mode 100644
index 060315debb4..00000000000
--- a/tests/lib/security/stringutils.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Lukas Reschke <lukas@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-
-use \OC\Security\StringUtils;
-
-class StringUtilsTest extends \Test\TestCase {
-
- public function dataProvider()
- {
- return array(
- array('Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt.', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt.'),
- array('', ''),
- array('我看这本书。 我看這本書', '我看这本书。 我看這本書'),
- array('GpKY9fSnWNJbES99zVGvA', 'GpKY9fSnWNJbES99zVGvA')
- );
- }
-
- /**
- * @dataProvider dataProvider
- */
- function testWrongEquals($string) {
- $this->assertFalse(StringUtils::equals($string, 'A Completely Wrong String'));
- $this->assertFalse(StringUtils::equals($string, null));
- }
-
- /**
- * @dataProvider dataProvider
- */
- function testTrueEquals($string, $expected) {
- $this->assertTrue(StringUtils::equals($string, $expected));
- }
-
-}
diff --git a/tests/lib/server.php b/tests/lib/server.php
index b72bef82036..e2670061e8d 100644
--- a/tests/lib/server.php
+++ b/tests/lib/server.php
@@ -38,7 +38,8 @@ class Server extends \Test\TestCase {
public function setUp() {
parent::setUp();
- $this->server = new \OC\Server('');
+ $config = new \OC\Config(\OC::$configDir);
+ $this->server = new \OC\Server('', $config);
}
public function dataTestQuery() {
@@ -61,6 +62,7 @@ class Server extends \Test\TestCase {
['CapabilitiesManager', '\OC\CapabilitiesManager'],
['ContactsManager', '\OC\ContactsManager'],
['ContactsManager', '\OCP\Contacts\IManager'],
+ ['CommentsManager', '\OCP\Comments\ICommentsManager'],
['Crypto', '\OC\Security\Crypto'],
['Crypto', '\OCP\Security\ICrypto'],
['CryptoWrapper', '\OC\Session\CryptoWrapper'],
@@ -173,4 +175,16 @@ class Server extends \Test\TestCase {
$this->assertInstanceOf('\OC_EventSource', $this->server->createEventSource(), 'service returned by "createEventSource" did not return the right class');
$this->assertInstanceOf('\OCP\IEventSource', $this->server->createEventSource(), 'service returned by "createEventSource" did not return the right class');
}
+
+ public function testOverwriteDefaultCommentsManager() {
+ $config = $this->server->getConfig();
+ $defaultManagerFactory = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
+
+ $config->setSystemValue('comments.managerFactory', '\Test\Comments\FakeFactory');
+
+ $manager = $this->server->getCommentsManager();
+ $this->assertInstanceOf('\OCP\Comments\ICommentsManager', $manager);
+
+ $config->setSystemValue('comments.managerFactory', $defaultManagerFactory);
+ }
}
diff --git a/tests/lib/setup.php b/tests/lib/setup.php
index 72c84520056..bc78c14008f 100644
--- a/tests/lib/setup.php
+++ b/tests/lib/setup.php
@@ -130,17 +130,4 @@ class Test_OC_Setup extends \Test\TestCase {
->will($this->returnValue('NotAnArray'));
$this->setupClass->getSupportedDatabases();
}
-
- /**
- * This is actual more an integration test whether the version parameter in the .htaccess
- * was updated as well when the version has been incremented.
- * If it hasn't this test will fail.
- */
- public function testHtaccessIsCurrent() {
- $result = self::invokePrivate(
- $this->setupClass,
- 'isCurrentHtaccess'
- );
- $this->assertTrue($result);
- }
}
diff --git a/tests/lib/share/MailNotificationsTest.php b/tests/lib/share/MailNotificationsTest.php
index 8684886e798..66bec8653fb 100644
--- a/tests/lib/share/MailNotificationsTest.php
+++ b/tests/lib/share/MailNotificationsTest.php
@@ -20,7 +20,6 @@
*/
use OC\Share\MailNotifications;
-use OCP\IConfig;
use OCP\IL10N;
use OCP\IUser;
use OCP\Mail\IMailer;
@@ -234,6 +233,9 @@ class MailNotificationsTest extends \Test\TestCase {
}
+ /**
+ * @param string $subject
+ */
protected function setupMailerMock($subject, $to, $exceptionOnSend = true) {
$message = $this->getMockBuilder('\OC\Mail\Message')
->disableOriginalConstructor()->getMock();
diff --git a/tests/lib/share/helper.php b/tests/lib/share/helper.php
index e37a3db8bf0..eaa29c8cb90 100644
--- a/tests/lib/share/helper.php
+++ b/tests/lib/share/helper.php
@@ -19,6 +19,10 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * @group DB
+ * Class Test_Share_Helper
+ */
class Test_Share_Helper extends \Test\TestCase {
public function expireDateProvider() {
@@ -121,4 +125,37 @@ class Test_Share_Helper extends \Test\TestCase {
public function testSplitUserRemoteError($id) {
\OC\Share\Helper::splitUserRemote($id);
}
+
+ /**
+ * @dataProvider dataTestCompareServerAddresses
+ *
+ * @param string $server1
+ * @param string $server2
+ * @param bool $expected
+ */
+ public function testIsSameUserOnSameServer($user1, $server1, $user2, $server2, $expected) {
+ $this->assertSame($expected,
+ \OC\Share\Helper::isSameUserOnSameServer($user1, $server1, $user2, $server2)
+ );
+ }
+
+ public function dataTestCompareServerAddresses() {
+ return [
+ ['user1', 'http://server1', 'user1', 'http://server1', true],
+ ['user1', 'https://server1', 'user1', 'http://server1', true],
+ ['user1', 'http://serVer1', 'user1', 'http://server1', true],
+ ['user1', 'http://server1/', 'user1', 'http://server1', true],
+ ['user1', 'server1', 'user1', 'http://server1', true],
+ ['user1', 'http://server1', 'user1', 'http://server2', false],
+ ['user1', 'https://server1', 'user1', 'http://server2', false],
+ ['user1', 'http://serVer1', 'user1', 'http://serer2', false],
+ ['user1', 'http://server1/', 'user1', 'http://server2', false],
+ ['user1', 'server1', 'user1', 'http://server2', false],
+ ['user1', 'http://server1', 'user2', 'http://server1', false],
+ ['user1', 'https://server1', 'user2', 'http://server1', false],
+ ['user1', 'http://serVer1', 'user2', 'http://server1', false],
+ ['user1', 'http://server1/', 'user2', 'http://server1', false],
+ ['user1', 'server1', 'user2', 'http://server1', false],
+ ];
+ }
}
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index fa19577cb72..5162a03f367 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -54,13 +54,13 @@ class Test_Share extends \Test\TestCase {
$this->user5 = $this->getUniqueID('user5_');
$this->user6 = $this->getUniqueID('user6_');
$this->groupAndUser = $this->getUniqueID('groupAndUser_');
- OC_User::createUser($this->user1, 'pass');
- OC_User::createUser($this->user2, 'pass');
- OC_User::createUser($this->user3, 'pass');
- OC_User::createUser($this->user4, 'pass');
- OC_User::createUser($this->user5, 'pass');
- OC_User::createUser($this->user6, 'pass'); // no group
- OC_User::createUser($this->groupAndUser, 'pass');
+ \OC::$server->getUserManager()->createUser($this->user1, 'pass');
+ \OC::$server->getUserManager()->createUser($this->user2, 'pass');
+ \OC::$server->getUserManager()->createUser($this->user3, 'pass');
+ \OC::$server->getUserManager()->createUser($this->user4, 'pass');
+ \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 OC_Group_Dummy);
@@ -94,13 +94,20 @@ class Test_Share extends \Test\TestCase {
$query->execute(array('test'));
\OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', $this->resharing);
- OC_User::deleteUser($this->user1);
- OC_User::deleteUser($this->user2);
- OC_User::deleteUser($this->user3);
- OC_User::deleteUser($this->user4);
- OC_User::deleteUser($this->user5);
- OC_User::deleteUser($this->user6);
- OC_User::deleteUser($this->groupAndUser);
+ $user = \OC::$server->getUserManager()->get($this->user1);
+ if ($user !== null) { $user->delete(); }
+ $user = \OC::$server->getUserManager()->get($this->user2);
+ if ($user !== null) { $user->delete(); }
+ $user = \OC::$server->getUserManager()->get($this->user3);
+ if ($user !== null) { $user->delete(); }
+ $user = \OC::$server->getUserManager()->get($this->user4);
+ if ($user !== null) { $user->delete(); }
+ $user = \OC::$server->getUserManager()->get($this->user5);
+ if ($user !== null) { $user->delete(); }
+ $user = \OC::$server->getUserManager()->get($this->user6);
+ if ($user !== null) { $user->delete(); }
+ $user = \OC::$server->getUserManager()->get($this->groupAndUser);
+ if ($user !== null) { $user->delete(); }
OC_Group::deleteGroup($this->group1);
OC_Group::deleteGroup($this->group2);
@@ -375,7 +382,8 @@ class Test_Share extends \Test\TestCase {
// Remove user
OC_User::setUserId($this->user1);
- OC_User::deleteUser($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));
}
diff --git a/tests/lib/streamwrappers.php b/tests/lib/streamwrappers.php
index 9b097535280..7175683a60b 100644
--- a/tests/lib/streamwrappers.php
+++ b/tests/lib/streamwrappers.php
@@ -55,7 +55,7 @@ class Test_StreamWrappers extends \Test\TestCase {
public function testCloseStream() {
//ensure all basic stream stuff works
$sourceFile = OC::$SERVERROOT . '/tests/data/lorem.txt';
- $tmpFile = OC_Helper::TmpFile('.txt');
+ $tmpFile = \OC::$server->getTempManager()->getTemporaryFile('.txt');
$file = 'close://' . $tmpFile;
$this->assertTrue(file_exists($file));
file_put_contents($file, file_get_contents($sourceFile));
@@ -65,7 +65,7 @@ class Test_StreamWrappers extends \Test\TestCase {
$this->assertFalse(file_exists($file));
//test callback
- $tmpFile = OC_Helper::TmpFile('.txt');
+ $tmpFile = \OC::$server->getTempManager()->getTemporaryFile('.txt');
$file = 'close://' . $tmpFile;
$actual = false;
$callback = function($path) use (&$actual) { $actual = $path; };
diff --git a/tests/lib/tags.php b/tests/lib/tags.php
index a8f59ff16e4..537c898da13 100644
--- a/tests/lib/tags.php
+++ b/tests/lib/tags.php
@@ -44,7 +44,7 @@ class Test_Tags extends \Test\TestCase {
OC_User::clearBackends();
OC_User::useBackend('dummy');
$userId = $this->getUniqueID('user_');
- OC_User::createUser($userId, 'pass');
+ \OC::$server->getUserManager()->createUser($userId, 'pass');
OC_User::setUserId($userId);
$this->user = new OC\User\User($userId, null);
$this->userSession = $this->getMock('\OCP\IUserSession');
@@ -290,7 +290,7 @@ class Test_Tags extends \Test\TestCase {
$tagger->tagAs(1, $testTag);
$otherUserId = $this->getUniqueID('user2_');
- OC_User::createUser($otherUserId, 'pass');
+ \OC::$server->getUserManager()->createUser($otherUserId, 'pass');
OC_User::setUserId($otherUserId);
$otherUserSession = $this->getMock('\OCP\IUserSession');
$otherUserSession
diff --git a/tests/lib/testcase.php b/tests/lib/testcase.php
index 5d88fa08a6d..93b354863a9 100644
--- a/tests/lib/testcase.php
+++ b/tests/lib/testcase.php
@@ -33,7 +33,8 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase {
private $commandBus;
/** @var IDBConnection */
- static private $realDatabase;
+ static protected $realDatabase = null;
+ static private $wasDatabaseAllowed = false;
protected function getTestTraits() {
$traits = [];
@@ -52,7 +53,9 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase {
protected function setUp() {
// detect database access
+ self::$wasDatabaseAllowed = true;
if (!$this->IsDatabaseAccessAllowed()) {
+ self::$wasDatabaseAllowed = false;
if (is_null(self::$realDatabase)) {
self::$realDatabase = \OC::$server->getDatabaseConnection();
}
@@ -92,6 +95,12 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase {
throw $hookExceptions[0];
}
+ // fail hard if xml errors have not been cleaned up
+ $errors = libxml_get_errors();
+ libxml_clear_errors();
+ $this->assertEquals([], $errors);
+
+ // tearDown the traits
$traits = $this->getTestTraits();
foreach ($traits as $trait) {
$methodName = 'tearDown' . basename(str_replace('\\', '/', $trait));
@@ -149,12 +158,21 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase {
}
public static function tearDownAfterClass() {
+ if (!self::$wasDatabaseAllowed && self::$realDatabase !== null) {
+ // in case an error is thrown in a test, PHPUnit jumps straight to tearDownAfterClass,
+ // so we need the database again
+ \OC::$server->registerService('DatabaseConnection', function () {
+ return self::$realDatabase;
+ });
+ }
$dataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data-autotest');
- $queryBuilder = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+ if (self::$wasDatabaseAllowed && \OC::$server->getDatabaseConnection()) {
+ $queryBuilder = \OC::$server->getDatabaseConnection()->getQueryBuilder();
- self::tearDownAfterClassCleanShares($queryBuilder);
- self::tearDownAfterClassCleanStorages($queryBuilder);
- self::tearDownAfterClassCleanFileCache($queryBuilder);
+ self::tearDownAfterClassCleanShares($queryBuilder);
+ self::tearDownAfterClassCleanStorages($queryBuilder);
+ self::tearDownAfterClassCleanFileCache($queryBuilder);
+ }
self::tearDownAfterClassCleanStrayDataFiles($dataDir);
self::tearDownAfterClassCleanStrayHooks();
self::tearDownAfterClassCleanStrayLocks();
diff --git a/tests/lib/updater.php b/tests/lib/updater.php
index 14ae3db3276..313ffb65738 100644
--- a/tests/lib/updater.php
+++ b/tests/lib/updater.php
@@ -66,7 +66,7 @@ class UpdaterTest extends \Test\TestCase {
* @return string
*/
private function buildUpdateUrl($baseUrl) {
- return $baseUrl . '?version='.implode('x', \OC_Util::getVersion()).'xinstalledatxlastupdatedatx'.\OC_Util::getChannel().'x'.\OC_Util::getEditionString().'x';
+ return $baseUrl . '?version='.implode('x', \OCP\Util::getVersion()).'xinstalledatxlastupdatedatx'.\OC_Util::getChannel().'x'.\OC_Util::getEditionString().'x';
}
/**
diff --git a/tests/lib/user.php b/tests/lib/user.php
index bc1ba063c8f..c4c74cbc254 100644
--- a/tests/lib/user.php
+++ b/tests/lib/user.php
@@ -26,7 +26,7 @@ class User extends TestCase {
parent::setUp();
$this->backend = $this->getMock('\Test\Util\User\Dummy');
- $manager = \OC_User::getManager();
+ $manager = \OC::$server->getUserManager();
$manager->registerBackend($this->backend);
}
@@ -51,30 +51,5 @@ class User extends TestCase {
$uid = \OC_User::checkPassword('foo', 'bar');
$this->assertEquals($uid, 'foo');
}
-
- public function testDeleteUser() {
- $fail = \OC_User::deleteUser('victim');
- $this->assertFalse($fail);
-
- $success = \OC_User::createUser('victim', 'password');
-
- $success = \OC_User::deleteUser('victim');
- $this->assertTrue($success);
- }
-
- public function testCreateUser(){
- $this->backend->expects($this->any())
- ->method('implementsActions')
- ->will($this->returnCallback(function ($actions) {
- if ($actions === \OC_USER_BACKEND_CREATE_USER) {
- return true;
- } else {
- return false;
- }
- }));
-
- $user = \OC_User::createUser('newuser', 'newpassword');
- $this->assertEquals('newuser', $user->getUid());
- }
}
diff --git a/tests/lib/util.php b/tests/lib/util.php
index fa559c17c80..cb5d28b48a7 100644
--- a/tests/lib/util.php
+++ b/tests/lib/util.php
@@ -8,7 +8,7 @@
*/
class Test_Util extends \Test\TestCase {
public function testGetVersion() {
- $version = \OC_Util::getVersion();
+ $version = \OCP\Util::getVersion();
$this->assertTrue(is_array($version));
foreach ($version as $num) {
$this->assertTrue(is_int($num));
diff --git a/tests/lib/utilcheckserver.php b/tests/lib/utilcheckserver.php
index a5ec529ff85..94e7fd2f779 100644
--- a/tests/lib/utilcheckserver.php
+++ b/tests/lib/utilcheckserver.php
@@ -37,7 +37,7 @@ class Test_Util_CheckServer extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->datadir = \OC_Helper::tmpFolder();
+ $this->datadir = \OC::$server->getTempManager()->getTemporaryFolder();
file_put_contents($this->datadir . '/.ocdata', '');
\OC::$server->getSession()->set('checkServer_succeeded', false);
@@ -123,7 +123,7 @@ class Test_Util_CheckServer extends \Test\TestCase {
$result = \OC_Util::checkServer($this->getConfig(array(
'installed' => true,
- 'version' => implode('.', OC_Util::getVersion())
+ 'version' => implode('.', \OCP\Util::getVersion())
)));
$this->assertCount(1, $result);
}
@@ -134,7 +134,7 @@ class Test_Util_CheckServer extends \Test\TestCase {
public function testDataDirWritable() {
$result = \OC_Util::checkServer($this->getConfig(array(
'installed' => true,
- 'version' => implode('.', OC_Util::getVersion())
+ 'version' => implode('.', \OCP\Util::getVersion())
)));
$this->assertEmpty($result);
}
@@ -150,7 +150,7 @@ class Test_Util_CheckServer extends \Test\TestCase {
chmod($this->datadir, 0300);
$result = \OC_Util::checkServer($this->getConfig(array(
'installed' => true,
- 'version' => implode('.', OC_Util::getVersion())
+ 'version' => implode('.', \OCP\Util::getVersion())
)));
$this->assertCount(1, $result);
}
@@ -162,7 +162,7 @@ class Test_Util_CheckServer extends \Test\TestCase {
chmod($this->datadir, 0300);
$result = \OC_Util::checkServer($this->getConfig(array(
'installed' => false,
- 'version' => implode('.', OC_Util::getVersion())
+ 'version' => implode('.', \OCP\Util::getVersion())
)));
chmod($this->datadir, 0700); //needed for cleanup
$this->assertEmpty($result);
diff --git a/tests/phpunit-autotest-external.xml b/tests/phpunit-autotest-external.xml
index b9402bfa572..31d2e395a01 100644
--- a/tests/phpunit-autotest-external.xml
+++ b/tests/phpunit-autotest-external.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit bootstrap="bootstrap.php"
- strict="true"
verbose="true"
timeoutForSmallTests="900"
timeoutForMediumTests="900"
diff --git a/tests/startsessionlistener.php b/tests/startsessionlistener.php
index 1f3573555ca..88544cc6ce9 100644
--- a/tests/startsessionlistener.php
+++ b/tests/startsessionlistener.php
@@ -44,4 +44,7 @@ class StartSessionListener implements PHPUnit_Framework_TestListener {
public function endTestSuite(PHPUnit_Framework_TestSuite $suite) {
}
+ public function addWarning(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_Warning $e, $time) {
+ }
+
}