Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/92261
Change subject: [WIP] Tests for the built-in notification types
......................................................................
[WIP] Tests for the built-in notification types
Change-Id: Ie93eff0a9a75a4a9816c81d57b7530149a14bb7a
---
A tests/NotificationsTest.php
1 file changed, 40 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo
refs/changes/61/92261/1
diff --git a/tests/NotificationsTest.php b/tests/NotificationsTest.php
new file mode 100644
index 0000000..e3fbd4c
--- /dev/null
+++ b/tests/NotificationsTest.php
@@ -0,0 +1,40 @@
+<?php
+
+/**
+ * Tests for the built in notification types
+ *
+ * @group Database
+ */
+class NotificationsTest extends MediaWikiTestCase {
+
+ /**
+ * Helper function to get a user's latest notification
+ * @param User $user
+ * @return EchoEvent
+ */
+ public static function getLatestNotification( $user ) {
+ $notifs = ApiEchoNotifications::getNotifications( $user );
+ return EchoEvent::newFromID( $notifs[1]['id'] );
+ }
+ /**
+ * @covers EchoHooks::onUserRights
+ */
+ public function testUserRightsNotif() {
+ $sysop = User::newFromName( 'UTSysop' );
+ $user = new User();
+ $user->setName( 'Dummy' );
+ $user->addToDatabase();
+
+ $context = new DerivativeContext( RequestContext::getMain() );
+ $context->setUser( $sysop );
+ $ur = new UserrightsPage();
+ $ur->setContext( $context );
+ $ur->doSaveUserGroups( $user, array('sysop'), array(), 'reason'
);
+ $event = self::getLatestNotification( $user );
+ $this->assertEquals( $event->getType(), 'user-rights' );
+ $extra = $event->getExtra();
+ $this->assertArrayHasKey( 'add', $extra );
+ $this->assertArrayEquals( array( 'sysop' ), $extra['add'] );
+ $this->assertArrayEquals( array(), $extra['remove'] );
+ }
+}
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/92261
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie93eff0a9a75a4a9816c81d57b7530149a14bb7a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits