diff options
Diffstat (limited to 'apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php')
-rw-r--r-- | apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php | 88 |
1 files changed, 42 insertions, 46 deletions
diff --git a/apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php b/apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php index c0de0016c31..4d3392a562d 100644 --- a/apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php +++ b/apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -8,13 +9,12 @@ namespace OCA\Comments\Tests\Unit\Collaboration; use OCA\Comments\Collaboration\CommentersSorter; use OCP\Comments\IComment; use OCP\Comments\ICommentsManager; +use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; class CommentersSorterTest extends TestCase { - /** @var ICommentsManager|\PHPUnit\Framework\MockObject\MockObject */ - protected $commentsManager; - /** @var CommentersSorter */ - protected $sorter; + protected ICommentsManager&MockObject $commentsManager; + protected CommentersSorter $sorter; protected function setUp(): void { parent::setUp(); @@ -25,9 +25,9 @@ class CommentersSorterTest extends TestCase { } /** - * @dataProvider sortDataProvider * @param $data */ + #[\PHPUnit\Framework\Attributes\DataProvider('sortDataProvider')] public function testSort($data): void { $commentMocks = []; foreach ($data['actors'] as $actorType => $actors) { @@ -55,38 +55,36 @@ class CommentersSorterTest extends TestCase { $this->assertEquals($data['expected'], $workArray); } - public function sortDataProvider() { + public static function sortDataProvider(): array { return [[ [ #1 – sort properly and otherwise keep existing order 'actors' => ['users' => ['celia' => 3, 'darius' => 7, 'faruk' => 5, 'gail' => 5], 'bots' => ['r2-d2' => 8]], 'input' => [ - 'users' => - [ - ['value' => ['shareWith' => 'alice']], - ['value' => ['shareWith' => 'bob']], - ['value' => ['shareWith' => 'celia']], - ['value' => ['shareWith' => 'darius']], - ['value' => ['shareWith' => 'elena']], - ['value' => ['shareWith' => 'faruk']], - ['value' => ['shareWith' => 'gail']], - ], + 'users' => [ + ['value' => ['shareWith' => 'alice']], + ['value' => ['shareWith' => 'bob']], + ['value' => ['shareWith' => 'celia']], + ['value' => ['shareWith' => 'darius']], + ['value' => ['shareWith' => 'elena']], + ['value' => ['shareWith' => 'faruk']], + ['value' => ['shareWith' => 'gail']], + ], 'bots' => [ ['value' => ['shareWith' => 'c-3po']], ['value' => ['shareWith' => 'r2-d2']], ] ], 'expected' => [ - 'users' => - [ - ['value' => ['shareWith' => 'darius']], - ['value' => ['shareWith' => 'faruk']], - ['value' => ['shareWith' => 'gail']], - ['value' => ['shareWith' => 'celia']], - ['value' => ['shareWith' => 'alice']], - ['value' => ['shareWith' => 'bob']], - ['value' => ['shareWith' => 'elena']], - ], + 'users' => [ + ['value' => ['shareWith' => 'darius']], + ['value' => ['shareWith' => 'faruk']], + ['value' => ['shareWith' => 'gail']], + ['value' => ['shareWith' => 'celia']], + ['value' => ['shareWith' => 'alice']], + ['value' => ['shareWith' => 'bob']], + ['value' => ['shareWith' => 'elena']], + ], 'bots' => [ ['value' => ['shareWith' => 'r2-d2']], ['value' => ['shareWith' => 'c-3po']], @@ -97,32 +95,30 @@ class CommentersSorterTest extends TestCase { #2 – no commentors, input equals output 'actors' => [], 'input' => [ - 'users' => - [ - ['value' => ['shareWith' => 'alice']], - ['value' => ['shareWith' => 'bob']], - ['value' => ['shareWith' => 'celia']], - ['value' => ['shareWith' => 'darius']], - ['value' => ['shareWith' => 'elena']], - ['value' => ['shareWith' => 'faruk']], - ['value' => ['shareWith' => 'gail']], - ], + 'users' => [ + ['value' => ['shareWith' => 'alice']], + ['value' => ['shareWith' => 'bob']], + ['value' => ['shareWith' => 'celia']], + ['value' => ['shareWith' => 'darius']], + ['value' => ['shareWith' => 'elena']], + ['value' => ['shareWith' => 'faruk']], + ['value' => ['shareWith' => 'gail']], + ], 'bots' => [ ['value' => ['shareWith' => 'c-3po']], ['value' => ['shareWith' => 'r2-d2']], ] ], 'expected' => [ - 'users' => - [ - ['value' => ['shareWith' => 'alice']], - ['value' => ['shareWith' => 'bob']], - ['value' => ['shareWith' => 'celia']], - ['value' => ['shareWith' => 'darius']], - ['value' => ['shareWith' => 'elena']], - ['value' => ['shareWith' => 'faruk']], - ['value' => ['shareWith' => 'gail']], - ], + 'users' => [ + ['value' => ['shareWith' => 'alice']], + ['value' => ['shareWith' => 'bob']], + ['value' => ['shareWith' => 'celia']], + ['value' => ['shareWith' => 'darius']], + ['value' => ['shareWith' => 'elena']], + ['value' => ['shareWith' => 'faruk']], + ['value' => ['shareWith' => 'gail']], + ], 'bots' => [ ['value' => ['shareWith' => 'c-3po']], ['value' => ['shareWith' => 'r2-d2']], |