Skip to content

Commit

Permalink
Backup the locale property.
Browse files Browse the repository at this point in the history
Don't leave global state in a worse place than when we found it.
  • Loading branch information
markstory committed Nov 6, 2015
1 parent 89ae92d commit 2ea2cf3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/TestCase/Database/Type/DateTypeTest.php
Expand Up @@ -175,7 +175,7 @@ public function testMarshal($value, $expected)
public function testMarshalWithLocaleParsing()
{
$this->type->useLocaleParser();
$expected = new Time('13-10-2013');
$expected = new Date('13-10-2013');
$result = $this->type->marshal('10/13/2013');
$this->assertEquals($expected->format('Y-m-d'), $result->format('Y-m-d'));

Expand All @@ -190,7 +190,7 @@ public function testMarshalWithLocaleParsing()
public function testMarshalWithLocaleParsingWithFormat()
{
$this->type->useLocaleParser()->setLocaleFormat('dd MMM, y');
$expected = new Time('13-10-2013');
$expected = new Date('13-10-2013');
$result = $this->type->marshal('13 Oct, 2013');
$this->assertEquals($expected->format('Y-m-d'), $result->format('Y-m-d'));
}
Expand Down
29 changes: 29 additions & 0 deletions tests/TestCase/I18n/DateTest.php
Expand Up @@ -22,6 +22,35 @@
*/
class DateTest extends TestCase
{
/**
* Backup the locale property
*
* @var string
*/
protected $locale;

/**
* setup
*
* @return void
*/
public function setUp()
{
parent::setUp();
$this->locale = Date::$defaultLocale;
}

/**
* Teardown
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
Date::$defaultLocale = $this->locale;
}

/**
* test formatting dates taking in account preferred i18n locale file
*
Expand Down

0 comments on commit 2ea2cf3

Please sign in to comment.