Import: Handle uploads with sha1 starting with 0 properly
[mediawiki.git] / tests / phpunit / includes / resourceloader / DerivativeResourceLoaderContextTest.php
blob24ea4b28e8736194f4aeabb275bd3de8bc971521
1 <?php
3 /**
4 * @group ResourceLoader
5 */
6 class DerivativeResourceLoaderContextTest extends PHPUnit_Framework_TestCase {
8 protected static function getResourceLoaderContext() {
9 $resourceLoader = new ResourceLoader();
10 $request = new FauxRequest( array(
11 'lang' => 'zh',
12 'modules' => 'test.context',
13 'only' => 'scripts',
14 'skin' => 'fallback',
15 'target' => 'test',
16 ) );
17 return new ResourceLoaderContext( $resourceLoader, $request );
20 public function testGet() {
21 $context = self::getResourceLoaderContext();
22 $derived = new DerivativeResourceLoaderContext( $context );
24 $this->assertEquals( $derived->getLanguage(), 'zh' );
25 $this->assertEquals( $derived->getModules(), array( 'test.context' ) );
26 $this->assertEquals( $derived->getOnly(), 'scripts' );
27 $this->assertEquals( $derived->getSkin(), 'fallback' );
28 $this->assertEquals( $derived->getHash(), 'zh|fallback|||scripts|||||' );
31 public function testSetLanguage() {
32 $context = self::getResourceLoaderContext();
33 $derived = new DerivativeResourceLoaderContext( $context );
35 $derived->setLanguage( 'nl' );
36 $this->assertEquals( $derived->getLanguage(), 'nl' );
38 $derived->setLanguage( 'he' );
39 $this->assertEquals( $derived->getDirection(), 'rtl' );
42 public function testSetModules() {
43 $context = self::getResourceLoaderContext();
44 $derived = new DerivativeResourceLoaderContext( $context );
46 $derived->setModules( array( 'test.override' ) );
47 $this->assertEquals( $derived->getModules(), array( 'test.override' ) );
50 public function testSetOnly() {
51 $context = self::getResourceLoaderContext();
52 $derived = new DerivativeResourceLoaderContext( $context );
54 $derived->setOnly( 'styles' );
55 $this->assertEquals( $derived->getOnly(), 'styles' );
57 $derived->setOnly( null );
58 $this->assertEquals( $derived->getOnly(), null );
61 public function testSetSkin() {
62 $context = self::getResourceLoaderContext();
63 $derived = new DerivativeResourceLoaderContext( $context );
65 $derived->setSkin( 'override' );
66 $this->assertEquals( $derived->getSkin(), 'override' );
69 public function testGetHash() {
70 $context = self::getResourceLoaderContext();
71 $derived = new DerivativeResourceLoaderContext( $context );
73 $derived->setLanguage( 'nl' );
74 // Assert that subclass is able to clear parent class "hash" member
75 $this->assertEquals( $derived->getHash(), 'nl|fallback|||scripts|||||' );