aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Comments/ManagerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Comments/ManagerTest.php')
-rw-r--r--tests/lib/Comments/ManagerTest.php24
1 files changed, 15 insertions, 9 deletions
diff --git a/tests/lib/Comments/ManagerTest.php b/tests/lib/Comments/ManagerTest.php
index c187f664215..5d03bb06521 100644
--- a/tests/lib/Comments/ManagerTest.php
+++ b/tests/lib/Comments/ManagerTest.php
@@ -43,7 +43,7 @@ class ManagerTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->connection = \OC::$server->getDatabaseConnection();
+ $this->connection = Server::get(IDBConnection::class);
$this->rootFolder = $this->createMock(IRootFolder::class);
$sql = $this->connection->getDatabasePlatform()->getTruncateTableSQL('`*PREFIX*comments`');
@@ -96,7 +96,7 @@ class ManagerTest extends TestCase {
public function testGetCommentNotFound(): void {
- $this->expectException(\OCP\Comments\NotFoundException::class);
+ $this->expectException(NotFoundException::class);
$manager = $this->getManager();
$manager->get('22');
@@ -116,7 +116,7 @@ class ManagerTest extends TestCase {
$creationDT = new \DateTime('yesterday');
$latestChildDT = new \DateTime();
- $qb = \OCP\Server::get(IDBConnection::class)->getQueryBuilder();
+ $qb = Server::get(IDBConnection::class)->getQueryBuilder();
$qb
->insert('comments')
->values([
@@ -158,7 +158,7 @@ class ManagerTest extends TestCase {
public function testGetTreeNotFound(): void {
- $this->expectException(\OCP\Comments\NotFoundException::class);
+ $this->expectException(NotFoundException::class);
$manager = $this->getManager();
$manager->getTree('22');
@@ -450,7 +450,7 @@ class ManagerTest extends TestCase {
public function testDelete(): void {
- $this->expectException(\OCP\Comments\NotFoundException::class);
+ $this->expectException(NotFoundException::class);
$manager = $this->getManager();
@@ -564,7 +564,7 @@ class ManagerTest extends TestCase {
$manager->delete($comment->getId());
$comment->setMessage('very beautiful, I am really so much impressed!');
- $this->expectException(\OCP\Comments\NotFoundException::class);
+ $this->expectException(NotFoundException::class);
$manager->save($comment);
}
@@ -652,10 +652,10 @@ class ManagerTest extends TestCase {
}
public function testDeleteReferencesOfActorWithUserManagement(): void {
- $user = \OCP\Server::get(IUserManager::class)->createUser('xenia', 'NotAnEasyPassword123456+');
+ $user = Server::get(IUserManager::class)->createUser('xenia', 'NotAnEasyPassword123456+');
$this->assertInstanceOf(IUser::class, $user);
- $manager = \OCP\Server::get(ICommentsManager::class);
+ $manager = Server::get(ICommentsManager::class);
$comment = $manager->create('users', $user->getUID(), 'files', 'file64');
$comment
->setMessage('Most important comment I ever left on the Internet.')
@@ -1073,6 +1073,7 @@ class ManagerTest extends TestCase {
* @return array<string, IComment>
*/
private function proccessComments(array $data): array {
+ $this->connection->beginTransaction();
/** @var array<string, IComment> $comments */
$comments = [];
foreach ($data as $comment) {
@@ -1088,6 +1089,7 @@ class ManagerTest extends TestCase {
$comment = $this->testSave($message, $actorId, $verb, $parentId, $id);
$comments[$comment->getMessage() . '#' . $comment->getActorId()] = $comment;
}
+ $this->connection->commit();
return $comments;
}
@@ -1107,6 +1109,10 @@ class ManagerTest extends TestCase {
$row->getMessage(),
];
}, $all);
+
+ usort($actual, static fn (array $a, array $b): int => $a[1] <=> $b[1]);
+ usort($expected, static fn (array $a, array $b): int => $a[1] <=> $b[1]);
+
$this->assertEqualsCanonicalizing($expected, $actual);
}
@@ -2419,7 +2425,7 @@ class ManagerTest extends TestCase {
$expected = array_combine($keys, $expected);
if ($notFound) {
- $this->expectException(\OCP\Comments\NotFoundException::class);
+ $this->expectException(NotFoundException::class);
}
$comment = $processedComments[$expected['message'] . '#' . $expected['actorId']];
$actual = $manager->getReactionComment((int)$comment->getParentId(), $comment->getActorType(), $comment->getActorId(), $comment->getMessage());