Browse Source

Update unit tests

Signed-off-by: Joas Schilling <coding@schilljs.com>
tags/v17.0.0beta1
Joas Schilling 4 years ago
parent
commit
565838da9c
No account linked to committer's email address

+ 6
- 0
apps/comments/tests/Unit/Controller/NotificationsTest.php View File

@@ -117,6 +117,9 @@ class NotificationsTest extends TestCase {
$comment->expects($this->any())
->method('getObjectType')
->willReturn('files');
$comment->expects($this->any())
->method('getId')
->willReturn('1234');

$this->commentsManager->expects($this->any())
->method('get')
@@ -192,6 +195,9 @@ class NotificationsTest extends TestCase {
$comment->expects($this->any())
->method('getObjectType')
->willReturn('files');
$comment->expects($this->any())
->method('getId')
->willReturn('1234');

$this->commentsManager->expects($this->any())
->method('get')

+ 6
- 0
apps/comments/tests/Unit/Notification/ListenerTest.php View File

@@ -91,6 +91,9 @@ class ListenerTest extends TestCase {
[ 'type' => 'user', 'id' => '23452-4333-54353-2342'],
[ 'type' => 'user', 'id' => 'yolo'],
]);
$comment->expects($this->atLeastOnce())
->method('getId')
->willReturn('1234');

/** @var CommentsEvent|\PHPUnit_Framework_MockObject_MockObject $event */
$event = $this->getMockBuilder(CommentsEvent::class)
@@ -186,6 +189,9 @@ class ListenerTest extends TestCase {
$comment->expects($this->once())
->method('getMentions')
->willReturn([[ 'type' => 'user', 'id' => 'foobar']]);
$comment->expects($this->atLeastOnce())
->method('getId')
->willReturn('1234');

/** @var CommentsEvent|\PHPUnit_Framework_MockObject_MockObject $event */
$event = $this->getMockBuilder(CommentsEvent::class)

+ 4
- 1
apps/comments/tests/Unit/Notification/NotifierTest.php View File

@@ -195,6 +195,9 @@ class NotifierTest extends TestCase {
->expects($this->any())
->method('getMentions')
->willReturn([['type' => 'user', 'id' => 'you']]);
$this->comment->expects($this->atLeastOnce())
->method('getId')
->willReturn('1234');

$this->commentsManager
->expects($this->once())
@@ -539,7 +542,7 @@ class NotifierTest extends TestCase {
}

/**
* @expectedException \InvalidArgumentException
* @expectedException \OCP\Notification\AlreadyProcessedException
*/
public function testPrepareUnresolvableFileID() {
$displayName = 'Huraga';

+ 2
- 10
apps/updatenotification/tests/Notification/NotifierTest.php View File

@@ -30,6 +30,7 @@ use OCP\IGroupManager;
use OCP\IURLGenerator;
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\Notification\AlreadyProcessedException;
use OCP\Notification\IManager;
use OCP\Notification\INotification;
use Test\TestCase;
@@ -112,21 +113,12 @@ class NotifierTest extends TestCase {
->method('getObjectId')
->willReturn($versionNotification);

if ($exception) {
$this->notificationManager->expects($this->once())
->method('markProcessed')
->with($notification);
} else {
$this->notificationManager->expects($this->never())
->method('markProcessed');
}

try {
self::invokePrivate($notifier, 'updateAlreadyInstalledCheck', [$notification, $versionInstalled]);
$this->assertFalse($exception);
} catch (\Exception $e) {
$this->assertTrue($exception);
$this->assertInstanceOf('InvalidArgumentException', $e);
$this->assertInstanceOf(AlreadyProcessedException::class, $e);
}
}
}

+ 1
- 1
lib/private/Authentication/Listeners/RemoteWipeNotificationsListener.php View File

@@ -61,7 +61,7 @@ class RemoteWipeNotificationsListener implements IEventListener {
$notification->setApp('auth')
->setUser($token->getUID())
->setDateTime($this->timeFactory->getDateTime())
->setObject('token', $token->getId())
->setObject('token', (string) $token->getId())
->setSubject($event, [
'name' => $token->getName(),
]);

+ 2
- 2
tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php View File

@@ -92,7 +92,7 @@ class RemoteWipeNotificationListenerTests extends TestCase {
$token->method('getId')->willReturn(123);
$notification->expects($this->once())
->method('setObject')
->with('token', 123)
->with('token', '123')
->willReturnSelf();
$token->method('getName')->willReturn('Token 1');
$notification->expects($this->once())
@@ -132,7 +132,7 @@ class RemoteWipeNotificationListenerTests extends TestCase {
$token->method('getId')->willReturn(123);
$notification->expects($this->once())
->method('setObject')
->with('token', 123)
->with('token', '123')
->willReturnSelf();
$token->method('getName')->willReturn('Token 1');
$notification->expects($this->once())

Loading…
Cancel
Save