r96936 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96935‎ | r96936 | r96937 >
Date:01:40, 13 September 2011
Author:preilly
Status:old (Comments)
Tags:
Comment:
mft r96935
Modified paths:
  • /branches/wmf/1.17wmf1/extensions/MobileFrontend/DeviceDetection.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/MobileFrontend/MobileFrontend.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/MobileFrontend/tests (added) (history)
  • /branches/wmf/1.17wmf1/extensions/MobileFrontend/tests/MobileFrontendTest.php (added) (history)
  • /branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/application.wml.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/tests/MobileFrontendTest.php
@@ -0,0 +1,50 @@
 2+<?php
 3+
 4+class ExtMobileFrontendTest extends MediaWikiTestCase {
 5+
 6+ /**
 7+ * PHP 5.3.2 introduces the ReflectionMethod::setAccessible() method to allow the invocation of
 8+ * protected and private methods directly through the Reflection API
 9+ */
 10+ protected static function getMethod( $name ) {
 11+ $class = new ReflectionClass( 'ExtMobileFrontend' );
 12+ $method = $class->getMethod( $name );
 13+ $method->setAccessible( true );
 14+ return $method;
 15+ }
 16+
 17+ protected function setUp() {
 18+ parent::setUp();
 19+ $this->wgExtMobileFrontend = new ExtMobileFrontend();
 20+ }
 21+
 22+ protected function tearDown() {
 23+ unset( $this->wgExtMobileFrontend );
 24+ parent::tearDown();
 25+ }
 26+
 27+ public function testgetBaseDomain() {
 28+ $getBaseDomain = self::getMethod( 'getBaseDomain' );
 29+ $wgExtMobileFrontend = new ExtMobileFrontend();
 30+ $_SERVER['HTTP_HOST'] = 'en.wikipedia.org';
 31+ $this->assertEquals( '.wikipedia.org', $getBaseDomain->invokeArgs( $wgExtMobileFrontend, array() ) );
 32+ }
 33+
 34+ public function testgetRelativeURL() {
 35+ $getRelativeURL = self::getMethod( 'getRelativeURL' );
 36+ $wgExtMobileFrontend = new ExtMobileFrontend();
 37+ $url = 'http://en.wikipedia.org/wiki/Positional_astronomy';
 38+ $this->assertEquals( '/wiki/Positional_astronomy', $getRelativeURL->invokeArgs( $wgExtMobileFrontend, array( $url ) ) );
 39+ }
 40+
 41+ public function testdisableCaching() {
 42+ global $wgRequest;
 43+ $disableCaching = self::getMethod( 'disableCaching' );
 44+ $wgExtMobileFrontend = new ExtMobileFrontend();
 45+ $_SERVER['HTTP_VIA'] = '.wikimedia.org:3128';
 46+ $disableCaching->invokeArgs( $wgExtMobileFrontend, array() );
 47+ $this->assertEquals( 'no-cache, must-revalidate', $wgRequest->response()->getheader( 'Cache-Control' ) );
 48+ $this->assertEquals( 'Sat, 26 Jul 1997 05:00:00 GMT', $wgRequest->response()->getheader( 'Expires' ) );
 49+ $this->assertEquals( 'no-cache', $wgRequest->response()->getheader( 'Pragma' ) );
 50+ }
 51+}
\ No newline at end of file
Property changes on: branches/wmf/1.17wmf1/extensions/MobileFrontend/tests/MobileFrontendTest.php
___________________________________________________________________
Added: svn:eol-style
152 + native
Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/DeviceDetection.php
@@ -344,7 +344,7 @@
345345 } elseif ( preg_match( '/PLAYSTATION 3/', $userAgent ) ) {
346346 $formatName = 'ps3';
347347 } elseif ( preg_match( '/SAMSUNG/', $userAgent ) ) {
348 - $formatName = 'capable';
 348+ $formatName = 'capable';
349349 } elseif ( preg_match( '/BlackBerry/', $userAgent ) ) {
350350 $formatName = 'blackberry';
351351 }
Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/MobileFrontend.php
@@ -64,8 +64,16 @@
6565 $wgMFRemovableClasses = array(
6666 );
6767
 68+# Unit tests
 69+$wgHooks['UnitTestsList'][] = 'efExtMobileFrontendUnitTests';
 70+
 71+function efExtMobileFrontendUnitTests( &$files ) {
 72+ $files[] = dirname( __FILE__ ) . '/tests/MobileFrontendTest.php';
 73+ return true;
 74+}
 75+
6876 class ExtMobileFrontend {
69 - const VERSION = '0.5.62';
 77+ const VERSION = '0.5.63';
7078
7179 /**
7280 * @var DOMDocument
Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/application.wml.php
@@ -5,7 +5,7 @@
66 $code = self::$code;
77
88 $applicationHtml = <<<EOT
9 - <?xml version='1.0' encoding='utf-8' ?>
 9+<?xml version='1.0' encoding='utf-8' ?>
1010 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
1111 <wml xml:lang="{$code}" dir="{$dir}">
1212 <head>

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r96935add basic unit test support and small fix for formattingpreilly01:35, 13 September 2011

Comments

#Comment by 😂 (talk | contribs)   01:41, 13 September 2011

There is no need to merge phpunit tests to the deployment branch right now, we don't deploy them.

#Comment by Preilly (talk | contribs)   01:42, 13 September 2011

Okay, thanks I wasn't sure if we did or not. So, I wanted to err on the side of caution.

#Comment by 😂 (talk | contribs)   03:38, 21 September 2011

Setting back to new, we don't mark merges as ok until the revs being merged are ok/resolved.

Status & tagging log