-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: lang() may return false #7966
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of CodeIgniter 4 framework. | ||
* | ||
* (c) CodeIgniter Foundation <admin@codeigniter.com> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
// "Language" language settings | ||
return [ | ||
'invalidMessageFormat' => 'Invalid message format: "{0}", args: "{1}"', | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
use CodeIgniter\Test\CIUnitTestCase; | ||
use CodeIgniter\Test\Mock\MockLanguage; | ||
use Config\Services; | ||
use InvalidArgumentException; | ||
use MessageFormatter; | ||
use Tests\Support\Language\SecondMockLanguage; | ||
|
||
|
@@ -126,6 +127,30 @@ public function testGetLineArrayFormatsMessages(): void | |
$this->assertSame(['45 related books.'], $this->lang->getLine('books.bookList', [91 / 2])); | ||
} | ||
|
||
/** | ||
* @see https://github.com/codeigniter4/shield/issues/851 | ||
*/ | ||
public function testGetLineInvalidFormatMessage(): void | ||
{ | ||
// No intl extension? then we can't test this - go away.... | ||
if (! class_exists(MessageFormatter::class)) { | ||
$this->markTestSkipped('No intl support.'); | ||
} | ||
|
||
$this->expectException(InvalidArgumentException::class); | ||
$this->expectExceptionMessage( | ||
'Invalid message format: "تم الكشف عن كلمة المرور {0} بسبب اختراق البيانات وشوهدت {1 ، عدد} مرة في {2} في كلمات المرور المخترقة.", args: "password,hits,wording"' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this normal (language) for tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it might be better to make a comment as to explain testing of Arabic as international languages. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Set locale to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Requesting comment for test language |
||
); | ||
|
||
$this->lang->setLocale('ar'); | ||
|
||
$this->lang->setData('Auth', [ | ||
'errorPasswordPwned' => 'تم الكشف عن كلمة المرور {0} بسبب اختراق البيانات وشوهدت {1 ، عدد} مرة في {2} في كلمات المرور المخترقة.', | ||
]); | ||
|
||
$this->lang->getLine('Auth.errorPasswordPwned', ['password', 'hits', 'wording']); | ||
} | ||
|
||
/** | ||
* @see https://github.com/codeigniter4/CodeIgniter4/issues/891 | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is necessary.