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 |
1 | 52 | + native |
Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/DeviceDetection.php |
— | — | @@ -344,7 +344,7 @@ |
345 | 345 | } elseif ( preg_match( '/PLAYSTATION 3/', $userAgent ) ) { |
346 | 346 | $formatName = 'ps3'; |
347 | 347 | } elseif ( preg_match( '/SAMSUNG/', $userAgent ) ) { |
348 | | - $formatName = 'capable'; |
| 348 | + $formatName = 'capable'; |
349 | 349 | } elseif ( preg_match( '/BlackBerry/', $userAgent ) ) { |
350 | 350 | $formatName = 'blackberry'; |
351 | 351 | } |
Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/MobileFrontend.php |
— | — | @@ -64,8 +64,16 @@ |
65 | 65 | $wgMFRemovableClasses = array( |
66 | 66 | ); |
67 | 67 | |
| 68 | +# Unit tests |
| 69 | +$wgHooks['UnitTestsList'][] = 'efExtMobileFrontendUnitTests'; |
| 70 | + |
| 71 | +function efExtMobileFrontendUnitTests( &$files ) { |
| 72 | + $files[] = dirname( __FILE__ ) . '/tests/MobileFrontendTest.php'; |
| 73 | + return true; |
| 74 | +} |
| 75 | + |
68 | 76 | class ExtMobileFrontend { |
69 | | - const VERSION = '0.5.62'; |
| 77 | + const VERSION = '0.5.63'; |
70 | 78 | |
71 | 79 | /** |
72 | 80 | * @var DOMDocument |
Index: branches/wmf/1.17wmf1/extensions/MobileFrontend/views/layout/application.wml.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | $code = self::$code; |
7 | 7 | |
8 | 8 | $applicationHtml = <<<EOT |
9 | | - <?xml version='1.0' encoding='utf-8' ?> |
| 9 | +<?xml version='1.0' encoding='utf-8' ?> |
10 | 10 | <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> |
11 | 11 | <wml xml:lang="{$code}" dir="{$dir}"> |
12 | 12 | <head> |