diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2017-10-30 15:10:21 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2017-10-30 15:59:43 +0100 |
commit | d5f1cef6420c7450ce960f469fd10557ea8fcdd9 (patch) | |
tree | cdc3245e7dd4e1bb280093ff56701b52383d7bcf /apps/comments/tests | |
parent | 61db8615f4921c12c4c7090e87701b1bdbb2c186 (diff) | |
download | nextcloud-server-d5f1cef6420c7450ce960f469fd10557ea8fcdd9.tar.gz nextcloud-server-d5f1cef6420c7450ce960f469fd10557ea8fcdd9.zip |
fix comment sorter
background: we have a flat hierarchy of comments, not a tree. therefore we
can also remove again the unnecessary additions.
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/comments/tests')
-rw-r--r-- | apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php b/apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php index 95a74f118c0..0cc3e3d4b61 100644 --- a/apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php +++ b/apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php @@ -27,6 +27,7 @@ namespace OCA\Comments\Tests\Unit\Collaboration; use OCA\Comments\Collaboration\CommentersSorter; use OCP\Comments\IComment; use OCP\Comments\ICommentsManager; +use OCP\IConfig; use Test\TestCase; class CommentersSorterTest extends TestCase { @@ -48,13 +49,25 @@ class CommentersSorterTest extends TestCase { * @param $data */ public function testSort($data) { - $this->commentsManager->expects($this->once()) - ->method('getForObject') - ->willReturn([$this->createMock(IComment::class)]); + $commentMocks = []; + foreach($data['actors'] as $actorType => $actors) { + foreach ($actors as $actorId => $noOfComments) { + for($i=0;$i<$noOfComments;$i++) { + $mock = $this->createMock(IComment::class); + $mock->expects($this->atLeastOnce()) + ->method('getActorType') + ->willReturn($actorType); + $mock->expects($this->atLeastOnce()) + ->method('getActorId') + ->willReturn($actorId); + $commentMocks[] = $mock; + } + } + } $this->commentsManager->expects($this->once()) - ->method('getActorsInTree') - ->willReturn($data['actors']); + ->method('getForObject') + ->willReturn($commentMocks); $workArray = $data['input']; $this->sorter->sort($workArray, ['itemType' => 'files', 'itemId' => '24']); |