Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix(tests): remove redundant unit test for activity
Signed-off-by: grnd-alt <[email protected]>
  • Loading branch information
grnd-alt committed Dec 3, 2024
commit eb61a3ae4480d8d07210e91fc2037e2887f9663e
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();
}
}
Loading