Skip to content

Commit

Permalink
fix(tests): remove redundant unit test for activity
Browse files Browse the repository at this point in the history
Signed-off-by: grnd-alt <[email protected]>
  • Loading branch information
grnd-alt committed Dec 3, 2024
1 parent 8d953ae commit eb61a3a
Showing 1 changed file with 0 additions and 40 deletions.
40 changes: 0 additions & 40 deletions apps/files/tests/Service/TagServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

use OCA\Files\Service\TagService;
use OCP\Activity\IManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Events\NodeAddedToFavorite;
use OCP\Files\Events\NodeRemovedFromFavorite;
use OCP\Files\Folder;
use OCP\Files\NotFoundException;
use OCP\ITags;
Expand Down Expand Up @@ -43,9 +40,6 @@ class TagServiceTest extends \Test\TestCase {
*/
private $root;

/** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
private $dispatcher;

/**
* @var TagService|\PHPUnit\Framework\MockObject\MockObject
*/
Expand Down Expand Up @@ -74,7 +68,6 @@ protected function setUp(): void {
->willReturn($user);

$this->root = \OC::$server->getUserFolder();
$this->dispatcher = $this->createMock(IEventDispatcher::class);

$this->tagger = \OC::$server->getTagManager()->load('files');
$this->tagService = $this->getTagService(['addActivity']);
Expand Down Expand Up @@ -108,9 +101,6 @@ public function testUpdateFileTags(): void {
$tag1 = 'tag1';
$tag2 = 'tag2';

$this->dispatcher->expects($this->never())
->method('dispatchTyped');

$subdir = $this->root->newFolder('subdir');
$testFile = $subdir->newFile('test.txt');
$testFile->putContent('test contents');
Expand Down Expand Up @@ -142,36 +132,6 @@ public function testUpdateFileTags(): void {
}
$this->assertTrue($caught);

$subdir->delete();
}

public function testFavoriteActivity(): void {
$subdir = $this->root->newFolder('subdir');
$file = $subdir->newFile('test.txt');

$invokedCount = $this->exactly(2);

$this->dispatcher->expects($invokedCount)
->method('dispatchTyped')
->willReturnCallback(function ($event) use ($invokedCount, $file) {
if ($invokedCount->getInvocationCount() === 1) {
$this->assertInstanceOf(NodeAddedToFavorite::class, $event);
}
if ($invokedCount->getInvocationCount() === 2) {
$this->assertInstanceOf(NodeRemovedFromFavorite::class, $event);
}
$this->assertEquals($this->userSession->getUser()->getUID(), $event->getUser()->getUID());
$this->assertEquals('subdir/test.txt', $event->getPath());
$this->assertEquals($file->getId(), $event->getFileId());
});

// set tags
$this->tagService->updateFileTags('subdir/test.txt', [ITags::TAG_FAVORITE]);

// remove tag
$this->tagService->updateFileTags('subdir/test.txt', []);


$subdir->delete();
}
}

0 comments on commit eb61a3a

Please sign in to comment.