aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/language/converters/MniConverterTest.php
blob: 95946d328dca88817ecfa546371dbbfc2b4c6760 (plain) (blame)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
 * PHPUnit tests for the Meitei converter.
 * The language can be represented using two scripts:
 *  - Meitei (mni)
 *  - Bangla (mni-beng)
 *
 * @author Nokib Sarkar
 */

/**
 * @covers \MniConverter
 */
class MniConverterTest extends MediaWikiIntegrationTestCase {

	use LanguageConverterTestTrait;

	/**
	 * @covers \MediaWiki\Language\LanguageConverter::convertTo
	 */
	public function testConversionToBengali() {
		// A conversion of Meitei to Bengali
		$this->assertEquals(
			'মীতৈ অসী কংলৈপাক্কী অচৌবা ফুরুপকী মনুংদা ১নী ।',
			$this->convertToBengali(
				'ꯃꯤꯇꯩ ꯑꯁꯤ ꯀꯪꯂꯩꯄꯥꯛꯀꯤ ꯑꯆꯧꯕ ꯐꯨꯔꯨꯞꯀꯤ ꯃꯅꯨꯡꯗ ꯱ꯅꯤ ꯫'
			)
		);

		// A simple conversion of Bengali to Bengali
		$this->assertEquals( 'লৌমী লৌবুক তা কুম্দুবা ফৌ',
			$this->convertToBengali( 'ꯂꯧꯃꯤ ꯂꯧꯕꯨꯛ ꯇꯥ ꯀꯨꯝꯗꯨꯕꯥ ꯐꯧ' )
		);
	}

	public function testRemoveHalanta() {
		// Remove Halanta from the end of the word
		$this->assertEquals( 'ন ক ম ং ল ৎ প ',
			$this->convertTo( 'ꯟ ꯛ ꯝ ꯡ ꯜ ꯠ ꯞ ', 'mni-beng' )
		);
	}

	/**
	 * Wrapper for converter::convertTo() method
	 * @param string $text
	 * @param string $variant
	 * @return string
	 */
	protected function convertTo( $text, $variant ) {
		return $this->getLanguageConverter()->convertTo( $text, $variant );
	}

	protected function convertToBengali( $text ) {
		return $this->convertTo( $text, 'mni-beng' );
	}
}