|
|
|
|
@ -39,27 +39,28 @@ use OCP\IUser; |
|
|
|
|
use OCP\IUserManager; |
|
|
|
|
use OCP\L10N\IFactory; |
|
|
|
|
use OCP\Notification\INotification; |
|
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
|
|
|
|
use Test\TestCase; |
|
|
|
|
|
|
|
|
|
class NotifierTest extends TestCase { |
|
|
|
|
|
|
|
|
|
/** @var Notifier */ |
|
|
|
|
protected $notifier; |
|
|
|
|
/** @var IFactory|\PHPUnit\Framework\MockObject\MockObject */ |
|
|
|
|
/** @var IFactory|MockObject */ |
|
|
|
|
protected $l10nFactory; |
|
|
|
|
/** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */ |
|
|
|
|
/** @var IL10N|MockObject */ |
|
|
|
|
protected $l; |
|
|
|
|
/** @var IRootFolder|\PHPUnit\Framework\MockObject\MockObject */ |
|
|
|
|
/** @var IRootFolder|MockObject */ |
|
|
|
|
protected $folder; |
|
|
|
|
/** @var ICommentsManager|\PHPUnit\Framework\MockObject\MockObject */ |
|
|
|
|
/** @var ICommentsManager|MockObject */ |
|
|
|
|
protected $commentsManager; |
|
|
|
|
/** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */ |
|
|
|
|
/** @var IURLGenerator|MockObject */ |
|
|
|
|
protected $url; |
|
|
|
|
/** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */ |
|
|
|
|
/** @var IUserManager|MockObject */ |
|
|
|
|
protected $userManager; |
|
|
|
|
/** @var INotification|\PHPUnit\Framework\MockObject\MockObject */ |
|
|
|
|
/** @var INotification|MockObject */ |
|
|
|
|
protected $notification; |
|
|
|
|
/** @var IComment|\PHPUnit\Framework\MockObject\MockObject */ |
|
|
|
|
/** @var IComment|MockObject */ |
|
|
|
|
protected $comment; |
|
|
|
|
/** @var string */ |
|
|
|
|
protected $lc = 'tlh_KX'; |
|
|
|
|
@ -97,15 +98,7 @@ class NotifierTest extends TestCase { |
|
|
|
|
$displayName = 'Huraga'; |
|
|
|
|
$message = '@Huraga mentioned you in a comment on "Gre\'thor.odp"'; |
|
|
|
|
|
|
|
|
|
/** @var IUser|\PHPUnit\Framework\MockObject\MockObject $user */ |
|
|
|
|
$user = $this->createMock(IUser::class); |
|
|
|
|
$user->expects($this->once()) |
|
|
|
|
->method('getDisplayName') |
|
|
|
|
->willReturn($displayName); |
|
|
|
|
/** @var IUser|\PHPUnit\Framework\MockObject\MockObject $you */ |
|
|
|
|
$you = $this->createMock(IUser::class); |
|
|
|
|
|
|
|
|
|
/** @var Node|\PHPUnit\Framework\MockObject\MockObject $node */ |
|
|
|
|
/** @var Node|MockObject $node */ |
|
|
|
|
$node = $this->createMock(Node::class); |
|
|
|
|
$node |
|
|
|
|
->expects($this->atLeastOnce()) |
|
|
|
|
@ -213,10 +206,10 @@ class NotifierTest extends TestCase { |
|
|
|
|
|
|
|
|
|
$this->userManager |
|
|
|
|
->expects($this->exactly(2)) |
|
|
|
|
->method('get') |
|
|
|
|
->method('getDisplayName') |
|
|
|
|
->willReturnMap([ |
|
|
|
|
['huraga', $user], |
|
|
|
|
['you', $you], |
|
|
|
|
['huraga', $displayName], |
|
|
|
|
['you', 'You'], |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
$this->notifier->prepare($this->notification, $this->lc); |
|
|
|
|
@ -226,10 +219,7 @@ class NotifierTest extends TestCase { |
|
|
|
|
$fileName = 'Gre\'thor.odp'; |
|
|
|
|
$message = 'You were mentioned on "Gre\'thor.odp", in a comment by a user that has since been deleted'; |
|
|
|
|
|
|
|
|
|
/** @var IUser|\PHPUnit\Framework\MockObject\MockObject $you */ |
|
|
|
|
$you = $this->createMock(IUser::class); |
|
|
|
|
|
|
|
|
|
/** @var Node|\PHPUnit\Framework\MockObject\MockObject $node */ |
|
|
|
|
/** @var Node|MockObject $node */ |
|
|
|
|
$node = $this->createMock(Node::class); |
|
|
|
|
$node |
|
|
|
|
->expects($this->atLeastOnce()) |
|
|
|
|
@ -334,9 +324,11 @@ class NotifierTest extends TestCase { |
|
|
|
|
|
|
|
|
|
$this->userManager |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('get') |
|
|
|
|
->with('you') |
|
|
|
|
->willReturn($you); |
|
|
|
|
->method('getDisplayName') |
|
|
|
|
->willReturnMap([ |
|
|
|
|
['huraga', null], |
|
|
|
|
['you', 'You'], |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
$this->notifier->prepare($this->notification, $this->lc); |
|
|
|
|
} |
|
|
|
|
@ -373,7 +365,7 @@ class NotifierTest extends TestCase { |
|
|
|
|
|
|
|
|
|
$this->userManager |
|
|
|
|
->expects($this->never()) |
|
|
|
|
->method('get'); |
|
|
|
|
->method('getDisplayName'); |
|
|
|
|
|
|
|
|
|
$this->notifier->prepare($this->notification, $this->lc); |
|
|
|
|
} |
|
|
|
|
@ -411,7 +403,7 @@ class NotifierTest extends TestCase { |
|
|
|
|
|
|
|
|
|
$this->userManager |
|
|
|
|
->expects($this->never()) |
|
|
|
|
->method('get'); |
|
|
|
|
->method('getDisplayName'); |
|
|
|
|
|
|
|
|
|
$this->notifier->prepare($this->notification, $this->lc); |
|
|
|
|
} |
|
|
|
|
@ -422,12 +414,6 @@ class NotifierTest extends TestCase { |
|
|
|
|
|
|
|
|
|
$displayName = 'Huraga'; |
|
|
|
|
|
|
|
|
|
/** @var IUser|\PHPUnit\Framework\MockObject\MockObject $user */ |
|
|
|
|
$user = $this->createMock(IUser::class); |
|
|
|
|
$user->expects($this->once()) |
|
|
|
|
->method('getDisplayName') |
|
|
|
|
->willReturn($displayName); |
|
|
|
|
|
|
|
|
|
$this->folder |
|
|
|
|
->expects($this->never()) |
|
|
|
|
->method('getById'); |
|
|
|
|
@ -472,9 +458,9 @@ class NotifierTest extends TestCase { |
|
|
|
|
|
|
|
|
|
$this->userManager |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('get') |
|
|
|
|
->method('getDisplayName') |
|
|
|
|
->with('huraga') |
|
|
|
|
->willReturn($user); |
|
|
|
|
->willReturn($displayName); |
|
|
|
|
|
|
|
|
|
$this->notifier->prepare($this->notification, $this->lc); |
|
|
|
|
} |
|
|
|
|
@ -485,12 +471,6 @@ class NotifierTest extends TestCase { |
|
|
|
|
|
|
|
|
|
$displayName = 'Huraga'; |
|
|
|
|
|
|
|
|
|
/** @var IUser|\PHPUnit\Framework\MockObject\MockObject $user */ |
|
|
|
|
$user = $this->createMock(IUser::class); |
|
|
|
|
$user->expects($this->once()) |
|
|
|
|
->method('getDisplayName') |
|
|
|
|
->willReturn($displayName); |
|
|
|
|
|
|
|
|
|
$this->folder |
|
|
|
|
->expects($this->never()) |
|
|
|
|
->method('getById'); |
|
|
|
|
@ -536,9 +516,9 @@ class NotifierTest extends TestCase { |
|
|
|
|
|
|
|
|
|
$this->userManager |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('get') |
|
|
|
|
->method('getDisplayName') |
|
|
|
|
->with('huraga') |
|
|
|
|
->willReturn($user); |
|
|
|
|
->willReturn($displayName); |
|
|
|
|
|
|
|
|
|
$this->notifier->prepare($this->notification, $this->lc); |
|
|
|
|
} |
|
|
|
|
@ -549,12 +529,6 @@ class NotifierTest extends TestCase { |
|
|
|
|
|
|
|
|
|
$displayName = 'Huraga'; |
|
|
|
|
|
|
|
|
|
/** @var IUser|\PHPUnit\Framework\MockObject\MockObject $user */ |
|
|
|
|
$user = $this->createMock(IUser::class); |
|
|
|
|
$user->expects($this->once()) |
|
|
|
|
->method('getDisplayName') |
|
|
|
|
->willReturn($displayName); |
|
|
|
|
|
|
|
|
|
$userFolder = $this->createMock(Folder::class); |
|
|
|
|
$this->folder->expects($this->once()) |
|
|
|
|
->method('getUserFolder') |
|
|
|
|
@ -609,9 +583,9 @@ class NotifierTest extends TestCase { |
|
|
|
|
|
|
|
|
|
$this->userManager |
|
|
|
|
->expects($this->once()) |
|
|
|
|
->method('get') |
|
|
|
|
->method('getDisplayName') |
|
|
|
|
->with('huraga') |
|
|
|
|
->willReturn($user); |
|
|
|
|
->willReturn($displayName); |
|
|
|
|
|
|
|
|
|
$this->notifier->prepare($this->notification, $this->lc); |
|
|
|
|
} |
|
|
|
|
|