mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX: tests now pass when the locale is set to something other than 'en_US' in the mysite's _config.php file (from r107940)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112702 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
93eb6214b7
commit
0e3693f99e
@ -407,6 +407,11 @@ PHP;
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testCollectFromFilesystemAndWriteMasterTables() {
|
function testCollectFromFilesystemAndWriteMasterTables() {
|
||||||
|
$defaultlocal = i18n::default_locale();
|
||||||
|
$local = i18n::get_locale();
|
||||||
|
i18n::set_locale('en_US'); //set the locale to the US locale expected in the asserts
|
||||||
|
i18n::set_default_locale('en_US');
|
||||||
|
|
||||||
$c = new i18nTextCollector();
|
$c = new i18nTextCollector();
|
||||||
$c->basePath = $this->alternateBasePath;
|
$c->basePath = $this->alternateBasePath;
|
||||||
$c->baseSavePath = $this->alternateBaseSavePath;
|
$c->baseSavePath = $this->alternateBaseSavePath;
|
||||||
@ -466,6 +471,9 @@ PHP;
|
|||||||
"\$lang['en_US']['i18nOtherModule']['MAINTEMPLATE'] = 'Main Template Other Module';",
|
"\$lang['en_US']['i18nOtherModule']['MAINTEMPLATE'] = 'Main Template Other Module';",
|
||||||
$otherModuleLangFileContent
|
$otherModuleLangFileContent
|
||||||
);
|
);
|
||||||
|
|
||||||
|
i18n::set_locale($local); //set the locale to the US locale expected in the asserts
|
||||||
|
+ i18n::set_default_locale($defaultlocal);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testCollectFromEntityProvidersInCustomObject() {
|
function testCollectFromEntityProvidersInCustomObject() {
|
||||||
|
@ -74,6 +74,9 @@ class MoneyTest extends SapphireTest {
|
|||||||
* is re-read properly.
|
* is re-read properly.
|
||||||
*/
|
*/
|
||||||
function testGettingWrittenDataObject() {
|
function testGettingWrittenDataObject() {
|
||||||
|
$local = i18n::get_locale();
|
||||||
|
i18n::set_locale('en_US'); //make sure that the $ amount is not prefixed by US$, as it would be in non-US locale
|
||||||
|
|
||||||
$obj = new MoneyTest_DataObject();
|
$obj = new MoneyTest_DataObject();
|
||||||
|
|
||||||
$m = new Money();
|
$m = new Money();
|
||||||
@ -93,6 +96,8 @@ class MoneyTest extends SapphireTest {
|
|||||||
$this->assertEquals("$987.65", $moneyTest->MyMoney->Nice(),
|
$this->assertEquals("$987.65", $moneyTest->MyMoney->Nice(),
|
||||||
"Money field not added to data object properly when read."
|
"Money field not added to data object properly when read."
|
||||||
);
|
);
|
||||||
|
|
||||||
|
i18n::set_locale($local);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testToCurrency() {
|
public function testToCurrency() {
|
||||||
|
@ -7,7 +7,22 @@ class MemberTest extends FunctionalTest {
|
|||||||
static $fixture_file = 'sapphire/tests/security/MemberTest.yml';
|
static $fixture_file = 'sapphire/tests/security/MemberTest.yml';
|
||||||
|
|
||||||
protected $orig = array();
|
protected $orig = array();
|
||||||
|
protected $local = null;
|
||||||
|
|
||||||
|
function __construct() {
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
//Setting the locale has to happen in the constructor (using the setUp and tearDown methods doesn't work)
|
||||||
|
//This is because the test relies on the yaml file being interpreted according to a particular date format
|
||||||
|
//and this setup occurs before the setUp method is run
|
||||||
|
$this->local = i18n::default_locale();
|
||||||
|
i18n::set_default_locale('en_US');
|
||||||
|
}
|
||||||
|
|
||||||
|
function __destruct() {
|
||||||
|
i18n::set_default_locale($this->local);
|
||||||
|
}
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
@ -18,7 +33,7 @@ class MemberTest extends FunctionalTest {
|
|||||||
|
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
Member::set_unique_identifier_field($this->orig['Member_unique_identifier_field']);
|
Member::set_unique_identifier_field($this->orig['Member_unique_identifier_field']);
|
||||||
|
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,6 +183,9 @@ class SecurityTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testRepeatedLoginAttemptsLockingPeopleOut() {
|
function testRepeatedLoginAttemptsLockingPeopleOut() {
|
||||||
|
$local = i18n::get_locale();
|
||||||
|
i18n::set_locale('en_US');
|
||||||
|
|
||||||
Member::lock_out_after_incorrect_logins(5);
|
Member::lock_out_after_incorrect_logins(5);
|
||||||
|
|
||||||
/* LOG IN WITH A BAD PASSWORD 7 TIMES */
|
/* LOG IN WITH A BAD PASSWORD 7 TIMES */
|
||||||
@ -239,6 +242,8 @@ class SecurityTest extends FunctionalTest {
|
|||||||
|
|
||||||
$this->doTestLoginForm('sam@silverstripe.com' , '1nitialPassword');
|
$this->doTestLoginForm('sam@silverstripe.com' , '1nitialPassword');
|
||||||
$this->assertEquals($this->session()->inst_get('loggedInAs'), $member->ID);
|
$this->assertEquals($this->session()->inst_get('loggedInAs'), $member->ID);
|
||||||
|
|
||||||
|
i18n::set_locale($local);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testAlternatingRepeatedLoginAttempts() {
|
function testAlternatingRepeatedLoginAttempts() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user