Index: trunk/extensions/Translate/tests/MessageGroupBaseTest.php |
— | — | @@ -0,0 +1,91 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class MessageGroupBaseTest extends PHPUnit_Framework_TestCase { |
| 5 | + protected $groupConfiguration = array( |
| 6 | + 'BASIC' => array( |
| 7 | + 'class' => 'FileBasedMessageGroup', |
| 8 | + 'id' => 'test-id', |
| 9 | + 'label' => 'Test Label', |
| 10 | + 'namespace' => 'NS_MEDIAWIKI', |
| 11 | + 'description' => 'Test description', |
| 12 | + ), |
| 13 | + ); |
| 14 | + |
| 15 | + protected function setUp() { |
| 16 | + parent::setUp(); |
| 17 | + $this->group = MessageGroupBase::factory( $this->groupConfiguration ); |
| 18 | + |
| 19 | + } |
| 20 | + |
| 21 | + protected function tearDown() { |
| 22 | + unset( $this->apple ); |
| 23 | + parent::tearDown(); |
| 24 | + } |
| 25 | + |
| 26 | + public function testGetConfiguration() { |
| 27 | + $this->assertEquals( |
| 28 | + $this->groupConfiguration, |
| 29 | + $this->group->getConfiguration(), |
| 30 | + "configuration should not change." |
| 31 | + ); |
| 32 | + } |
| 33 | + |
| 34 | + public function testGetId() { |
| 35 | + $this->assertEquals( |
| 36 | + $this->groupConfiguration['BASIC']['id'], |
| 37 | + $this->group->getId(), |
| 38 | + "id comes from config." |
| 39 | + ); |
| 40 | + } |
| 41 | + |
| 42 | + public function testGetSourceLanguage() { |
| 43 | + $this->assertEquals( |
| 44 | + 'en', |
| 45 | + $this->group->getSourceLanguage(), |
| 46 | + "source language defaults to en." |
| 47 | + ); |
| 48 | + } |
| 49 | + |
| 50 | + public function testGetNamespaceConstant() { |
| 51 | + $this->assertEquals( |
| 52 | + NS_MEDIAWIKI, |
| 53 | + $this->group->getNamespace(), |
| 54 | + "should parse string namespace contant." |
| 55 | + ); |
| 56 | + } |
| 57 | + |
| 58 | + public function testGetNamespaceNumber() { |
| 59 | + $conf = $this->groupConfiguration; |
| 60 | + $conf['BASIC']['namespace'] = NS_MEDIAWIKI; |
| 61 | + $group = MessageGroupBase::factory( $conf ); |
| 62 | + |
| 63 | + $this->assertEquals( |
| 64 | + NS_MEDIAWIKI, |
| 65 | + $this->group->getNamespace(), |
| 66 | + "should parse integer namespace number." |
| 67 | + ); |
| 68 | + } |
| 69 | + |
| 70 | + public function testGetNamespaceString() { |
| 71 | + $conf = $this->groupConfiguration; |
| 72 | + $conf['BASIC']['namespace'] = 'mediawiki'; |
| 73 | + $group = MessageGroupBase::factory( $conf ); |
| 74 | + |
| 75 | + $this->assertEquals( |
| 76 | + NS_MEDIAWIKI, |
| 77 | + $this->group->getNamespace(), |
| 78 | + "should parse string namespace name." |
| 79 | + ); |
| 80 | + } |
| 81 | + |
| 82 | + /** |
| 83 | + * @expectedException MWException |
| 84 | + * @expectedExceptionMessage No valid namespace defined |
| 85 | + */ |
| 86 | + public function testGetNamespaceInvalid() { |
| 87 | + $conf = $this->groupConfiguration; |
| 88 | + $conf['BASIC']['namespace'] = 'ergweofijwef'; |
| 89 | + $group = MessageGroupBase::factory( $conf ); |
| 90 | + } |
| 91 | + |
| 92 | +} |
Property changes on: trunk/extensions/Translate/tests/MessageGroupBaseTest.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 93 | + native |
Index: trunk/extensions/Translate/tests/TranslateTestSuite.php |
— | — | @@ -0,0 +1,18 @@ |
| 2 | +<?php |
| 3 | +require_once 'PHPUnit/Framework/TestSuite.php'; |
| 4 | +class TranslateTestSuite extends PHPUnit_Framework_TestSuite { |
| 5 | + public static function registerUnitTests( &$files ) { |
| 6 | + $testDir = dirname( __FILE__ ) . '/'; |
| 7 | + $files[] = $testDir . 'MessageGroupBaseTest.php'; |
| 8 | + return true; |
| 9 | + } |
| 10 | + |
| 11 | + public function __construct() { |
| 12 | + $this->setName ( 'TranslateTestSuite' ); |
| 13 | + $this->addTestSuite ( 'MessageGroupBase' ); |
| 14 | + } |
| 15 | + |
| 16 | + public static function suite() { |
| 17 | + return new self(); |
| 18 | + } |
| 19 | +} |
Property changes on: trunk/extensions/Translate/tests/TranslateTestSuite.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 20 | + native |
Index: trunk/extensions/Translate/Translate.php |
— | — | @@ -118,6 +118,8 @@ |
119 | 119 | |
120 | 120 | $wgHooks['LinkBegin'][] = 'SpecialMyLanguage::linkfix'; |
121 | 121 | |
| 122 | +$wgHooks['UnitTestsList'][] = 'TranslateTestSuite::registerUnitTests'; |
| 123 | + |
122 | 124 | // New rights |
123 | 125 | $wgAvailableRights[] = 'translate'; |
124 | 126 | $wgAvailableRights[] = 'translate-import'; |
Index: trunk/extensions/Translate/_autoload.php |
— | — | @@ -188,5 +188,11 @@ |
189 | 189 | */ |
190 | 190 | $wgAutoloadClasses['ApiQueryMessageCollection'] = $dir . 'api/ApiQueryMessageCollection.php'; |
191 | 191 | $wgAutoloadClasses['ApiQueryMessageGroups'] = $dir . 'api/ApiQueryMessageGroups.php'; |
| 192 | +/**@}*/ |
192 | 193 | |
| 194 | +/** |
| 195 | + * @name Tests |
| 196 | + * @{ |
| 197 | + */ |
| 198 | +$wgAutoloadClasses['TranslateTestSuite'] = $dir . 'tests/TranslateTestSuite.php'; |
193 | 199 | /**@}*/ |