summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/UniversalLanguageSelector/tests/phpunit/ResourceLoaderULSJsonMessageModuleTest.php
blob: 739d390864dc3cb175094c875273417024f5584d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php

namespace UniversalLanguageSelector\Tests;

use ResourceLoaderULSJsonMessageModule;

/**
 * @covers \ResourceLoaderULSJsonMessageModule
 *
 * @license GPL-2.0-or-later
 * @author Thiemo Kreuz
 */
class ResourceLoaderULSJsonMessageModuleTest extends \PHPUnit\Framework\TestCase {
	use \PHPUnit4And6Compat;

	public function testAllReturnValues() {
		$instance = new ResourceLoaderULSJsonMessageModule();

		$context = $this->createMock( \ResourceLoaderContext::class );
		$context->method( 'getLanguage' )
			->willReturn( 'en' );

		$this->assertContainsOnly( 'string', $instance->getDependencies(), 'dependencies' );
		$this->assertContainsOnly( 'string', $instance->getTargets(), 'targets' );

		$summary = $instance->getDefinitionSummary( $context );
		$lastElement = end( $summary );
		$this->assertArrayHasKey( 'fileHashes', $lastElement );
		$this->assertContainsOnly( 'string', $lastElement['fileHashes'] );

		$script = $instance->getScript( $context );
		$this->assertStringStartsWith( 'mw.uls.loadLocalization("en",{"', $script );
	}

}