diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2013-01-18 16:46:04 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2013-01-18 16:46:04 +0100 |
commit | 63601400e476c6cf43d985f3e7b9864681695ed4 (patch) | |
tree | f7846203a952e38aaf66989d0a4702779f549962 /tests/jasmine | |
parent | 8ff01378c9e0207f9169b81966a51def645b6a51 (diff) |
Update to MediaWiki 1.20.2
this update includes:
* adjusted Arch Linux skin
* updated FluxBBAuthPlugin
* patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024
Diffstat (limited to 'tests/jasmine')
-rw-r--r-- | tests/jasmine/SpecRunner.html | 58 | ||||
-rw-r--r-- | tests/jasmine/spec/mediawiki.Uri.spec.js | 307 | ||||
-rw-r--r-- | tests/jasmine/spec_makers/makeJqueryMsgSpec.php | 20 |
3 files changed, 30 insertions, 355 deletions
diff --git a/tests/jasmine/SpecRunner.html b/tests/jasmine/SpecRunner.html index 6af9b0c3..63d0fdfa 100644 --- a/tests/jasmine/SpecRunner.html +++ b/tests/jasmine/SpecRunner.html @@ -1,42 +1,28 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" - "http://www.w3.org/TR/html4/loose.dtd"> -<html> -<head> - <title>Jasmine Test Runner</title> - <link rel="stylesheet" type="text/css" href="lib/jasmine-1.0.1/jasmine.css"> - <script type="text/javascript" src="lib/jasmine-1.0.1/jasmine.js"></script> - <script type="text/javascript" src="lib/jasmine-1.0.1/jasmine-html.js"></script> +<!DOCTYPE html> +<html lang="en" dir="ltr"> + <head> + <title>Jasmine Test Runner</title> + <meta charset="UTF-8" /> + <link rel="stylesheet" type="text/css" href="lib/jasmine-1.0.1/jasmine.css"> + <script src="lib/jasmine-1.0.1/jasmine.js"></script> + <script src="lib/jasmine-1.0.1/jasmine-html.js"></script> - <!-- include source files here... --> - <script type="text/javascript" src="../../load.php?debug=true&lang=en&modules=jquery%7Cmediawiki&only=scripts&skin=vector"></script> - - <script type="text/javascript" src="../../resources/mediawiki/mediawiki.js"></script> + <!-- include source files here... --> + <script src="../../load.php?debug=true&lang=en&modules=startup&only=scripts&skin=vector&*"></script> + <script> + mw.loader.load( ['mediawiki.jqueryMsg'] ); + </script> - <script type="text/javascript" src="../../resources/mediawiki.language/mediawiki.language.js"></script> - <script type="text/javascript" src="../../resources/mediawiki/mediawiki.jqueryMsg.js"></script> - <script type="text/javascript" src="../../resources/mediawiki/mediawiki.Uri.js"></script> -<!-- - <script type="text/javascript" src="../../resources/mediawiki/mediawiki.api.js"></script> - <script type="text/javascript" src="../../resources/mediawiki/mediawiki.api.edit.js"></script> ---> + <!-- insert test data files here --> + <script src="spec/mediawiki.jqueryMsg.spec.data.js"></script> - <!-- insert test data files here --> - <script type="text/javascript" src="spec/mediawiki.jqueryMsg.spec.data.js"></script> - - <!-- include spec files here... --> - <script type="text/javascript" src="spec/mediawiki.Uri.spec.js"></script> - <!-- - <script type="text/javascript" src="spec/mw.Api.spec.js"></script> - <script type="text/javascript" src="spec/mw.Api.edit.spec.js"></script> - --> - <script type="text/javascript" src="spec/mediawiki.jqueryMsg.spec.js"></script> - -</head> + <!-- include spec files here... --> + <script src="spec/mediawiki.jqueryMsg.spec.js"></script> + </head> <body> -<script type="text/javascript"> - jasmine.getEnv().addReporter( new jasmine.TrivialReporter() ); - jasmine.getEnv().execute(); -</script> - + <script> + jasmine.getEnv().addReporter( new jasmine.TrivialReporter() ); + jasmine.getEnv().execute(); + </script> </body> </html> diff --git a/tests/jasmine/spec/mediawiki.Uri.spec.js b/tests/jasmine/spec/mediawiki.Uri.spec.js deleted file mode 100644 index 721ccb38..00000000 --- a/tests/jasmine/spec/mediawiki.Uri.spec.js +++ /dev/null @@ -1,307 +0,0 @@ -( function() { - - // ensure we have a generic URI parser if not running in a browser - if ( !mw.Uri ) { - mw.Uri = mw.UriRelative( 'http://example.com/' ); - } - - describe( "mw.Uri", function() { - - describe( "should work well in loose and strict mode", function() { - - function basicTests( strict ) { - - describe( "should parse a simple HTTP URI correctly", function() { - - var uriString = 'http://www.ietf.org/rfc/rfc2396.txt'; - var uri; - if ( strict ) { - uri = new mw.Uri( uriString, strict ); - } else { - uri = new mw.Uri( uriString ); - } - - it( "should have basic object properties", function() { - expect( uri.protocol ).toEqual( 'http' ); - expect( uri.host ).toEqual( 'www.ietf.org' ); - expect( uri.port ).not.toBeDefined(); - expect( uri.path ).toEqual( '/rfc/rfc2396.txt' ); - expect( uri.query ).toEqual( {} ); - expect( uri.fragment ).not.toBeDefined(); - } ); - - describe( "should construct composite components of URI on request", function() { - it( "should have empty userinfo", function() { - expect( uri.getUserInfo() ).toEqual( '' ); - } ); - - it( "should have authority equal to host", function() { - expect( uri.getAuthority() ).toEqual( 'www.ietf.org' ); - } ); - - it( "should have hostport equal to host", function() { - expect( uri.getHostPort() ).toEqual( 'www.ietf.org' ); - } ); - - it( "should have empty string as query string", function() { - expect( uri.getQueryString() ).toEqual( '' ); - } ); - - it( "should have path as relative path", function() { - expect( uri.getRelativePath() ).toEqual( '/rfc/rfc2396.txt' ); - } ); - - it( "should return a uri string equivalent to original", function() { - expect( uri.toString() ).toEqual( uriString ); - } ); - } ); - } ); - } - - describe( "should work in loose mode", function() { - basicTests( false ); - } ); - - describe( "should work in strict mode", function() { - basicTests( true ); - } ); - - } ); - - it( "should parse a simple ftp URI correctly with user and password", function() { - var uri = new mw.Uri( 'ftp://usr:pwd@192.0.2.16/' ); - expect( uri.protocol ).toEqual( 'ftp' ); - expect( uri.user ).toEqual( 'usr' ); - expect( uri.password ).toEqual( 'pwd' ); - expect( uri.host ).toEqual( '192.0.2.16' ); - expect( uri.port ).not.toBeDefined(); - expect( uri.path ).toEqual( '/' ); - expect( uri.query ).toEqual( {} ); - expect( uri.fragment ).not.toBeDefined(); - } ); - - it( "should parse a simple querystring", function() { - var uri = new mw.Uri( 'http://www.google.com/?q=uri' ); - expect( uri.protocol ).toEqual( 'http' ); - expect( uri.host ).toEqual( 'www.google.com' ); - expect( uri.port ).not.toBeDefined(); - expect( uri.path ).toEqual( '/' ); - expect( uri.query ).toBeDefined(); - expect( uri.query ).toEqual( { q: 'uri' } ); - expect( uri.fragment ).not.toBeDefined(); - expect( uri.getQueryString() ).toEqual( 'q=uri' ); - } ); - - describe( "should handle multiple value query args (overrideKeys on)", function() { - var uri = new mw.Uri( 'http://www.example.com/dir/?m=foo&m=bar&n=1', { overrideKeys: true } ); - it ( "should parse with multiple values", function() { - expect( uri.query.m ).toEqual( 'bar' ); - expect( uri.query.n ).toEqual( '1' ); - } ); - it ( "should accept multiple values", function() { - uri.query.n = [ "x", "y", "z" ]; - expect( uri.toString() ).toContain( 'm=bar' ); - expect( uri.toString() ).toContain( 'n=x&n=y&n=z' ); - expect( uri.toString().length ).toEqual( 'http://www.example.com/dir/?m=bar&n=x&n=y&n=z'.length ); - } ); - } ); - - describe( "should handle multiple value query args (overrideKeys off)", function() { - var uri = new mw.Uri( 'http://www.example.com/dir/?m=foo&m=bar&n=1', { overrideKeys: false } ); - it ( "should parse with multiple values", function() { - expect( uri.query.m.length ).toEqual( 2 ); - expect( uri.query.m[0] ).toEqual( 'foo' ); - expect( uri.query.m[1] ).toEqual( 'bar' ); - expect( uri.query.n ).toEqual( '1' ); - } ); - it ( "should accept multiple values", function() { - uri.query.n = [ "x", "y", "z" ]; - expect( uri.toString() ).toContain( 'm=foo&m=bar' ); - expect( uri.toString() ).toContain( 'n=x&n=y&n=z' ); - expect( uri.toString().length ).toEqual( 'http://www.example.com/dir/?m=foo&m=bar&n=x&n=y&n=z'.length ); - } ); - it ( "should be okay with removing values", function() { - uri.query.m.splice( 0, 1 ); - delete uri.query.n; - expect( uri.toString() ).toEqual( 'http://www.example.com/dir/?m=bar' ); - uri.query.m.splice( 0, 1 ); - expect( uri.toString() ).toEqual( 'http://www.example.com/dir/' ); - } ); - } ); - - describe( "should deal with an all-dressed URI with everything", function() { - var uri = new mw.Uri( 'http://auth@www.example.com:81/dir/dir.2/index.htm?q1=0&&test1&test2=value+%28escaped%29#top' ); - - it( "should have basic object properties", function() { - expect( uri.protocol ).toEqual( 'http' ); - expect( uri.user ).toEqual( 'auth' ); - expect( uri.password ).not.toBeDefined(); - expect( uri.host ).toEqual( 'www.example.com' ); - expect( uri.port ).toEqual( '81' ); - expect( uri.path ).toEqual( '/dir/dir.2/index.htm' ); - expect( uri.query ).toEqual( { q1: '0', test1: null, test2: 'value (escaped)' } ); - expect( uri.fragment ).toEqual( 'top' ); - } ); - - describe( "should construct composite components of URI on request", function() { - it( "should have userinfo", function() { - expect( uri.getUserInfo() ).toEqual( 'auth' ); - } ); - - it( "should have authority equal to auth@hostport", function() { - expect( uri.getAuthority() ).toEqual( 'auth@www.example.com:81' ); - } ); - - it( "should have hostport equal to host:port", function() { - expect( uri.getHostPort() ).toEqual( 'www.example.com:81' ); - } ); - - it( "should have query string which contains all components", function() { - var queryString = uri.getQueryString(); - expect( queryString ).toContain( 'q1=0' ); - expect( queryString ).toContain( 'test1' ); - expect( queryString ).not.toContain( 'test1=' ); - expect( queryString ).toContain( 'test2=value+%28escaped%29' ); - } ); - - it( "should have path as relative path", function() { - expect( uri.getRelativePath() ).toContain( uri.path ); - expect( uri.getRelativePath() ).toContain( uri.getQueryString() ); - expect( uri.getRelativePath() ).toContain( uri.fragment ); - } ); - - } ); - } ); - - describe( "should be able to clone itself", function() { - var original = new mw.Uri( 'http://en.wiki.local/w/api.php?action=query&foo=bar' ); - var clone = original.clone(); - - it( "should make clones equivalent", function() { - expect( original ).toEqual( clone ); - expect( original.toString() ).toEqual( clone.toString() ); - } ); - - it( "should be able to manipulate clones independently", function() { - // but they are still different objects - expect( original ).not.toBe( clone ); - // and can diverge - clone.host = 'fr.wiki.local'; - expect( original.host ).not.toEqual( clone.host ); - expect( original.toString() ).not.toEqual( clone.toString() ); - } ); - } ); - - describe( "should be able to construct URL from object", function() { - it ( "should construct given basic arguments", function() { - var uri = new mw.Uri( { protocol: 'http', host: 'www.foo.local', path: '/this' } ); - expect( uri.toString() ).toEqual( 'http://www.foo.local/this' ); - } ); - - it ( "should construct given more complex arguments", function() { - var uri = new mw.Uri( { - protocol: 'http', - host: 'www.foo.local', - path: '/this', - query: { hi: 'there' }, - fragment: 'blah' - } ); - expect( uri.toString() ).toEqual( 'http://www.foo.local/this?hi=there#blah' ); - } ); - - it ( "should fail to construct without required properties", function() { - expect( function() { - var uri = new mw.Uri( { protocol: 'http', host: 'www.foo.local' } ); - } ).toThrow( "Bad constructor arguments" ); - } ); - } ); - - describe( "should be able to manipulate properties", function() { - var uri; - - beforeEach( function() { - uri = new mw.Uri( 'http://en.wiki.local/w/api.php' ); - } ); - - it( "can add a fragment", function() { - uri.fragment = 'frag'; - expect( uri.toString() ).toEqual( 'http://en.wiki.local/w/api.php#frag' ); - } ); - - it( "can change host and port", function() { - uri.host = 'fr.wiki.local'; - uri.port = '8080'; - expect( uri.toString() ).toEqual( 'http://fr.wiki.local:8080/w/api.php' ); - } ); - - it ( "can add query arguments", function() { - uri.query.foo = 'bar'; - expect( uri.toString() ).toEqual( 'http://en.wiki.local/w/api.php?foo=bar' ); - } ); - - it ( "can extend query arguments", function() { - uri.query.foo = 'bar'; - expect( uri.toString() ).toEqual( 'http://en.wiki.local/w/api.php?foo=bar' ); - uri.extend( { foo: 'quux', pif: 'paf' } ); - expect( uri.toString() ).toContain( 'foo=quux' ); - expect( uri.toString() ).not.toContain( 'foo=bar' ); - expect( uri.toString() ).toContain( 'pif=paf' ); - } ); - - it ( "can remove query arguments", function() { - uri.query.foo = 'bar'; - expect( uri.toString() ).toEqual( 'http://en.wiki.local/w/api.php?foo=bar' ); - delete( uri.query.foo ); - expect( uri.toString() ).toEqual( 'http://en.wiki.local/w/api.php' ); - } ); - - } ); - - describe( "should handle protocol-relative URLs", function() { - - it ( "should create protocol-relative URLs with same protocol as document", function() { - var uriRel = mw.UriRelative( 'glork://en.wiki.local/foo.php' ); - var uri = new uriRel( '//en.wiki.local/w/api.php' ); - expect( uri.protocol ).toEqual( 'glork' ); - } ); - - } ); - - it( "should throw error on no arguments to constructor", function() { - expect( function() { - var uri = new mw.Uri(); - } ).toThrow( "Bad constructor arguments" ); - } ); - - it( "should throw error on empty string as argument to constructor", function() { - expect( function() { - var uri = new mw.Uri( '' ); - } ).toThrow( "Bad constructor arguments" ); - } ); - - it( "should throw error on non-URI as argument to constructor", function() { - expect( function() { - var uri = new mw.Uri( 'glaswegian penguins' ); - } ).toThrow( "Bad constructor arguments" ); - } ); - - it( "should throw error on improper URI as argument to constructor", function() { - expect( function() { - var uri = new mw.Uri( 'http:/foo.com' ); - } ).toThrow( "Bad constructor arguments" ); - } ); - - it( "should throw error on URI without protocol or // in strict mode", function() { - expect( function() { - var uri = new mw.Uri( 'foo.com/bar/baz', true ); - } ).toThrow( "Bad constructor arguments" ); - } ); - - it( "should normalize URI without protocol or // in loose mode", function() { - var uri = new mw.Uri( 'foo.com/bar/baz', false ); - expect( uri.toString() ).toEqual( 'http://foo.com/bar/baz' ); - } ); - - } ); - -} )(); diff --git a/tests/jasmine/spec_makers/makeJqueryMsgSpec.php b/tests/jasmine/spec_makers/makeJqueryMsgSpec.php index 1ac8dcba..840da96a 100644 --- a/tests/jasmine/spec_makers/makeJqueryMsgSpec.php +++ b/tests/jasmine/spec_makers/makeJqueryMsgSpec.php @@ -8,13 +8,13 @@ * which can be used with the JasmineBDD framework. This specification can then be used by simply including it into * the SpecRunner.html file. * - * This is similar to Michael Dale (mdale@mediawiki.org)'s parser tests, except that it doesn't look up the + * This is similar to Michael Dale (mdale@mediawiki.org)'s parser tests, except that it doesn't look up the * API results while doing the test, so the Jasmine run is much faster(at the cost of being out of date in rare * circumstances. But mostly the parsing that we are doing in Javascript doesn't change much.) * - */ + */ -$maintenanceDir = dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ) . '/maintenance'; +$maintenanceDir = dirname( dirname( dirname( __DIR__ ) ) ) . '/maintenance'; require( "$maintenanceDir/Maintenance.php" ); @@ -51,26 +51,22 @@ class MakeLanguageSpec extends Maintenance { private function getMessagesAndTests() { $messages = array(); $tests = array(); - $wfMsgExtOptions = array( 'parsemag' ); foreach ( array( 'en', 'fr', 'ar', 'jp', 'zh' ) as $languageCode ) { - $wfMsgExtOptions['language'] = $languageCode; foreach ( self::$keyToTestArgs as $key => $testArgs ) { foreach ($testArgs as $args) { // get the raw template, without any transformations - $template = wfMsgGetKey( $key, /* useDb */ true, $languageCode, /* transform */ false ); + $template = wfMessage( $key )->inLanguage( $languageCode )->plain(); - // get the magic-parsed version with args - $wfMsgExtArgs = array_merge( array( $key, $wfMsgExtOptions ), $args ); - $result = call_user_func_array( 'wfMsgExt', $wfMsgExtArgs ); + $result = wfMessage( $key, $args )->inLanguage( $languageCode )->text(); // record the template, args, language, and expected result - // fake multiple languages by flattening them together + // fake multiple languages by flattening them together $langKey = $languageCode . '_' . $key; $messages[ $langKey ] = $template; - $tests[] = array( + $tests[] = array( 'name' => $languageCode . " " . $key . " " . join( ",", $args ), 'key' => $langKey, - 'args' => $args, + 'args' => $args, 'result' => $result, 'lang' => $languageCode ); |