From 2ea2cf39e72d243b97f0fba42f85e55fb65e8f73 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 4 Nov 2015 21:50:18 -0500 Subject: [PATCH] Backup the locale property. Don't leave global state in a worse place than when we found it. --- tests/TestCase/Database/Type/DateTypeTest.php | 4 +-- tests/TestCase/I18n/DateTest.php | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/tests/TestCase/Database/Type/DateTypeTest.php b/tests/TestCase/Database/Type/DateTypeTest.php index 1c3ef4b0d37..deb155e5e2a 100644 --- a/tests/TestCase/Database/Type/DateTypeTest.php +++ b/tests/TestCase/Database/Type/DateTypeTest.php @@ -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')); @@ -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')); } diff --git a/tests/TestCase/I18n/DateTest.php b/tests/TestCase/I18n/DateTest.php index 6c3eef5775a..4eafd77fff3 100644 --- a/tests/TestCase/I18n/DateTest.php +++ b/tests/TestCase/I18n/DateTest.php @@ -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 *