Update unit tests
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
c3ef1cd90d
commit
565838da9c
|
@ -117,6 +117,9 @@ class NotificationsTest extends TestCase {
|
||||||
$comment->expects($this->any())
|
$comment->expects($this->any())
|
||||||
->method('getObjectType')
|
->method('getObjectType')
|
||||||
->willReturn('files');
|
->willReturn('files');
|
||||||
|
$comment->expects($this->any())
|
||||||
|
->method('getId')
|
||||||
|
->willReturn('1234');
|
||||||
|
|
||||||
$this->commentsManager->expects($this->any())
|
$this->commentsManager->expects($this->any())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
@ -192,6 +195,9 @@ class NotificationsTest extends TestCase {
|
||||||
$comment->expects($this->any())
|
$comment->expects($this->any())
|
||||||
->method('getObjectType')
|
->method('getObjectType')
|
||||||
->willReturn('files');
|
->willReturn('files');
|
||||||
|
$comment->expects($this->any())
|
||||||
|
->method('getId')
|
||||||
|
->willReturn('1234');
|
||||||
|
|
||||||
$this->commentsManager->expects($this->any())
|
$this->commentsManager->expects($this->any())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
|
|
@ -91,6 +91,9 @@ class ListenerTest extends TestCase {
|
||||||
[ 'type' => 'user', 'id' => '23452-4333-54353-2342'],
|
[ 'type' => 'user', 'id' => '23452-4333-54353-2342'],
|
||||||
[ 'type' => 'user', 'id' => 'yolo'],
|
[ 'type' => 'user', 'id' => 'yolo'],
|
||||||
]);
|
]);
|
||||||
|
$comment->expects($this->atLeastOnce())
|
||||||
|
->method('getId')
|
||||||
|
->willReturn('1234');
|
||||||
|
|
||||||
/** @var CommentsEvent|\PHPUnit_Framework_MockObject_MockObject $event */
|
/** @var CommentsEvent|\PHPUnit_Framework_MockObject_MockObject $event */
|
||||||
$event = $this->getMockBuilder(CommentsEvent::class)
|
$event = $this->getMockBuilder(CommentsEvent::class)
|
||||||
|
@ -186,6 +189,9 @@ class ListenerTest extends TestCase {
|
||||||
$comment->expects($this->once())
|
$comment->expects($this->once())
|
||||||
->method('getMentions')
|
->method('getMentions')
|
||||||
->willReturn([[ 'type' => 'user', 'id' => 'foobar']]);
|
->willReturn([[ 'type' => 'user', 'id' => 'foobar']]);
|
||||||
|
$comment->expects($this->atLeastOnce())
|
||||||
|
->method('getId')
|
||||||
|
->willReturn('1234');
|
||||||
|
|
||||||
/** @var CommentsEvent|\PHPUnit_Framework_MockObject_MockObject $event */
|
/** @var CommentsEvent|\PHPUnit_Framework_MockObject_MockObject $event */
|
||||||
$event = $this->getMockBuilder(CommentsEvent::class)
|
$event = $this->getMockBuilder(CommentsEvent::class)
|
||||||
|
|
|
@ -195,6 +195,9 @@ class NotifierTest extends TestCase {
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getMentions')
|
->method('getMentions')
|
||||||
->willReturn([['type' => 'user', 'id' => 'you']]);
|
->willReturn([['type' => 'user', 'id' => 'you']]);
|
||||||
|
$this->comment->expects($this->atLeastOnce())
|
||||||
|
->method('getId')
|
||||||
|
->willReturn('1234');
|
||||||
|
|
||||||
$this->commentsManager
|
$this->commentsManager
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
|
@ -539,7 +542,7 @@ class NotifierTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \OCP\Notification\AlreadyProcessedException
|
||||||
*/
|
*/
|
||||||
public function testPrepareUnresolvableFileID() {
|
public function testPrepareUnresolvableFileID() {
|
||||||
$displayName = 'Huraga';
|
$displayName = 'Huraga';
|
||||||
|
|
|
@ -30,6 +30,7 @@ use OCP\IGroupManager;
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
use OCP\L10N\IFactory;
|
use OCP\L10N\IFactory;
|
||||||
|
use OCP\Notification\AlreadyProcessedException;
|
||||||
use OCP\Notification\IManager;
|
use OCP\Notification\IManager;
|
||||||
use OCP\Notification\INotification;
|
use OCP\Notification\INotification;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
@ -112,21 +113,12 @@ class NotifierTest extends TestCase {
|
||||||
->method('getObjectId')
|
->method('getObjectId')
|
||||||
->willReturn($versionNotification);
|
->willReturn($versionNotification);
|
||||||
|
|
||||||
if ($exception) {
|
|
||||||
$this->notificationManager->expects($this->once())
|
|
||||||
->method('markProcessed')
|
|
||||||
->with($notification);
|
|
||||||
} else {
|
|
||||||
$this->notificationManager->expects($this->never())
|
|
||||||
->method('markProcessed');
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
self::invokePrivate($notifier, 'updateAlreadyInstalledCheck', [$notification, $versionInstalled]);
|
self::invokePrivate($notifier, 'updateAlreadyInstalledCheck', [$notification, $versionInstalled]);
|
||||||
$this->assertFalse($exception);
|
$this->assertFalse($exception);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->assertTrue($exception);
|
$this->assertTrue($exception);
|
||||||
$this->assertInstanceOf('InvalidArgumentException', $e);
|
$this->assertInstanceOf(AlreadyProcessedException::class, $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ class RemoteWipeNotificationsListener implements IEventListener {
|
||||||
$notification->setApp('auth')
|
$notification->setApp('auth')
|
||||||
->setUser($token->getUID())
|
->setUser($token->getUID())
|
||||||
->setDateTime($this->timeFactory->getDateTime())
|
->setDateTime($this->timeFactory->getDateTime())
|
||||||
->setObject('token', $token->getId())
|
->setObject('token', (string) $token->getId())
|
||||||
->setSubject($event, [
|
->setSubject($event, [
|
||||||
'name' => $token->getName(),
|
'name' => $token->getName(),
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -92,7 +92,7 @@ class RemoteWipeNotificationListenerTests extends TestCase {
|
||||||
$token->method('getId')->willReturn(123);
|
$token->method('getId')->willReturn(123);
|
||||||
$notification->expects($this->once())
|
$notification->expects($this->once())
|
||||||
->method('setObject')
|
->method('setObject')
|
||||||
->with('token', 123)
|
->with('token', '123')
|
||||||
->willReturnSelf();
|
->willReturnSelf();
|
||||||
$token->method('getName')->willReturn('Token 1');
|
$token->method('getName')->willReturn('Token 1');
|
||||||
$notification->expects($this->once())
|
$notification->expects($this->once())
|
||||||
|
@ -132,7 +132,7 @@ class RemoteWipeNotificationListenerTests extends TestCase {
|
||||||
$token->method('getId')->willReturn(123);
|
$token->method('getId')->willReturn(123);
|
||||||
$notification->expects($this->once())
|
$notification->expects($this->once())
|
||||||
->method('setObject')
|
->method('setObject')
|
||||||
->with('token', 123)
|
->with('token', '123')
|
||||||
->willReturnSelf();
|
->willReturnSelf();
|
||||||
$token->method('getName')->willReturn('Token 1');
|
$token->method('getName')->willReturn('Token 1');
|
||||||
$notification->expects($this->once())
|
$notification->expects($this->once())
|
||||||
|
|
Loading…
Reference in New Issue