Add unit tests for comment handling

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2018-10-09 13:06:41 +02:00
parent 5edb95fc6b
commit da0cfdb1dc
3 changed files with 163 additions and 7 deletions

View File

@@ -35,7 +35,7 @@ use OCP\Notification\INotifier;
use OCP\RichObjectStrings\Definitions;
class UnknownUserTest extends \Test\TestCase {
class NotifierTest extends \Test\TestCase {
/** @var IFactory */
protected $l10nFactory;
@@ -129,6 +129,53 @@ class UnknownUserTest extends \Test\TestCase {
}
public function testPrepareCardCommentMentioned() {
/** @var INotification $notification */
$notification = $this->createMock(INotification::class);
$notification->expects($this->once())
->method('getApp')
->willReturn('deck');
$notification->expects($this->once())
->method('getSubjectParameters')
->willReturn(['Card title', 'Board title', 'admin']);
$notification->expects($this->once())
->method('getSubject')
->willReturn('card-comment-mentioned');
$notification->expects($this->once())
->method('getObjectId')
->willReturn('123');
$this->cardMapper->expects($this->once())
->method('findBoardId')
->willReturn(999);
$expectedMessage = 'admin has mentioned in a comment on "Card title".';
$notification->expects($this->once())
->method('setParsedSubject')
->with($expectedMessage);
$notification->expects($this->once())
->method('setRichSubject')
->with('{user} has mentioned in a comment on "Card title".');
$this->url->expects($this->once())
->method('imagePath')
->with('deck', 'deck-dark.svg')
->willReturn('deck-dark.svg');
$this->url->expects($this->once())
->method('getAbsoluteURL')
->with('deck-dark.svg')
->willReturn('/absolute/deck-dark.svg');
$notification->expects($this->once())
->method('setIcon')
->with('/absolute/deck-dark.svg');
$actualNotification = $this->notifier->prepare($notification, 'en_US');
$this->assertEquals($notification, $actualNotification);
}
public function dataPrepareCardAssigned() {
return [
[true], [false]
@@ -269,4 +316,4 @@ class UnknownUserTest extends \Test\TestCase {
$this->assertEquals($notification, $actualNotification);
}
}
}