mirror of
https://github.com/yiisoft/yii2.git
synced 2026-03-07 15:57:35 +01:00
Fixes #16910: Fix messages sorting on extract
This commit is contained in:
committed by
Alexander Makarov
parent
d07e286dbd
commit
c162bd7ae7
@@ -592,6 +592,35 @@ abstract class BaseMessageControllerTest extends TestCase
|
||||
$this->assertArrayHasKey($positiveKey1, $messages);
|
||||
$this->assertArrayHasKey($positiveKey2, $messages);
|
||||
}
|
||||
|
||||
public function testMessagesSorting()
|
||||
{
|
||||
$category = 'test_order_category';
|
||||
$key1 = 'key1';
|
||||
$key2 = 'key2';
|
||||
|
||||
$sourceFileContent = "Yii::t('{$category}', '{$key1}');Yii::t('{$category}', '{$key2}');";
|
||||
$this->createSourceFile($sourceFileContent);
|
||||
|
||||
$this->saveMessages([$key2 => 'already translated'], $category);
|
||||
|
||||
$this->saveConfigFile($this->getConfig([
|
||||
'sort' => true,
|
||||
]));
|
||||
$this->runMessageControllerAction('extract', [$this->configFileName]);
|
||||
|
||||
$keys = array_keys($this->loadMessages($category));
|
||||
$this->assertEquals([$key1, $key2], $keys, "The order of messages should be '{$key1}, {$key2}' when sort equals true");
|
||||
|
||||
|
||||
$this->saveMessages([$key2 => 'already translated'], $category);
|
||||
$this->saveConfigFile($this->getConfig([
|
||||
'sort' => false,
|
||||
]));
|
||||
$this->runMessageControllerAction('extract', [$this->configFileName]);
|
||||
$keys = array_keys($this->loadMessages($category));
|
||||
$this->assertEquals([$key2, $key1], $keys, "The order of messages should be '{$key2}, {$key1}' when sort equals false and {$key1} was added later");
|
||||
}
|
||||
}
|
||||
|
||||
class MessageControllerMock extends MessageController
|
||||
|
||||
Reference in New Issue
Block a user