UserCache::singleton()->doQuery( $userIds, array( 'userpage' ), __METHOD__ );
}
+ /**
+ * @param string $field
+ * @param string $value
+ * @return Message|string|int The return type depends on the value of $field:
+ * - thumb: string
+ * - img_timestamp: string
+ * - img_name: string
+ * - img_user_text: string
+ * - img_size: string
+ * - img_description: string
+ * - count: int
+ * - top: Message
+ * @throws MWException
+ */
function formatValue( $field, $value ) {
switch ( $field ) {
case 'thumb':
case 'top':
// Messages: listfiles-latestversion-yes, listfiles-latestversion-no
return $this->msg( 'listfiles-latestversion-' . $value );
+ default:
+ throw new MWException( "Unknown field '$field'" );
}
}
--- /dev/null
+<?php
+/**
+ * Test class for SpecialListFiles class.
+ *
+ * Copyright © 2013, Antoine Musso
+ * Copyright © 2013, Siebrand Mazeland
+ * Copyright © 2013, Wikimedia Foundation Inc.
+ *
+ */
+
+class SpecialListFilesTest extends MediaWikiTestCase {
+ /**
+ * @expectedException MWException
+ * @expectedExceptionMesage invalid_field
+ * @covers ImageListPager::formatValue
+ */
+ public function testFormatValuesThrowException() {
+ $page = new ImageListPager( RequestContext::getMain() );
+ $page->formatValue( 'invalid_field', 'invalid_value' );
+ }
+}